Search code examples
pythonffmpegjupyter-notebook

How to specify start and end frames when making a video with ffmpeg


I am working with python in a jupyter notebook, and I am trying to use ffmpeg to specify the start and end images and convert several images from a folder into a single video. I have a folder, 'images', with the images inside labeled, 'image0', 'image1', 'image2', etc. I would like to specify the start and end images in my video. For example, I would like to be able to make the video using 'image100', to 'image200'. Right now, I have:

!/home/jovyan/ffmpeg-dir/ffmpeg -i /home/jovyan/images/image%d.bmp -frames:v 1000 /home/jovyan/output.mp4

This is making the video correctly, but I believe it is just taking the first 1000 images.

Thanks!


Solution

  • Use -start_number.

    Use the -start_number option to declare a starting number for the sequence. This is useful if your sequence does not start with img001.jpg but is still in a numerical order.

    (source: https://ffmpeg.org/faq.html#toc-How-do-I-encode-single-pictures-into-movies_003f)

    For example, I would like to be able to make the video using 'image100', to 'image200'.

    You need to combine -start_number 100 and -frames:v 101 (101 frames from image100.jpg to image200.jpg).