FFmpeg darkening video

2

I'm trying to switch my encoding setup from Mac to Windows. As part of that, I'm trying to get FFmpeg working as my ProRes encoder.

I'm converting from 10-bit uncompressed to ProRes 422 HQ. When I do, colors are noticeably darker, by comparison to the original uncompressed, and a ProRes from Adobe Media Encoder.

I'm using

./ffmpeg -i testfile.mov -c:v prores_ks -profile:v 3 -pix_fmt yuv422p10le -c:a copy prores422_ks4.mov

I've tried the ProRes and Prores_KS codec, with the same result. I ran MediaInfo on the files an got the following:

Adobe Media Encoder (correct color)

Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   2005.03 (qt  )
File size                                : 208 MiB
Duration                                 : 13 s 13 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 134 Mb/s
Encoded date                             : UTC 2018-03-14 22:08:26
Tagged date                              : UTC 2018-03-14 22:09:38
Writing library                          : Apple QuickTime
TIM                                      : 00:59:53:00
TSC                                      : 24000
TSZ                                      : 1001

Video
ID                                       : 1
Format                                   : ProRes
Format version                           : Version 0
Format profile                           : 422 HQ
Codec ID                                 : apch
Duration                                 : 13 s 13 ms
Bit rate mode                            : Variable
Bit rate                                 : 132 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:2
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 2.654
Stream size                              : 205 MiB (98%)
Writing library                          : Apple
Language                                 : English
Encoded date                             : UTC 2018-03-14 22:08:26
Tagged date                              : UTC 2018-03-14 22:08:26
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

FFmpeg (darker colors)

Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   0000.02 (qt  )
File size                                : 195 MiB
Duration                                 : 13 s 55 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 125 Mb/s
Writing application                      : Lavf57.83.100

Video
ID                                       : 1
Format                                   : ProRes
Format version                           : Version 0
Format profile                           : 422 HQ
Codec ID                                 : apch
Duration                                 : 13 s 55 ms
Bit rate mode                            : Variable
Bit rate                                 : 124 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:2
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 2.485
Stream size                              : 192 MiB (99%)
Writing library                          : Lavc
Language                                 : English
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Original Footage

Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   2005.03 (qt  )
File size                                : 2.42 GiB
Duration                                 : 13 s 55 ms
Overall bit rate                         : 1 592 Mb/s
Encoded date                             : UTC 2018-03-14 20:32:39
Tagged date                              : UTC 2018-03-14 20:32:39

Video
ID                                       : 1
Format                                   : RGB
Codec ID                                 : r210
Codec ID/Hint                            : Blackmagic Design
Duration                                 : 13 s 55 ms
Bit rate mode                            : Constant
Bit rate                                 : 1 591 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
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 32.000
Stream size                              : 2.42 GiB (100%)
Language                                 : English
Encoded date                             : UTC 2018-03-14 20:32:39
Tagged date                              : UTC 2018-03-14 20:32:39
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Here is the output from FFMpeg

Guessed Channel Layout for Input Stream #0.2 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'testfile.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2018-03-14T20:32:39.000000Z
  Duration: 00:00:13.05, start: 0.000000, bitrate: 1592473 kb/s
    Stream #0:0(eng): Video: r210 (r210 / 0x30313272), rgb48le(10 bpc, bt709, progressive), 1920x1080, 1590933 kb/s, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc (default)
    Metadata:
      creation_time   : 2018-03-14T20:32:39.000000Z
      handler_name    : Linux Alias Data Handler
      encoder         : 10 bit packed RGB (r210)
      timecode        : 00:59:53:00
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      rotate          : 0
      creation_time   : 2018-03-14T20:32:39.000000Z
      handler_name    : Libquicktime Time Code Media Handler
      reel_name       : untitled
      timecode        : 00:59:53:00
    Stream #0:2(eng): Audio: pcm_s16be (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2018-03-14T20:32:39.000000Z
      handler_name    : Linux Alias Data Handler
Stream mapping:
  Stream #0:0 -> #0:0 (r210 (native) -> prores (prores_ks))
  Stream #0:2 -> #0:1 (copy)
Press [q] to stop, [?] for help
Output #0, mov, to 'prores422_ks9.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    encoder         : Lavf57.83.100
    Stream #0:0(eng): Video: prores (prores_ks) (apch / 0x68637061), yuv422p10le, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 24k tbn, 23.98 tbc (default)
    Metadata:
      creation_time   : 2018-03-14T20:32:39.000000Z
      handler_name    : Linux Alias Data Handler
      timecode        : 00:59:53:00
      encoder         : Lavc57.107.100 prores_ks
    Stream #0:1(eng): Audio: pcm_s16be (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2018-03-14T20:32:39.000000Z
      handler_name    : Linux Alias Data Handler

Here are some example images of what the change looks like. I can't post full frames or anything identifying of the content, but here are some color swatches.

Media Encoder Beige

FFMpeg Beige

Media Encoder Blue

FFMpeg Blue

Correct Color Bars

FFMpeg Color Bars

Note: I trimmed a black frame or two off the end in Media Encoder

I'm a noob at FFmpeg, so any help would be greatly appreciated! I assume I'm missing something obvious.

Muindor

Posted 2018-03-19T23:56:30.793

Reputation: 21

is it only getting darker or is it getting "less contrasty" all together? could well be that FFmpeg is interpreting your source material as 0-255, when it actually already is 16-240 (I know it's 10bit, but you get the idea...). also, the ffmpeg banner would help - and knowing something about the source. – flolilo – 2018-03-20T00:24:30.200

@flolilolilo I just updated the post with pictures, MediaInfo of the uncompressed source and FFmpeg readout. Thank you so much! – Muindor – 2018-03-20T19:51:24.093

Uh...can you deliver something more..contrasty? ideally, it would be some color-bars, so we can see if it affects the whole spectrum of levels (vulgo: everything gets darker) or if it just compresses the top and bottom parts of the spectrum.

– flolilo – 2018-03-20T20:25:20.160

still, from what I see, I would bet it comes down to the conversion from RGB48 (as ffmpeg calls it) to YUV422. I will check if I can find anything on that topic... – flolilo – 2018-03-20T20:26:30.223

@flolilolilo I just added some color bars. Thanks so much for the help. I'll keep searching too! – Muindor – 2018-03-21T00:16:07.573

as you can see, it only darkens the lighter colors - black even gets lighter. therefore, my guess that it tries to make your video TV-safe (16-235 instead of 0-255 - that's 8 bit, I know ;-) ). I have to go to sleep now, but perhaps this ffmpeg trac "Impossible to transcode full range RGB videos" might be of use. Will look into more of it tomorrow ;-).

– flolilo – 2018-03-21T00:48:41.147

@flolilolilo Now that I know what to search for, I see it is a common issue. I looked into that post and could'nt find a solution, but I'll keep searching :D Thank you! – Muindor – 2018-03-21T18:26:31.027

Was a solution to this problem ever found? – jippyjoe4 – 2019-07-04T19:21:02.133

No answers