16

I have a bunch of mov / H.264 files, that I'd like to encode into mov/MJPEG. However I'm getting very low quality output. Here's what I tried:

ffmpeg -i a.mov -an -crf 11 -preset slower -pix_fmt yuv420p -vcodec mjpeg -f mov -y b.mov

For H.264 encoding the -crf and -preset flags generate higher quality. But that doesn't seem to work for MJPEG.

llogan
  • 121,796
  • 28
  • 232
  • 243
Arun
  • 1,599
  • 5
  • 19
  • 33
  • 1
    mjpeg is an intra-frame compression scheme only. It looks at a frame, compresses it with jpeg specs, then moves on the the next frame. It doesn't make sense for it to have -crf. -crf is a protocol for an inter-frame compression scheme, where the algorithm tries to save disc space by looking across frames for ways to compress the data rate. I recommend ffmpeg questions to be asked a video.stackexchange.com, neither SO nor SU. – user1934286 Apr 19 '17 at 22:33

1 Answers1

40

Use -q:v to control (M)JPEG quality

The effective range is a linear scale of 2-31, and a lower value will result in a higher quality output.

Examples

Make MJPEG video in MOV container:

ffmpeg -i input.mov -c:v mjpeg -q:v 3 -an output.mov

Output a series of JPG images:

ffmpeg -i input.mov -q:v 2 images_%04d.jpg

Files will be named images_0001.jpg, images_0002.jpg, images_0003.jpg, etc.


Private options

For H.264 encoding the -crf and -preset flags generate higher quality. But that doesn't seem to work for MJPEG.

The MJPEG encoder does not use -crf and -preset; these are "private" options for some encoders such as libx264, libx265, and libvpx. You can see private options like this: ffmpeg -h encoder=mjpeg.

llogan
  • 121,796
  • 28
  • 232
  • 243