开发者

How to get the duration of the video uploaded?

开发者 https://www.devze.com 2023-01-04 01:03 出处:网络
i\'m using ffmpeg to convert videos to desired formats and to generate the thumbnails.. I want to find the total durat开发者_StackOverflow中文版ion of the video to display in the main page along with

i'm using ffmpeg to convert videos to desired formats and to generate the thumbnails..

I want to find the total durat开发者_StackOverflow中文版ion of the video to display in the main page along with the thumbnails..

Can i use ffmpeg to find the duration when its being uploaded and store them on the database.?

Is storing the duration in db is necessary or else is there any other method?


Take a look at this: How To Get Video Duration With FFMPEG and PHP

Down a few replies in that page there is a snippet of code that seems to work for a certain user. I must admit I haven't tested it so it's entirely up to you:

$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];

Hope it helps

0

精彩评论

暂无评论...
验证码 换一张
取 消