Opened 11 years ago

Closed 3 years ago

Last modified 3 years ago

#3409 closed defect (invalid)

Impossible to transcode full range RGB videos with libx264, and keep full range + proper colors

Reported by: mzso Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: dqeswn@gmail.com, rogerdpack@gmail.com, mirh Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I encountered this while trying to transcode screencasted videos with fraps or ut-video streams.

When using yuv444p pixel format I get washed out, too light videos.

"-color_range" has no affect.

People suggested: "-vf colormatrix=bt601:bt709" But it also doesn't have an affect.

x264 itself has issues with RGB full range videos, if I use i444 with it I also get improper output. But if I use "--output-csp rgb" it succeds in encoding a proper output file, though with a large file size.
I can't even achieve this with ffmpeg because it doesn't let me use RGB with libx264: "Incompatible pixel format 'rgb24' for codec 'libx264', auto-selecting format 'yuv444p'"

Attachments (5)

fr-rgb-sample.mkv (1.6 MB ) - added by mzso 11 years ago.
Sample of a file with the issue
rgb-source.png (1.8 MB ) - added by mzso 11 years ago.
RGB Source screenshot
yuv-x264.png (2.1 MB ) - added by mzso 11 years ago.
Screenshot of file encoded to yuv444 with x264 using avisynth with "crf 0"
yuv-ffmpeg-crf0.png (2.1 MB ) - added by mzso 11 years ago.
Screenshot of file encoded to yuv444 with ffmpeg/libx264 with "crf 0"
yuv-ffmpeg-crf0-avisynth.png (1.9 MB ) - added by mzso 11 years ago.
Screenshot of file encoded to yuv444 with ffmpeg/libx264 using avisynth input with "crf 0"

Change History (29)

comment:1 by Carl Eugen Hoyos, 11 years ago

To make this a valid ticket, please provide your failing command line together with the complete, uncut console output. To encode to H264 RGB, use -vcodec libx264rgb

comment:2 by mzso, 11 years ago

