I have ~10k PNG-Files that I would like to convert into a video.
From looking around the Internet I came across ffmpeg and chose to run the following command:
ffmpeg -f image2 -r 25 -i img/* -vcodec libx264 -crf 22 video.mp4First of all, running this command yielded the prompt File 'img/00001.png' already exists. Overwrite ? [y/N], which seems a little strange to me since, as far as I understand, the command should not modify the images themselves, just create a new video.mp4 file?
Anyhow, I didn't want to press y 10k times, so I backed up my images and modified the command:
ffmpeg -f image2 -r 25 -i img/* -vcodec libx264 -crf 22 -y video.mp4Now, the program seems to run fine for 254 images but then throws the error:
[png @ 0x7facf0503800] ff_frame_thread_encoder_init failed
Error initializing output stream 255:0 -- Error while opening encoder for output stream #255:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!In case it's useful, I added the full log file here. And, for good measure, here is an example from the images I want to convert. Also, here is the infamous frame 255, on which the program crashes.
11 Answer
ffmpeg requires each input file to have its own -i argument, so when you run -i img/*, your shell will expand the wildcard to a series of images, which ffmpeg will in turn read as only one input image, but 10k (minus one) output images. In other words, ffmpeg will see:
ffmpeg … -i img/00000.png img/00001.png …which is telling it to use 00000.png as input and 00001.png as output.
In fact, you will have overwritten all your files 00001.png through 00254.png with the content of 00000.png. So I hope you have a backup of those.
Once you've restored your original input files, please check your command again. You haven't used the %d wildcard to specify image numbers (which was shown in the linked answer). So, use:
ffmpeg -f image2 -framerate 25 -i img/%05d.png -vcodec libx264 -crf 22 video.mp4For more info, check the Slideshow guide. There you'll also find different options for specifying the list of input files (e.g. through a glob pattern, similar to what you were attempting to do).
1