3

I am trying to create a sample video that shows every half-second frame using ffmpeg.

For example, if a video is 24 fps, I would like to create a video show every 12, 24, 36, 48.. and so on frames and create video with those frames.

I found a way to do that by extracting image files and encoding the result to video.

ffmpeg -i input -vf select='not(mod(n\,12))' -vsync vfr image_%05d.jpg

and to create video,

ffmpeg -framerate 24 -i image_%05d.jpg -c:v libx264 -r 24 -pix_fmt yuv420p output.mpeg

Now, I want to know if there is a way to skip the step of saving image files and get re-encoded video in one process.

1 Answer 1

2

Use

ffmpeg -i input -vf select='not(mod(n\,12)),setpts=N/FRAME_RATE/TB' -r 24 output.mp4

The setpts makes the the selected frames have timestamps in continuous sequence as per the output frame rate.

3
  • Wow thanks Mulvya, I really appreciate your help. It looks like if I drop audio by putting -an option, it works perfectly. Commented Jul 6, 2016 at 1:33
  • er, it has the following error for me Invalid chars ',setpts=N/FRAME_RATE/TB' at the end of expression... any suggestions?
    – ch271828n
    Commented Jan 4, 2019 at 4:27
  • Place the end quote before the comma.
    – Gyan
    Commented Jan 4, 2019 at 4:33

You must log in to answer this question.

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