Something like this? (Didn't think it shows anything useful)

E:\Videó Felvételek>ffmpeg -i "E:\Videó Felvételek\input.avi"  -acodec copy -vcodec libx264 -preset ultrafast -crf 20 -color_range 2 -pix_fmt yuv444p  out.mkv
ffmpeg version N-60813-g44b22bb Copyright (c) 2000-2014 the FFmpeg developers
  built on Feb 22 2014 03:11:45 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 65.100 / 52. 65.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  1.103 /  4.  1.103
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, avi, from 'E:\Vide├│ Felv├ętelek\input.avi':
  Duration: 00:00:27.27, start: 0.000000, bitrate: 405890 kb/s
    Stream #0:0: Video: utvideo (ULRG / 0x47524C55), rgb24, 1920x1200, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 7.1, s16, 5644 kb/s
[libx264 @ 029370e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 029370e0] profile High 4:4:4 Predictive, level 5.0, 4:4:4 8-bit
[libx264 @ 029370e0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=6 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, matroska, to 'out.mkv':
  Metadata:
    encoder         : Lavf55.33.100
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p(pc), 1920x1200, q=-1--1, 1k tbn, 30 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 7.1, 5644 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (utvideo -> libx264)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  533 fps= 13 q=-1.0 Lsize=   84544kB time=00:00:27.26 bitrate=25400.1kbits/s
video:65784kB audio:18742kB subtitle:0 data:0 global headers:0kB muxing overhead 0.020164%
[libx264 @ 029370e0] frame I:3     Avg QP:17.00  size:430087
[libx264 @ 029370e0] frame P:530   Avg QP:19.47  size:124665
[libx264 @ 029370e0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 029370e0] mb P  I16..4: 16.0%  0.0%  0.0%  P16..4: 47.2%  0.0%  0.0%  0.0%  0.0% skip:36.8%
[libx264 @ 029370e0] coded y,u,v intra: 45.4% 3.6% 4.0% inter: 35.0% 3.6% 3.4%
[libx264 @ 029370e0] i16 v,h,dc,p: 34% 31% 24% 11%
[libx264 @ 029370e0] kb/s:19739.97
Last edited 11 years ago by Carl Eugen Hoyos (previous) (diff)

in reply to:  2 ; comment:3 by Carl Eugen Hoyos, 11 years ago

Replying to mzso:

    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p(pc), 1920x1200, q=-1--1, 1k tbn, 30 tbc

What is the problem now with the output video? You requested MPEG-style colour range (16-235), is something else produced? Or do you want full range?

in reply to:  3 comment:4 by mzso, 11 years ago

Replying to cehoyos:

Replying to mzso:

    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p(pc), 1920x1200, q=-1--1, 1k tbn, 30 tbc

What is the problem now with the output video? You requested MPEG-style colour range (16-235), is something else produced? Or do you want full range?

Yes I want full range.

comment:5 by Carl Eugen Hoyos, 11 years ago

Resolution: invalid
Status: newclosed

Then please request full range with -pix_fmt yuvj444p.

People suggested:

Where did you ask? This is a bug tracker, not a support forum, please post all usage questions to the user mailing list.

Last edited 11 years ago by Carl Eugen Hoyos (previous) (diff)

in reply to:  5 ; comment:6 by mzso, 11 years ago

Replying to cehoyos:

The please request full range with -pix_fmt yuvj444p.

"-color_range 2" is supposed to be fullrange according to the help (it actually is according to the renderer just with wrong colors) No-one told me that I should use yuvj444p instead of yuv444p, and it was virtually impossible to figure out from the ffmpeg help and googling
wasn't fruitful. Sorry.
Thanks for the tip again. I get proper video now, albeit with a warning: "[swscaler @ 0400f260] deprecated pixel format used, make sure you did set range correctly"

Where did you ask? This is a bug tracker, not a support forum, please post all usage questions to the user mailing list.

I know. Mostly on doom9. At one point wrote at the ffmpeg irc but that was inactive.

in reply to:  6 comment:7 by Carl Eugen Hoyos, 11 years ago

Replying to mzso:

Replying to cehoyos:

Then please request full range with -pix_fmt yuvj444p.

"-color_range 2" is supposed to be fullrange according to the help

The documentation is wrong afaict, see tickets #443 and #3326.
It has never worked for encoding and I am not convinced it is meant to have any effect on encoding.

comment:8 by Carl Eugen Hoyos, 11 years ago

I am curious: Which player do you use for playback?

in reply to:  8 comment:9 by mzso, 11 years ago

Replying to cehoyos:

I am curious: Which player do you use for playback?

Potplayer with LAV Filters + madVR.

comment:10 by mzso, 11 years ago

Resolution: invalid
Status: closedreopened

Looks like the colors are not right after all. If I use the colormatrix filter the result just gets worse. A lot of detail loss.

-vcodec libx264 -preset slower -crf 18 -pix_fmt yuvj444p:
http://screenshotcomparison.com/comparison/64322

-vcodec libx264 -preset slower -crf 18 -pix_fmt yuvj444p -vf colormatrix=bt601:bt709:
http://screenshotcomparison.com/comparison/64323

comment:11 by Carl Eugen Hoyos, 11 years ago

Please provide an input sample and your failing command lines together with the complete, uncut console output to make this a valid ticket.

in reply to:  11 comment:12 by mzso, 11 years ago

Replying to cehoyos:

Please provide an input sample and your failing command lines together with the complete, uncut console output to make this a valid ticket.

The input is a 270 MB screencap... Mayble I'll try to remux a few frames or something.

by mzso, 11 years ago

Attachment: fr-rgb-sample.mkv added

Sample of a file with the issue

comment:13 by mzso, 11 years ago

A uploaded a two frame file, I remuxed with mkvmerge.

Command line 1:
E:\Videó Felvételek>ffmpeg -i "E:\Videó Felvételek\fr-rgb-sample.mkv" -an -vcodec libx264 -preset slower -crf 18 -pix_fmt yuvj444p fr-rgb-sample-transcode.mkv
ffmpeg version N-60813-g44b22bb Copyright (c) 2000-2014 the FFmpeg developers

built on Feb 22 2014 03:11:45 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-l

ibgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora -
-enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib

libavutil 52. 65.100 / 52. 65.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 1.103 / 4. 1.103
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100

Input #0, matroska,webm, from 'E:\Vide+- Felv+ętelek\fr-rgb-sample.mkv':

Metadata:

encoder : libebml v1.3.0 + libmatroska v1.4.1
creation_time : 2014-02-25 17:09:53

Duration: 00:00:00.03, start: 0.000000, bitrate: 395171 kb/s

Stream #0:0: Video: utvideo (ULRG / 0x47524C55), rgb24, 1600x1200, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)

[swscaler @ 027788a0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 02768980] using SAR=1/1
[libx264 @ 02768980] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 02768980] profile High 4:4:4 Predictive, level 5.0, 4:4:4 8-bit
[libx264 @ 02768980] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=8 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=9 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 c
hroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb
=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'fr-rgb-sample-transcode.mkv':

Metadata:

encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj444p, 1600x1200 [SAR 1:1 DAR 4:3], q=-1--1, 1k tbn, 30 tbc (default)

Stream mapping:

Stream #0:0 -> #0:0 (utvideo -> libx264)

Press [q] to stop, ? for help
frame= 1 fps=0.0 q=24.0 Lsize= 97kB time=00:00:00.03 bitrate=24133.3kbits/s
video:97kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.589085%
[libx264 @ 02768980] frame I:1 Avg QP:20.97 size: 98237
[libx264 @ 02768980] mb I I16..4: 4.2% 81.3% 14.5%
[libx264 @ 02768980] 8x8 transform intra:81.3%
[libx264 @ 02768980] coded y,u,v intra: 84.7% 19.1% 12.0%
[libx264 @ 02768980] i16 v,h,dc,p: 9% 25% 24% 42%
[libx264 @ 02768980] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 3% 5% 3% 13% 17% 11% 23% 10% 16%
[libx264 @ 02768980] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 4% 8% 3% 10% 15% 9% 25% 9% 16%
[libx264 @ 02768980] kb/s:23576.88

Command line 2:
E:\Videó Felvételek>ffmpeg -i "E:\Videó Felvételek\fr-rgb-sample.mkv" -an -vcodec libx264 -preset slower -crf 18 -pix_fmt yuvj444p -vf colormatrix=bt601:bt709 fr-rgb-sample-transcode-vf.mkv
ffmpeg version N-60813-g44b22bb Copyright (c) 2000-2014 the FFmpeg developers

built on Feb 22 2014 03:11:45 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-l

ibgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora -
-enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib

libavutil 52. 65.100 / 52. 65.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 1.103 / 4. 1.103
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100

Input #0, matroska,webm, from 'E:\Vide+- Felv+ętelek\fr-rgb-sample.mkv':

Metadata:

encoder : libebml v1.3.0 + libmatroska v1.4.1
creation_time : 2014-02-25 17:09:53

Duration: 00:00:00.03, start: 0.000000, bitrate: 395171 kb/s

Stream #0:0: Video: utvideo (ULRG / 0x47524C55), rgb24, 1600x1200, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)

[swscaler @ 026d7fc0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 027e8680] using SAR=1/1
[libx264 @ 027e8680] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 027e8680] profile High 4:4:4 Predictive, level 5.0, 4:4:4 8-bit
[libx264 @ 027e8680] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=8 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=9 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 c
hroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb
=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'fr-rgb-sample-transcode-vf.mkv':

