My task involves using ffmpeg to create video from image sequence. the code belows solves the problem.
import ffmpeg
video = ffmpeg.input('/path/to/images/*.jpg', pattern_type='glob',framerate=20).output(video.mp4).run()
However since the image data we are getting follows the pattern
1.jpg,
2.jpg,
3.jpg
.
.
20.jpg
.
.
100.jpg
the video get created with the glob pattern 1.jpg, 100.jpg, 11.jpg, 12.jpg, ... 2.jpg, 20.jpg, 21.jpg ...
which is very unpleasant to watch.
Is there anyway I can pass a list or anything else aside a path/glob pattern where the images are sorted in order.
Also as a bonus I will be happy if I can choose which files to add as an the input method input()
You may use Concat demuxer:
Create a file
mylist.txt
with all the image files in the following format:You may create
mylist.txt
manually, or create the text file using Python code.Use the following command (you may select different codec):
Second option:
Writing JPEG data into stdin PIPE of FFmpeg sub-process.
jpeg_pipe
input format.Here is a code sample: