Use FFMPEG in PHP to obtain video thumbnails and total video duration. The copy code is as follows: get the video file thumbnail functiongetVideoCover ($ file, $ time, $ name) {if (empty ($ time) $ time1; the first frame in the first second is intercepted by default $ strlenstrle
The code is as follows:
// Obtain the thumbnail of the video file
Function getVideoCover ($ file, $ time, $ name ){
If (empty ($ time) $ time = '1'; // The first frame of the first second is intercepted by default.
$ Strlen = strlen ($ file );
// $ VideoCover = substr ($ file, 0, $ strlen-4 );
// $ VideoCoverName = $videoCover.'.jpg '; // name the thumbnail.
// Exec ("ffmpeg-I ". $ file. "-y-f mjpeg-ss ". $ time. "-t 0.001-s 320x240 ". $ name. "", $ out, $ status );
$ Str = "ffmpeg-I". $ file. "-y-f mjpeg-ss 3-t". $ time. "-s 320x240". $ name;
// Echo $ str ."
";
$ Result = system ($ str );
}
// Obtain the total length and creation time of the video file
Function getTime ($ file ){
$ Vtime = exec ("ffmpeg-I ". $ file. "2> & 1 | grep 'duration' | cut-D'-f 4 | sed s/, //"); // The total length
$ Ctime = date ("Y-m-d H: I: s", filectime ($ file); // creation time
// $ Duration = explode (":", $ time );
// $ Duration_in_seconds = $ duration [0] * 3600 + $ duration [1] * 60 + round ($ duration [2]); // Convert to seconds
Return array ('vtime' => $ vtime,
'Ctime' => $ ctime
);
}
The http://www.bkjia.com/PHPjc/764621.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/764621.htmlTechArticle code is as follows: // Get the thumbnail function of the video file getVideoCover ($ file, $ time, $ name) {if (empty ($ time) $ time = '1 '; // The first frame of the first second is intercepted by default $ strlen = strle...