The command I used :
ffmpeg -itsoffset -40 -i BG.mp4 -vframes 1 output.jpgSee in this command. It's will take a snapshoot at frame 40 from the start frame. And by this way, you have to wait for ffmpeg seek to the frame's Index 40. That's find. But thinking about offset 100,000 or more?. I see it's take long time.
You can this command for "little exactly" but much faster.
ffmpeg -ss 00:00:50 -i BG.mp4 -vframes 1 output.jpgthe ss parameter is time seek of video. That's make thumbnail much faster than seek by frame. You can calculate the -ss parameter by:
ssTimeInSec = FrameOffset / FramePerSecondI write a PHP code to translate TimeInSec to time in -ss parameter.
function translateSecToString($sec){
$sec = intval($sec);
$h = intval($sec / 3600);
$m = intval(($sec - ($h * 3600))/60);
$s = $sec - ($h * 3600) - ($m * 60);
if($h < 10){$h = '0'.$h;}
if($m < 10){$m = '0'.$m;}
if($s < 10){$s = '0'.$s;}
return $h.':'.$m.':'.$s;
}
Hope it can help :D
No comments:
Post a Comment