ffmpegmultimediamjpeg

Incompatible pixel format YUV420P with mjpeg


I am using ffmpeg to make a video from jpeg images using mjpeg codec. I use this command

ffmpeg -i frame%d.jpg -c:v mjpeg -pix_fmt yuv420p -q:v 1 -y out.mp4

and I have this warning the yuvj420p was chosen instead. After reading about that pixel format, I found its deprecated to use YUV420p and set the -color_range. So I did so and set the color_range to 2, but nothing changed.


Solution

  • You get the warning because ffmpeg's internal JPEG encoder expects JPEG-range input, and does so using the old (deprecated) pixfmt YUVJ420P instead of the new method (setting pixfmt=YUV420P with color-range).

    However, that brings us to the core of this question: why are you re-encoding JPEG source images to JPEG? You don't need to! You can just use -c:v copy (instead of -c:v mjpeg) to copy the existing JPEG images as-is into the .mp4 file.