Reputation: 1538
I am trying to use ffmpeg to take an audio file, image, and render a video. I need to encode this video correctly to be able to upload to YouTube, but am running into an error saying:
[libx264 @ 0x7fffbc28a380] width not divisible by 2 (2001x2048)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
I get this error after using the following command to render the video:
$ ffmpeg -loop 1 -framerate 2 -i 'front.jpg' -i 'output.mp3' -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p outputReEncoded.mkv
The image is a square, so I wan't my output video file to not stretch the image, and just have the square image ontop of a black background. I'm having trouble using scale to fix the width, can anyone help me fix my ffmpeg statement so that my video will correctly render, and be uploadable to YouTube ? Thx
Upvotes: 0
Views: 937
Reputation: 92928
You can use the scale filter.
ffmpeg -loop 1 -framerate 2 -i 'front.jpg' -i 'output.mp3' -vf "scale=2*trunc(iw/2):2*trunc(ih/2),setsar=1" -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p outputReEncoded.mkv
The setsar filter is added to make the pixel/sample aspect ratio square, which Youtube recommends.
Upvotes: 1