0

I have around 1000 frames in *.png format, which are named like frame-0.png, frame-1.png, frame-2.png and so on. I read them and generate a movie by following command :

ffmpeg -f image2 -r 20 -i frame-%00d.png -vcodec mpeg4 -y movie.mp4 

Let's say I just want to read frames like frame-0.png,frame-20.png, frame-40.png and make a movie out of it. How can I achieve that ?

One possible way I know, is to make movie from all 1000 frames then generate a new movie by skipping frames from the following command :

ffmpeg -y -i movie.mp4 -filter:v "select='mod(n,20)'" out.mp4

Is there any direct method ?

1 Answer 1

0

The direct way to do this is by using the concat demuxer, where the text file only mentions the selected files. Besides being a hack, you no longer get to use the image2 options. The better way is to combine your present commands.

ffmpeg -framerate 20 -i frame-%d.png -vf "select='not(mod(n,20))'" -c:v mpeg4 -y movie.mp4 
4
  • This works only if all the frames are present. What If I have only frame-0.png, frame-20.png, frame-40.png available.
    – Grayrigel
    Commented Feb 13, 2017 at 14:34
  • Then, you use the demuxer or pipe the images. To pipe, on Win: cat *.png | ffmpeg -f image2pipe -framerate 1 -i - -r 20 -y out.mp4
    – Gyan
    Commented Feb 13, 2017 at 15:00
  • Command in comment above will also work on Linux & macOS.
    – llogan
    Commented Feb 13, 2017 at 18:13
  • Also, I forgot about image autodetection, so you can likely omit the -f.
    – llogan
    Commented Feb 14, 2017 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.