Metadata:

encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj444p, 1600x1200 [SAR 1:1 DAR 4:3], q=-1--1, 1k tbn, 30 tbc (default)

Stream mapping:

Stream #0:0 -> #0:0 (utvideo -> libx264)

Press [q] to stop, ? for help
frame= 1 fps=0.0 q=24.0 Lsize= 100kB time=00:00:00.03 bitrate=24715.9kbits/s
video:99kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.575121%
[libx264 @ 027e8680] frame I:1 Avg QP:21.02 size:100640
[libx264 @ 027e8680] mb I I16..4: 3.0% 81.8% 15.2%
[libx264 @ 027e8680] 8x8 transform intra:81.8%
[libx264 @ 027e8680] coded y,u,v intra: 86.3% 19.3% 12.4%
[libx264 @ 027e8680] i16 v,h,dc,p: 10% 25% 24% 41%
[libx264 @ 027e8680] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 3% 5% 3% 13% 17% 11% 23% 10% 15%
[libx264 @ 027e8680] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 5% 7% 3% 11% 15% 10% 24% 9% 16%
[libx264 @ 027e8680] kb/s:24153.60

comment:15 by Carl Eugen Hoyos, 11 years ago

Do you test the final output file visually (with a media player) or with another method?

in reply to:  15 comment:16 by mzso, 11 years ago

