Use FFMpeg to get middle frame of a video?

This could be simplified, but here's some old code I had lying around that should to the trick. (Adjust the ffmpeg path to match the location of yours) $output = shell_exec("/usr/local/bin/ffmpeg -i {$path}"); preg_match('/Duration: (0-9{2}):(0-9{2}):(^ ,)+/', $output, $matches); $time = str_replace("Duration: ", "", $matches0); $time_breakdown = explode(":", $time); $total_seconds = round(($time_breakdown0*60*60) + ($time_breakdown1*60) + $time_breakdown2); shell_exec("/usr/local/bin/ffmpeg -y -i {$path} -f mjpeg -vframes 1 -ss " . ($total_seconds / 2) ." -s {$w}x{$h} {$output_filename}.

Thanks, That's just what I was looking for! – Jon Dewees Jul 29 '09 at 23:08.

FFmpeg helps you get the framerate and the length of the video, so you can multiply one by the other and divide by 2 to get the number of the middle frame. Ie for a 30 seconds video running at 15 frames per second : 30 * 15 = 450 / 2 = 225, meaning you need to grab the 225th frame.

FFmpeg certainly doens't have a single option for that. Few people need such functionality. Also, I don't think that there's a universal way to find the middle of a video: Depending on the video codec and encoding parameters, you may not be able to find the length of the video or seek to a certain point in that video.

Also, a video may even not have FPS information in it!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions