Reputation: 508
Does anyone know how I can achieve the following color space (bt.709) via FFmpeg?
Here is what I have now in my files...
As you can see there is Format settings, Matrix
as default, how can I set it like this :
Thank you
Upvotes: 6
Views: 31134
Reputation: 4425
After much searching, the secret option that has to be passed to ffmpeg for proper BT.709 encoding is found to be inside the video filter feature.
Note: The -vf
video filter option will actually transform the RGB values while the other 709 flags just indicate what flags will be included in the container settings (eg: as some MP4 metadata).
This example starts with a 32x32 png that is set to (RGB = 0, 0, 255
) or max blue.
ffmpeg -y -i Blue32x32.png -c:v libx264 -pix_fmt yuv420p -preset:v slow -profile:v baseline -crf 20 -vf scale=out_color_matrix=bt709 -color_primaries bt709 -color_trc bt709 -colorspace bt709 Blue32x32_709.m4v
ffmpeg -y -i Blue32x32_709.m4v Blue32x32_709.y4m
od -v -t u1 Blue32x32_709.y4m
The output of the last/bottom FFmpeg command will dump the byte values as ints, you should see (Y Cb Cr) values as Y = 32, Cb = 240, Cr = 118
which means the BT.709 conversion matrix is being used in the .m4v
file. When decoded back to RGB the transformed color is 2, 0, 255
.
Upvotes: 11
Reputation: 93329
With re-encoding, use
ffmpeg -i test.mxf -c copy -c:v mpeg2video -b:v 5000k \
-color_primaries 1 -color_trc 1 -colorspace 1 out.mxf
In Mediainfo, at the end of the video stream attributes, you should see the three color-related entries. Note that Format settings (Matrix) is related to MPEG quantization and not color.
Upvotes: 15