Replying to cehoyos:

Do you test the final output file visually (with a media player) or with another method?

I tested visually by alternating between images. As it turns out there was an issue with the renderer too which is now fixed. So I re-did the comparisons. The difference is more subtle. But the ffmpeg output is definitely wrong.
Source and encode with x264 and avisynth(indistinguishable):
http://screenshotcomparison.com/comparison/64762

Source and encode with ffmpeg(color abnormalities):
http://screenshotcomparison.com/comparison/64764

Encode with ffmpeg using avisynth (way too dark):
http://abload.de/img/yuv-ffmpeg-crf0-avisyijra0.png
(No matter what I tried the output stayed like this)

Avisynth script:

FFVideoSource("e:\Videó Felvételek\motor2.avi")
ConvertToYV24(matrix="PC.709")

Command line 1:

E:\Videó Felvételek>x264 --input-range PC --fps 30 -force-cfr --preset slower --crf 0 --output-csp i444 --range PC --demuxer y4m -o x264_lossless.mkv "E:\Videó Felvételek\pc709.avs"
x264 [error]: invalid argument: deblock = orce-cfr

E:\Videó Felvételek>x264 --input-range PC --fps 30 --force-cfr --preset slower --crf 0 --output-csp i444 --range PC --colormatrix bt709 --colorprim bt709 -o x264_lossless.mkv "E:\Videó Felvételek\pc709.avs"
avs [info]: 1600x1200p 0:0 @ 3998/143 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
x264 [info]: profile High 4:4:4 Predictive, level 5.0, 4:4:4 8-bit
x264 [info]: frame I:7 Avg QP: 0.00 size:695602
x264 [info]: frame P:213 Avg QP: 0.00 size:395907
x264 [info]: mb I I16..4: 56.2% 23.3% 20.5%
x264 [info]: mb P I16..4: 6.9% 1.8% 1.6% P16..4: 29.5% 6.9% 13.5% 0.0% 0.2% skip:39.5%
x264 [info]: 8x8 transform intra:19.1% inter:36.7%
x264 [info]: coded y,u,v intra: 82.6% 66.4% 56.4% inter: 53.0% 52.7% 46.1%
x264 [info]: i16 v,h,dc,p: 36% 62% 2% 0%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 40% 29% 1% 2% 2% 1% 0% 0%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 34% 6% 4% 11% 7% 4% 3% 2%
x264 [info]: Weighted P-Frames: Y:23.5% UV:16.4%
x264 [info]: ref P L0: 69.7% 2.3% 13.4% 5.2% 3.7% 2.3% 1.6% 0.9% 0.9% 0.0%
x264 [info]: kb/s:97306.31

encoded 220 frames, 1.58 fps, 97306.93 kb/s

Command line 2:

E:\Videó Felvételek>ffmpeg -i "E:\Videó Felvételek\motor2.avi" -an -vcodec libx264 -preset slower -crf 0 -pix_fmt yuvj444p -x264opts "colorprim=bt709:transfer=bt709:colormatrix=bt709" yuv-ffmpeg.mkv
ffmpeg version N-60813-g44b22bb Copyright (c) 2000-2014 the FFmpeg developers

built on Feb 22 2014 03:11:45 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-l

ibgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora -
-enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib

libavutil 52. 65.100 / 52. 65.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 1.103 / 4. 1.103
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100

Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from 'E:\Vide+- Felv+ętelek\motor2.avi':

Duration: 00:00:07.87, start: 0.000000, bitrate: 291034 kb/s

Stream #0:0: Video: utvideo (ULRG / 0x47524C55), rgb24, 1600x1200, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s

