FFmpeg scene detection and scenecut

encodingffmpegvideovideo-encoding

This is a follow-up question from my previous question posted HERE. So basically using FFmpeg, I'm trying to detect scenes after choosing a good scenecut threshold, and grab a single representative frame out of each scene.

Right now, the below scene detection command we already have, saves the detected scenes on disk, which unfortunately takes a long time:

ffmpeg -y -i myVideo.mp4 -vf yadif \
       -c:v libx264 -profile:v high -preset:v fast \
       -x264opts min-keyint=15:keyint=1000:scenecut=20 -b:v 2000k \
       -c:a aac -b:a 128k \
       -f segment -segment_format mp4 -segment_time 0.01 -segment_format_options movflags=faststart \
       /home/1/output%05d.mp4

My eventual goal is to identify the scenes, and only save a single frame out of that scene as an image (say middle frame of that scene) instead of encoding and saving the whole scene videos. Is there a fast way to achieve that?

Best Answer

This should work for getting the first frame of the shot.

ffmpeg -i video.mp4 -filter:v "select=gt(scene\,0.5)" -vsync vfr output/frame%d.jpg 
Related Question