Search code examples
ffmpeglibx264

Error initializing output stream ffmpeg on Rasbpi converting jpg to video


I have a folder with thousands of jpgs at 1024x768 that I want to convert into a single video for playback.

The error I get is Error initializing output stream 73:0 -- Error while opening encoder for output stream #73:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed!

Here's my input $ ffmpeg -i Timelapse/*.jpg -c:v libx264 -preset ultrafast -crf 0 output.mkv -y

What is strange is it errors on a specific numbered output stream. It seems to be either 71:0, 72:0, or 73:0. I thought it was something wrong with the file it is attempting to process in the given stream but the resolution is all the same (as I've seen errors when its not divisible by 2). I've deleted the 71st-73rd image in hopes it was somehow messed up but that doesn't help either. I've ensured my libx264 is installed correctly as well.

Any suggestions?

Terminal output example

Terminal output example


Solution

  • Problem

    You forgot the -pattern_type glob input option. As a result ffmpeg expanded the wildcard (*) and interpreted image0000.jpg as the only input and all of the following images as outputs. The command was executed as:

    ffmpeg -i Timelapse/image0000.jpg Timelapse/image0001.jpg Timelapse/image0002.jpg Timelapse/image0003.jpg [...] -c:v libx264 -preset ultrafast -crf 0 output.mkv -y
    

    Because you used -y it overwrote all of the output images without asking you for confirmation.

    Solution

    Using the glob pattern:

    ffmpeg -pattern_type glob -i 'Timelapse/*.jpg' -c:v libx264 -preset ultrafast -crf 0 output.mkv
    

    Or using the sequence pattern which can also be used on Windows:

    ffmpeg -i Timelapse/image%04d.jpg -c:v libx264 -preset ultrafast -crf 0 output.mkv
    

    See FFmpeg image demuxer documentation for more info.