[swscaler @ 03ff88a0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 040d06c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 040d06c0] profile High 4:4:4 Predictive, level 5.0, 4:4:4 8-bit
[libx264 @ 040d06c0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=8 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=9 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trelli
s=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 r
c=cqp mbtree=0 qp=0
Output #0, matroska, to 'yuv-ffmpeg.mkv':

Metadata:

encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj444p, 1600x1200, q=-1--1, 1k tbn, 30 tbc

Stream mapping:

Stream #0:0 -> #0:0 (utvideo -> libx264)

Press [q] to stop, ? for help
frame= 220 fps=1.6 q=-1.0 Lsize= 88422kB time=00:00:07.86 bitrate=92086.6kbits/s
video:88420kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.002805%
[libx264 @ 040d06c0] frame I:7 Avg QP: 0.00 size:705491
[libx264 @ 040d06c0] frame P:213 Avg QP: 0.00 size:401890
[libx264 @ 040d06c0] mb I I16..4: 54.2% 24.7% 21.1%
[libx264 @ 040d06c0] mb P I16..4: 6.8% 1.9% 1.6% P16..4: 29.3% 7.0% 13.5% 0.0% 0.2% skip:39.6%
[libx264 @ 040d06c0] 8x8 transform intra:20.1% inter:39.4%
[libx264 @ 040d06c0] coded y,u,v intra: 83.9% 67.4% 58.1% inter: 52.9% 52.6% 47.0%
[libx264 @ 040d06c0] i16 v,h,dc,p: 35% 63% 2% 0%
[libx264 @ 040d06c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 43% 27% 1% 2% 2% 1% 0% 0%
[libx264 @ 040d06c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 35% 6% 4% 11% 6% 4% 3% 2%
[libx264 @ 040d06c0] Weighted P-Frames: Y:23.5% UV:16.9%
[libx264 @ 040d06c0] ref P L0: 68.1% 2.6% 14.4% 5.3% 3.7% 2.4% 1.6% 0.9% 0.9% 0.0%
[libx264 @ 040d06c0] kb/s:92075.64

Command line 3:

E:\Videó Felvételek>ffmpeg -i "E:\Videó Felvételek\pc709.avs" -an -vcodec libx264 -preset slower -crf 0 -pix_fmt yuvj444p -x264opts "colorprim=bt709:transfer=bt709:colormatrix=bt709" yuv-ffmpeg-avs.mkv
ffmpeg version N-60813-g44b22bb Copyright (c) 2000-2014 the FFmpeg developers

built on Feb 22 2014 03:11:45 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-l

ibgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora -
-enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib

libavutil 52. 65.100 / 52. 65.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 1.103 / 4. 1.103
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100

Input #0, avisynth, from 'E:\Vide+- Felv+ętelek\pc709.avs':

Duration: 00:00:07.87, start: 0.000000, bitrate: 0 kb/s

Stream #0:0: Video: rawvideo (444P / 0x50343434), yuv444p, 1600x1200, 27.96 fps, 27.96 tbr, 27.96 tbn, 27.96 tbc

[swscaler @ 040288a0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 02a8c480] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 02a8c480] profile High 4:4:4 Predictive, level 5.0, 4:4:4 8-bit
[libx264 @ 02a8c480] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=8 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=9 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trelli
s=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 r
c=cqp mbtree=0 qp=0
Output #0, matroska, to 'yuv-ffmpeg-avs.mkv':

Metadata:

encoder : Lavf55.33.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuvj444p, 1600x1200, q=-1--1, 1k tbn, 27.96 tbc

Stream mapping:

Stream #0:0 -> #0:0 (rawvideo -> libx264)

Press [q] to stop, ? for help
frame= 220 fps=1.6 q=-1.0 Lsize= 81741kB time=00:00:07.86 bitrate=85096.7kbits/s
video:81739kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.003007%
[libx264 @ 02a8c480] frame I:6 Avg QP: 0.00 size:759384
[libx264 @ 02a8c480] frame P:214 Avg QP: 0.00 size:369831
[libx264 @ 02a8c480] mb I I16..4: 49.7% 31.6% 18.7%
[libx264 @ 02a8c480] mb P I16..4: 9.9% 2.3% 1.2% P16..4: 28.4% 5.3% 10.7% 0.0% 0.2% skip:41.9%
[libx264 @ 02a8c480] 8x8 transform intra:19.8% inter:38.6%
[libx264 @ 02a8c480] coded y,u,v intra: 35.7% 84.0% 67.9% inter: 31.8% 48.7% 43.5%
[libx264 @ 02a8c480] i16 v,h,dc,p: 76% 23% 1% 0%
[libx264 @ 02a8c480] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 22% 66% 0% 1% 1% 0% 0% 0%
[libx264 @ 02a8c480] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 36% 7% 3% 10% 7% 4% 2% 2%
[libx264 @ 02a8c480] Weighted P-Frames: Y:20.6% UV:15.4%
[libx264 @ 02a8c480] ref P L0: 68.4% 7.3% 9.9% 5.0% 3.3% 2.3% 1.6% 0.8% 1.3% 0.2%
[libx264 @ 02a8c480] kb/s:85094.27

by mzso, 11 years ago

Attachment: rgb-source.png added

RGB Source screenshot

by mzso, 11 years ago

Attachment: yuv-x264.png added

Screenshot of file encoded to yuv444 with x264 using avisynth with "crf 0"

by mzso, 11 years ago

Attachment: yuv-ffmpeg-crf0.png added

Screenshot of file encoded to yuv444 with ffmpeg/libx264 with "crf 0"

by mzso, 11 years ago

Screenshot of file encoded to yuv444 with ffmpeg/libx264 using avisynth input with "crf 0"

comment:17 by Roger Pack, 9 years ago

can the x264.exe executable convert it right?

comment:18 by Roger Pack, 9 years ago

Cc: rogerdpack@gmail.com added

comment:19 by Djfe, 7 years ago

This is still an issue.

ffmpeg -i .\logo-huffyuv.avi -c:v libx264 -an test.mp4

Is producing wrong colors.

The following command does the right thing, but why isn't is the default?:
ffmpeg -i .\logo-huffyuv.avi -pix_fmt yuv444p -vf scale=w=0:h=0:out_color_matrix=bt709 -x264opts colorprim=bt709:transfer=bt709:colormatrix=bt709 -c:v libx264 -an test.mp4

-pix_fmt yuv444p can be considered optional since FFmpeg guesses that by itself.
-x264opts colorprim=bt709:transfer=bt709:colormatrix=bt709 doesn't make the image look any different, but writes the correct colorspace information into the file, so that FFmpeg, Media Info and others can show it.

Without the x264 opts bt709 wouldn't be written in the following ffprobe output:

Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p(tv, bt709), 1920x1080, 12487 kb/s, 60 fps, 60 tbr, 500k tbn, 120 tbc (default)

To me this looks like ffmpeg is converting to bt601 by default, but all players interpret it like bt709 or something like that. (But I could be wrong, in any way, the colors are converted wrong atm.)

I extracted 6 frames from the original file (log-huffyuv.avi).
You can find it here:
https://drive.google.com/open?id=0B_dHhH1qeJ6DMU5ETG5rdFpDWGM
(I wanted to upload to upload.ffmpeg.org, but the ftp server seems to be down)

Output of the correct command on an avi file:

PS D:\some path> ffmpeg -i .\logo-huffyuv.avi -pix_fmt yuv444p -vf scale=w=0:h=0:out_color_matrix=bt709 -x264o
pts colorprim=bt709:transfer=bt709:colormatrix=bt709 -c:v libx264 -crf 0 -tune animation -preset placebo -profile:v high
444 -an logo-H264-test.mp4
ffmpeg version N-84814-gad7aff0 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 52.100 / 55. 52.100
  libavcodec     57. 86.103 / 57. 86.103
  libavformat    57. 68.100 / 57. 68.100
  libavdevice    57.  3.101 / 57.  3.101
  libavfilter     6. 78.101 /  6. 78.101
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, avi, from '.\logo-huffyuv.avi':
  Metadata:
    encoder         : Lavf57.71.100
  Duration: 00:00:04.48, start: 0.000000, bitrate: 776213 kb/s
    Stream #0:0: Video: huffyuv (HFYU / 0x55594648), bgr0, 1920x1080, 779087 kb/s, 60 fps, 60 tbr, 60 tbn, 60 tbc
File 'logo-H264-test.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (huffyuv (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0000000002037060] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0000000002037060] profile High 4:4:4 Predictive, level 5.1, 4:4:4 8-bit
[libx264 @ 0000000002037060] 264 - core 148 r2762 90a61ec - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 deblock=1:1:1 analyse=0x1:0x131 me=esa subme=9 psy=0 mixed_ref=1 me_range=24 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=12 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, mp4, to 'logo-H264-test.mp4':
  Metadata:
    encoder         : Lavf57.68.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 1920x1080, q=-1--1, 60 fps, 500k tbn, 60 tbc
    Metadata:
      encoder         : Lavc57.86.103 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=  269 fps= 26 q=-1.0 Lsize=    5815kB time=00:00:04.46 bitrate=10665.2kbits/s speed=0.437x
video:5813kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.033330%
[libx264 @ 0000000002037060] frame I:3     Avg QP: 0.00  size: 11825
[libx264 @ 0000000002037060] frame P:266   Avg QP: 0.00  size: 22243
[libx264 @ 0000000002037060] mb I  I16..4: 98.7%  0.0%  1.3%
[libx264 @ 0000000002037060] mb P  I16..4:  1.6%  0.0%  0.3%  P16..4:  4.4%  0.5%  0.5%  0.1%  0.1%    skip:92.5%
[libx264 @ 0000000002037060] 8x8 transform intra:0.0% inter:11.9%
[libx264 @ 0000000002037060] coded y,u,v intra: 22.1% 20.9% 20.3% inter: 2.9% 2.7% 2.7%
[libx264 @ 0000000002037060] i16 v,h,dc,p: 84% 14%  1%  1%
[libx264 @ 0000000002037060] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 18% 20%  7% 11%  7%  9%  5%  1%
[libx264 @ 0000000002037060] Weighted P-Frames: Y:13.2% UV:12.0%
[libx264 @ 0000000002037060] ref P L0: 60.1%  0.5%  7.9%  5.0%  4.2%  4.1%  3.6%  2.4%  2.0%  1.6%  1.8%  1.9%  1.6%  1.3%  1.2%  0.6%
[libx264 @ 0000000002037060] kb/s:10621.08

comment:20 by Djfe, 7 years ago

someone just informed me, that the file I uploaded doesn't contain any information about which color matrix it conforms to.
FFmpeg obviously guessed BT.709 since it's a full hd video.
But in fact it was BT.601

The only issue I can see here, is that FFmpeg has to guess the color matrix, but doesn't warn the user about that.

But the original issue might be a different one, so don't close this, yet ;)

comment:21 by Balling, 4 years ago

Why this is still open? As was said many times (#8937), ffplay does not support it properly (this is Won't FIX) and others need to have all of the following

ffmpeg -i incorrect_color_h264.mp4 -c copy -colorspace bt709 -color_primaries bt709 -color_trc bt709 out.mp4

and ALSO (relating to this ticket) -color_range pc (that is just metadata, of course) and -pix_fmt yuvj444p (or any other with "j" in ffmpeg -pix_fmts). Then if you do all correctly between the source file and destination file, it is good.

Last edited 4 years ago by Balling (previous) (diff)

comment:22 by Balling, 3 years ago

Resolution: invalid
Status: reopenedclosed

The obvious problem here is that swscale defaults to YCbCr limited range, so what should be done is -vf scale=out_range=pc and you may also want to specify -color_range pc to tag it. zscale defaults to source range.

yuvj4xxp are deprecated and should not be used.

Last edited 3 years ago by Balling (previous) (diff)

in reply to:  22 comment:23 by mirh, 3 years ago

Cc: mirh added

Replying to Djfe:

FFmpeg obviously guessed BT.709 since it's a full hd video.
But in fact it was BT.601

It's not really obvious, and tbh I'd really be curious to know wherever in the source code this would even happen.

Replying to Balling:

Why this is still open? As was said many times (#8937), ffplay does not support it properly (this is Won't FIX) and others need to have all of the following

Nobody mentioned ffplay anywhere in the thread. OP was even using MadVR, of all the renderers.
Also, even if they were and nobody wanted to care about a proper fix (which doesn't seem like the case for instance in #8862) you'd still at least have the pity to put some warning here or there.

Replying to Balling:

The obvious problem here is that swscale defaults to YCbCr limited range,

Not just that, but something in pc709.avs was changing the range and then forgetting about "signalling" it. Could this be related to #9374 perhaps?

Last edited 3 years ago by mirh (previous) (diff)

comment:24 by Balling, 3 years ago

It's not really obvious, and tbh I'd really be curious to know wherever in the source code this would even happen.

This is false. FFmpeg always defaults to 601 even for HD.

Nobody mentioned ffplay anywhere in the thread.

They are using it for testing, since it is part of ffmpeg.

the pity to put some warning here or there.

I did fix some of it (240M matrix, for example). But yeah. That would be nice.

Last edited 3 years ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.