Search code examples
ffmpegh.264video-compression

ffmpeg width not divisible by 2 (375x500) error


i tried to scale the video to 375x500 using ffmpeg.

ffmpeg -i input.mp4 -s 375x500 -c:a copy output.mp4

Getting this error, [libx264 @ 0x5639d358ad60] width not divisible by 2 (375x500) 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 tried so many commands but i didnt get my solution.


Solution

  • libx264 requires width/height to be divisible by 2 when using the standard yuv420p pixel format. Refer to the many suggestions regarding how to fix the not divisible by 2 error with scale/pad/crop:

    However, if you must have exactly 375x500 then you have to use a pixel format that supports this size:

    ffmpeg -i input.mp4 -vf "format=yuv444p,scale=375:500" -c:a copy output.mp4
    

    Drawback is that almost no player or device will be able to play it (unless it uses FFmpeg).

    See the format and scale filter documentation and the output of ffmpeg -pix_fmts for more info.