How to upload video duration?

I use ffmpeg to convert videos to desired formats and create thumbnails.

I want to find the total duration of the video to display on the main page along with thumbnails.

Can I use ffmpeg to find the duration when loading and storing it in the database?

Is duration persistence required in db, or is there any other way?

+5
source share
1 answer

Take a look at this: How to get video duration using FFMPEG and PHP

, , , . , , :

$videofile="/var/video/user_videos/partofvideo.avi";
ob_start();
passthru("/usr/bin/ffmpeg -i \"{$videofile}\" 2>&1");
$duration = ob_get_contents();
ob_end_clean();

$search='/Duration: (.*?),/';
$duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3);
//TEST ECHO
echo $matches[1][0];

,

+2

All Articles