Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
24th November 2024, 01:33 | #1 | Link |
Registered User
Join Date: Apr 2024
Posts: 303
|
ffmpeg 709 Colors
This is the information for a video I have. If I make a png image sequence out of it using ffmpeg and/or Shutter Encoder, will the images have the 709 colors from the video?
Code:
Format : AVC Format/Info : Advanced Video Codec Format profile : High@L4.1 Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Format settings, Slice count : 4 slices per frame Codec ID : V_MPEG4/ISO/AVC Duration : 23 min 43 s Bit rate mode : Variable Bit rate : 38.7 Mb/s Maximum bit rate : 40.0 Mb/s Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 23.976 (24000/1001) FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.779 Time code of first frame : 00:59:59:00 Stream size : 6.42 GiB (96%) Default : No Forced : No |
24th November 2024, 05:37 | #2 | Link | ||
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 3,153
|
Yes it will, however please note that it will convert the range from Limited TV Range to Full PC Range during the yv12 to rgb24 conversion.
Here's a simple yv12 limited tv range output generated to simulate your source: Quote:
And here's the mediainfo of the corresponding PNG file: Code:
General Complete name : New File 000000.png Format : PNG Format/Info : Portable Network Graphic File size : 3.54 KiB Image Format : PNG Format/Info : Portable Network Graphic Compression : Deflate Format settings : Linear Width : 848 pixels Height : 480 pixels Display aspect ratio : 16:9 Color space : RGB Bit depth : 8 bits Compression mode : Lossless Stream size : 3.54 KiB (100%) BT709 is indeed still there and preserved, but given that Studio RGB (i.e RGB Limited TV Range) isn't really a thing outside of broadcast environments, pretty much any software that converts to RGB will make the picture Full PC Range. In the 8bit case we're going from 16-235 to 0-255. As a side note, the reason why Studio RGB is only used in broadcast and isn't really widespread is that SDI cables need some codes to carry stuff like the timecode and other sync codes, so you wouldn't be able to carry the whole 255 values. Anyway, this can be easily simulated like this: Quote:
As you can see, the first one, the original video, never exceeds the 235 top and only ever goes down the 16 bottom in one specific section on the right hand side dedicated to the super black. In other words, it's 8bit limited tv range. On the other hand, the second one, the screenshot, happily hits the 255 ceiling (i.e white) and 0 bottom (i.e black) as it's 8bit full pc range. Again, this kind of conversion is pretty safe and there aren't any issues unless you actually have out of range values (i.e things going above 235 or 0.7V and below 16 or 0.0V) 'cause when your 235 gets mapped to 255 anything above 235 is automatically lost as it can't be mapped above 255. In any case, in a properly graded and encoded limited tv range file there shouldn't be anything going out of range in the first place 'cause every TV is RGB Full PC Range anyway and it would perform the exact same conversion anyway, so any out of range highlight would be clipped out. This is exactly why I always tell all my coworkers to be extremely careful during live events and to always perform soft highlights rollback to dim them and make them fall within the 0.0-0.7V range. |
||
24th November 2024, 05:50 | #3 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,599
|
Quote:
2) For a source without colorimetry flags, unless otherwise specified, ffmpeg will use bt601 by default, not 709, for the YUV=>RGB conversion |
|
24th November 2024, 13:22 | #4 | Link | |
Registered User
Join Date: Apr 2024
Posts: 303
|
Quote:
Code:
ffmpeg -i input.mkv output%d.png |
|
24th November 2024, 15:13 | #6 | Link | |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 234
|
Quote:
Code:
ffmpeg -colorspace bt709 -color_trc bt709 -color_primaries bt709 -color_range tv -i input.mkv output%d.png |
|
24th November 2024, 15:42 | #7 | Link | |
Registered User
Join Date: Aug 2024
Posts: 326
|
Quote:
Faster and better. The only benefit of swscale IMO is it can handle more obscure pixel formats. |
|
24th November 2024, 17:05 | #8 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,599
|
Beware the problem with ffmpeg using -colorspace etc..., or with colorimetry tagged files and using png output - is the output png still has gAMA and cHRM tags. This causes the colors to be displayed inconsistently in different programs . A browser may display certain colors, a picture viewer something else. Different source filters can display different colors. A long standing ffmpeg issue with several open tickets and discussion
For untagged files, I would use zscale too. If using swscale, beware it uses a "fast" less accurate conversion unless you use -sws_flags full_chroma_int+accurate_rnd |
24th November 2024, 17:51 | #9 | Link | |
Registered User
Join Date: Apr 2024
Posts: 303
|
Quote:
|
|
24th November 2024, 19:44 | #10 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,599
|
Not sure, I don't use shutter encoder . It depends on what commands it's passing to ffmpeg, and/or other operations it's performing. Maybe it has some logic that makes assumptions about a given resolution and colorimetry. You can test it.
|
24th November 2024, 19:50 | #11 | Link |
Registered User
Join Date: Jun 2024
Location: South Africa
Posts: 234
|
Z2697, poisondeathray, I do use zscale for actual conversion or scaling; no contest, it leaves swscale in the dust. However, I found that using those switches before the input merely sets the values for the internal structures, as far as I can tell from the debug log, and doesn't do any conversion (the auto-inserted swscale filter).
|
25th November 2024, 16:20 | #13 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,599
|
Quote:
1) If you leave it as-is, the default YUV to RGB conversion uses Rec601 2) For non colorimetry flagged sources - you control the conversion by specifying the input matrix as 709 using zscale or swscale. Use the sws scale switches mentioned above if you care about less error when using swscale. eg Code:
-vf zscale=min=709,format=gbrp |
|
25th November 2024, 17:19 | #14 | Link | |
Registered User
Join Date: Apr 2024
Posts: 303
|
Quote:
|
|
25th November 2024, 19:30 | #15 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,599
|
Ask a ffmpeg developer . There are tickets for this already.
The gAMA, cHRM tag issue is specific to PNG . Even if the underlying YUV to RGB conversion in ffmpeg is correct, the PNG can have problems being displayed in programs The most consistent PNG display is no gAMA, cHRM tags - it essentially displays the same everywhere It's easy to verify this, if you strip the gAMA, cHRM tags, the PNG now displays correctly in browsers and other programs. Quote:
see #2 in the post above "For non colorimetry flagged sources..." Also point #2 in my first reply "For a source without colorimetry flags, unless otherwise specified,..." Nothing is guaranteed to be automatically correct in ffmpeg-land. You should always verify your workflow, because there are a bunch of "gotchas" Jpeg is different because there are YUV variants, subsampled variants, RGB variants. Also, it is supposed to use full range 601 (pc 601) - as per the jpeg spec , not Rec709, not limited range. Common conversions should be handled correctly automatically in ffmpeg already (because jpeg is/was so common, all the bugs have been fixed), but you can test and verify . Obscure input formats might need some other switches for the correct conversion AVIF isalso different because they have pixel format variations as well, possible different conversions. For example a YUV AVIF wouldn't need any changes to matrix, because the input is YUV. You aren't converting to RGB in that case Webp lossless is RGB only, but lossy web is YUV. So you have to control the YUV to RGB conversion for lossless webp for the correct colors, otherwise bt601 is used GIF is actually PAL8 , not sure if the conversion is correct, you have to test |
|
25th November 2024, 20:40 | #16 | Link |
Life's clearer in 4K UHD
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,293
|
Why can't us regular folk create Jpeg 2000 images as used with DCP (Digital Cinema Package)/DCI?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
|
25th November 2024, 22:35 | #17 | Link | |
Registered User
Join Date: Mar 2011
Posts: 4,972
|
Quote:
https://en.wikipedia.org/wiki/JPEG_2000#Legal_status Or maybe partly due to obsolescence. https://en.wikipedia.org/wiki/JPEG_XL JPEG_XL has a lossless mode. It seems to compare with PNG for compression only it's much slower (unless it's the IrfanView implementation or something peculiar to my setup). |
|
25th November 2024, 22:43 | #18 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,599
|
Quote:
Compression wise JPEG-XL is much better than png at the highest compression levels, but much slower Here are some compression tests on a single image anime frame (notice the thread starter... he had multiple login handles that all got banned on that site for basically rehashing the same questions over and over... just saying....) https://forum.videohelp.com/threads/...es#post2722950 |
|
25th November 2024, 22:48 | #19 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,972
|
jay123210599,
SMPlayer can save screenshots of frames as it plays a video as png, webp or jpeg. I haven't messed around with it much but you can increase the playback speed by a fair amount so you shouldn't have to do it in real time. I'd be willing to give SMPlayer the benefit of the doubt in respect to always saving the images with the correct colors. Here's a few jpegs with a section of the rec.709 video they were taken from. Test.zip (6.9 MB) |
25th November 2024, 23:02 | #20 | Link | ||
Registered User
Join Date: Oct 2012
Posts: 8,250
|
Quote:
this is not fix by ffmpeg. even if the meta data is correct programs will interpret them wrong. one of these is literally the windows picture "app" it will assume that your display is gamma 2.2 so not the same issue where HDR assumes sRGB for SDR sources but similar. well ffmpeg could fix interpreting bt 1886 as something around 2.0 by using the bt 709 encoding function for what ever reason. i don't hold my breath on that... stripping is the way to go! Quote:
https://developer.nvidia.com/nvjpeg2...get_os=Windows i guess i simply don't know about a DCI limitation? |
||
Tags |
colorspace, ffmpeg, ffmpeg gui, image-quality |
Thread Tools | Search this Thread |
Display Modes | |
|
|