Lossless Chroma Subampling

When exporting video as lossless mp4, the chroma subsampling format is 4:2:0.

In HuffYUV and FFV1 it is 4:2:2.

If it’s truly lossless shouldn’t it be 4:4:4?

Do you have an export pre-set called “lossless mp4”? What version of SC are you using please? I could not find it on my SC.

Or how did you configure your export for “lossless mp4”?

  • Are you just checking your findings for your last export with the forum?
  • Or are you proposing the rename that export setting? To what? Maybe call it “mildly lossy mp4”
  • Or are you proposing that the export settings should be changed internally to 4:4:4 (if it is indeed part of SC)?

Just let us know, maybe then there will be further answers.

Not if the source is 4:2:0. The presets are for convenience. It assumes that most source clips are 4:2:0. You can make your own presets to use 4:4:4. But Shotcut does not use a native 4:4:4 format internally. It has YUV4:2:2 and RGB24.

How?

It would be nice to have a choice of 4:4:4, 4:2:2 or 4:2:0 in the custom-export dialog.

Shotcut uses the FFMpeg library to perform encoding. You can pass custom FFMpeg parameters to the encoder on the “Other” tab. I haven’t tried the exact steps to change the chroma format. But here are some flags you could research to see if you can get something to work for you:

for x264 encoding:
-profile:v high444
Additional info:
https://trac.ffmpeg.org/wiki/Encode/H.264

For other formats, this might work (if it is supported):
-pix_fmt yuv422p

If you can find an FFMpeg command sequence that produces the result you want, then it should be possible to transpose that to the “Other” tab in Shotcut.

Along with chroma formats, it would be nice to support Rec.2020 color space and higher bit depths (10bit, 12bit). But like I said, internally, Shotcut does not have that much precision yet. So exporting to those higher quality formats would just be wasting space on precision that doesn’t actually exist in the pictures.

1 Like

Do I simply paste an entire ffmpeg command line into “other” or just the part containing -pix_fmt yuv444p? If I could post a complete ffmpeg command line into “other”, that would be great!

ffmpeg can be pretty finicky about how its command lines are structured and the sequence they’re in.

Yes I do. I see it in the latest version.

It’s not truly lossless if it’s not 4:4:4. The clips are coming out at 4:2:0 and 4:2:2.

I’m taking it on faith that ffmpeg is using crf 0 which is actually variable bit rate or what they call “lossless”.

No. You provide the codec parameters that you supply to ffmpeg.
There is a list of supported parameters that the underlying MLT framework supports here:
https://mltframework.org/plugins/ConsumerAvformat/
The parameters need to be provided in a manor that is appropriate for the FFMpeg codec they apply to. Documentation is here:
http://ffmpeg.org/ffmpeg-codecs.html

2 Likes

This statement could possibly misinform people. The output will only lose chroma information if the output chroma format has fewer samples than the source file chroma format. Most Shotcut users (>90%) will only be using sources from their phones and prosumer cameras - which will have a chroma format of 4:2:0. So 4:2:0 is lossless for them. A few Shotcut users (<10%) might have source files with 4:2:2 chroma sampling from higher end cameras. They might want to choose the lossless formats with 4:2:2 chroma sampling. Very few Shotcut users (<1%) might be using source files with 4:4:4 chroma sampling. That very small minority will certainly lose chroma information because Shotcut does not have an internal image format that preserves 4:4:4 chroma sampling.

The term “lossless” in this context wasn’t really meant to refer to the chroma sampling. It was intended to refer to the detail lost to compression artifacts. And it should actually be interpreted “perceptually lossless” meaning there might be a mathematical difference between the source and output files, but those differences would not be perceivable to the human eye.

Yes, it would have to be 4:4:4 from end to end to be truly lossless. This might be the case with animation or graphics.

If I give ffmpeg a 4:2:0 source, will ffmpeg resample the chroma and output anything other than the unmodified chroma samples in the source file? That is what I’m trying to avoid.

That was easier than I thought it would be. I simply pasted this line into “Other” and it came out 4:4:4 according to MediaInfo.

pix_fmt=yuv444p

The way Shotcut uses FFMpeg to encode will cause a chroma format conversion if the source does not match the output preset. This could result in upsampling or downsampling depending on source and output formats.

I see, so best to keep a 4:2:0 source at 4:2:0 and avoid up/downsampling.

Theoretically there could be some chroma bleeding when upsampling from 4:2:0 to 4:2:2. I doubt it would be perceivable. But if you want to be very picky, then you would not want to perform the chroma conversion.

All I need is a camcorder that shoots in 4:4:4.

1 Like