4

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?

4
  • 1
    See stackoverflow.com/q/40688062/5726027 and 2nd part from stackoverflow.com/q/34962426/5726027
    – Gyan
    Jul 9, 2018 at 17:26
  • @Gyan Very useful. But ffmpeg -i video.mp4 -vsync 0 -vf select='gt(scene\,0.4)' -f image2 img-%04d.png doesn't work for me, and shows me error: Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
    – Tina J
    Jul 9, 2018 at 17:37
  • 1
    You should run cmd from first link and then prepare text file as shown in 2nd link.
    – Gyan
    Jul 9, 2018 at 18:04
  • Thanks @Gyan. Assuming I need only the first frame of scene, what would be a single-run command (not two commands)?
    – Tina J
    Jul 12, 2018 at 17:32

1 Answer 1

3

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 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .