[FFmpeg-user] The internal ffmpeg rgb=>yuv pipeline and conversion matrices
rabbit+list at rabbit.us
Fri May 6 16:04:09 CEST 2016
I am having trouble finding info on how to properly control color
reproduction, both in terms of "reference manual" and in terms of "best
practice guides". If I missed a resource neatly explaining everything I
am confused about below, please do not hesitate to "RTFM" me ;)
I am looking to produce high quality 720p H264 streams derived from RGB
source material. Both the source and 99.999% of the playback
environments are 24bit RGB color platforms (pc/mobile/etc displaying a
youtube/vimeo/etc window in a browser)
For simplicity let's construct a non-sensical RGB source:
ffmpeg -y -r 30 \
-filter_complex 'color=c=00aa00:s=320x200; color=c=00aa00:s=1280x720' \
-c:v libx264 -pix_fmt yuv444p -profile:v high444 -qp 0 -preset:v
-t 5 greenz.mkv
This will generate two identical 5 second video streams of the #00AA00
green, with the only difference being the screen size (ultra-sub-SD vs
HD). If then we render these streams on-screen, and add a pure RGB
"control output" and take a screenshot we end up with the attached image.
The 320x200 is displayed properly, although the color is slightly off:
#00AB01. I assume that this loss is due to the inherently-imperfect
RGB24 => YUV444P transition, and there isn't much one can do about it.
However the 720p playback is *way* off, at #009000. I can "correct" it
by playing via `mpv --vid=2 --vf=format=colormatrix=bt.601 greenz.mkv`
or by explicitly tagging the H264 bitstream at encoding time via `...
- What is the "default" conversion matrix used within ffmpeg when
nothing else is specified. Is it (apparently) bt.601, or does it default
to different things depending on input?
- If it is bt.601 is it bt470bg or is it smpte170m or in the matrix case
it doesn't matter?
- Is the visual change during playback (via mpv in this case) of the
"untagged" streams based solely on the output size? Or is there another
reason why stream1 looks different than stream2 with default settings?
- Is it "ok" to produce 720p video explicitly tagged at bt.601? I ran
across multiple writeups on the net suggesting 720p not encoded (is this
the right term?) in bt.709 is a big no-no.
- Regardless of what the answer to the previous question is: If I wanted
to produce the same example video in bt.709 and have it play correctly
in both cases - what would the ffmpeg incantation be?
- Am I correct that the inconsistency #00AA00 => #00AB01 is simply "cost
of doing YUV business", or is the reason more nuanced/involved?
- Anything else I missed/need to know? :)
Thank you in advance for your help!
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 26720 bytes
Desc: not available
More information about the ffmpeg-user