0

だから私はphpでファイルに対してffprobeコマンドを実行し、出力を取得しています(期間、時間などを取得するため)

exec("usr/bin/ffprobe -v quiet-print_format json -show_format -show_streams $location", $output, $exitCode); 

$location は、ファイルの場所 + ファイル名です。現在、このコマンドは .mp4 / .avi /私が試した他のすべてに対して100%完全に機能します。.mov を除いて、.mov を使用すると、「出力」変数が空になります。これを修正/変更する方法はありますか?

4

2 に答える 2

-2

ffprobe では mov ファイルに関する多くの情報は得られません。exiftool を使用します。

ツールをサーバーにインストールします: http://owl.phy.queensu.ca/~phil/exiftool/install.html

あなたがした場合:

exiftool IMG_0014.MOV > a.txt

出力は

ExifTool Version Number         : 8.60
File Name                       : IMG_0014.MOV
Directory                       : .
File Size                       : 19 MB
File Modification Date/Time     : 2013:07:19 12:03:22-10:00
File Permissions                : rw-r--r--
File Type                       : MOV
MIME Type                       : video/quicktime
Major Brand                     : Apple QuickTime (.MOV/QT)
Minor Version                   : 0.0.0
Compatible Brands               : qt
Movie Data Size                 : 19979709
Movie Header Version            : 0
Modify Date                     : 2013:07:19 22:03:21
Time Scale                      : 600
Duration                        : 7.27 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 2013:07:19 22:03:13
Track Modify Date               : 2013:07:19 22:03:21
Track ID                        : 1
Track Duration                  : 7.27 s
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 1920
Image Height                    : 1080
Graphics Mode                   : ditherCopy
Op Color                        : 32768 32768 32768
Compressor ID                   : avc1
Source Image Width              : 1920
Source Image Height             : 1080
X Resolution                    : 72
Y Resolution                    : 72
Compressor Name                 : H.264
Bit Depth                       : 24
Video Frame Rate                : 27.011
Camera Identifier               : Back
Frame Readout Time              : 28512 microseconds
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2013:07:19 22:03:13
Media Modify Date               : 2013:07:19 22:03:21
Media Time Scale                : 44100
Media Duration                  : 7.31 s
Media Language Code             : und
Balance                         : 0
Handler Class                   : Data Handler
Handler Vendor ID               : Apple
Handler Description             : Core Media Data Handler
Audio Channels                  : 1
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Audio Format                    : chan
Model                           : iPhone 4S
Software Version                : 6.1.3
Create Date                     : 2013:07:20 08:03:13+10:00
Make                            : Apple
Handler Type                    : Metadata Tags
Make (und-AU)                   : Apple
Creation Date (und-AU)          : 2013:07:20 08:03:13+10:00
Software (und-AU)               : 6.1.3
Model (und-AU)                  : iPhone 4S
Avg Bitrate                     : 22 Mbps
Image Size                      : 1920x1080
Rotation                        : 90

ビデオファイルからの情報だけが必要な場合は、ffmpeg とこれらの他のすべてのクラスを使用してオンラインで機能させることができます。とにかく、ffmpeg を使用してビデオファイルを照会します。

$ffmpeg_path = 'ffmpeg'; //or: /usr/bin/ffmpeg - depends on your installation
$vid = 'PATH/TO/VIDEO'; //Replace here!

if (file_exists($vid)) {

    $video_attributes = _get_video_attributes($vid, $ffmpeg_path);

    print_r('Video codec: ' . $video_attributes['codec'] . ' - width: '  . $video_attributes['width'] 
            . ' - height: ' .  $video_attributes['height'] . ' <br/>');

    print_r('Video duration: ' . $video_attributes['hours'] . ':' . $video_attributes['mins'] . ':'
           . $video_attributes['secs'] . '.'. $video_attributes['ms']);
} else { echo 'File does not exist.'; }

function _get_video_attributes($video, $ffmpeg) {

    $command = $ffmpeg . ' -i ' . $video . ' -vstats 2>&1';  
    $output = shell_exec($command);  

    $regex_sizes = "/Video: ([^,]*), ([^,]*), ([0-9]{1,4})x([0-9]{1,4})/";
    if (preg_match($regex_sizes, $output, $regs)) {
        $codec = $regs [1] ? $regs [1] : null;
        $width = $regs [3] ? $regs [3] : null;
        $height = $regs [4] ? $regs [4] : null;
     }

    $regex_duration = "/Duration: ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}).([0-9]{1,2})/";
    if (preg_match($regex_duration, $output, $regs)) {
        $hours = $regs [1] ? $regs [1] : null;
        $mins = $regs [2] ? $regs [2] : null;
        $secs = $regs [3] ? $regs [3] : null;
        $ms = $regs [4] ? $regs [4] : null;
    }

    return array ('codec' => $codec,
            'width' => $width,
            'height' => $height,
            'hours' => $hours,
            'mins' => $mins,
            'secs' => $secs,
            'ms' => $ms
    );

}
于 2015-03-25T17:42:39.573 に答える