I read through the ffmpeg documentation and saw that to create a video from an image sequence you can use ffmpeg -i image-%03d.png video.webm
but one of the problems I am having is how I can actually choose different images named different things each time for instance a picture named "pilot.png" and another named "airplane.png".
Asked
Active
Viewed 167 times
0

UserErrorLoL
- 11
- 1
-
Using a Python script, you may write the images to stdin pipe of FFmpeg sub-process. Here is an example for [H.265 video encoding](https://stackoverflow.com/questions/61260182/how-to-output-x265-compressed-video-with-cv2-videowriter) (use `libvpx-vp9` codec for VP9 or `libvpx` for VP8 instead of `libx265`). In case you don't want to decoded the PNG images, you may use something as [this post](https://stackoverflow.com/a/61148924/4926757). Make sure all images have the same resolution and have the same pixel format (all RGB or all RGBA). – Rotem Jun 03 '22 at 10:33
-
Thank you for the information. So when I am using a sub-process, how can I handle problems involving format codes. For instance I am calling ` subprocess.call('ffmpeg -i image-%d*.png -vf zoompan=d=(%d)/1:fps=1/1,framerate=25:interp_start=0:interp_end=255:scene=100 -c:v mpeg4 -maxrate 5M -q:v 2 out.mp4'%(timeperimage + 1), shell = True)` but one of the problems here is I need to pass a var for the second format code but not for the first. How can I keep this behavior with the subprocess? – UserErrorLoL Jun 03 '22 at 15:40
-
I don't understand what do you mean by "pass a var for the second format code but not for the first". The command is a string. Add `shlex.split` – Rotem Jun 03 '22 at 16:03
-
Thank you for the information. Additionally, you mentioned the pictures needing to have the same resolution and pixel format. Is there any way I can standardize all of the images with ffmpeg or do I need another solution? – UserErrorLoL Jun 06 '22 at 13:44
-
You may use OpenCV for reading each image, and resizing it before writing to FFmpeg. In that kind of solution you are writing raw images. – Rotem Jun 06 '22 at 15:01