Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full range video not preserved, reduced to Limited range. Also missing colorspace tag. #93

Closed
Vrael0n opened this issue Aug 9, 2023 · 4 comments

Comments

@Vrael0n
Copy link

Vrael0n commented Aug 9, 2023

Encoding a Full range video outputs as limited range with shifted brightness.
diff

The range is changed to Limited (tv) and the bt2020nc colorspace tag is missing:

FFprobe Input: av1 (Main), yuv420p10le(pc, bt2020nc/bt2020/smpte2084), 3840x2160, SAR 1:1 DAR 16:9, 60 fps
FFprobe Output: av1 (Main), yuv420p10le(tv, unknown/bt2020/smpte2084, progressive), 3840x2160, 60 fps

NVEnc and QSVEnc don't have this behavior:

NVEncC64.exe --avhw --codec av1 --preset P7 --profile main --tier 1 --output-depth 10 --vbr 100000 --aq --aq-temporal --mv-precision Q-pel --lookahead 32 --output-buf 32 --colorrange auto --colormatrix auto --colorprim auto --transfer auto --chromaloc auto --max-cll copy --master-display copy --audio-copy -i "\10.0.0.202\NVMe\a\MW2 5s clip.mkv" -o "\10.0.0.202\NVMe\a\MW2 5s clip NV.mkv"
FFprobe: av1 (Main), yuv420p10le(pc, bt2020nc/bt2020/smpte2084, progressive), 3840x2160, 60 fps

QSVEncC64.exe --avhw --codec hevc --quality best --vbr 100000 --profile main10 --output-depth 10 --colorrange auto --colormatrix auto --colorprim auto --transfer auto --chromaloc auto --max-cll copy --master-display copy --audio-copy -i "\10.0.0.202\NVMe\a\MW2 5s clip.mkv" -o "\10.0.0.202\NVMe\a\MW2 5s clip QSV.mkv"
FFprobe: hevc (Main 10), yuv420p10le(pc, bt2020nc/bt2020/smpte2084, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 60 fps

Environment Info:
VCEEnc 8.16 (x64)
OS Windows 11 x64 (22621) [UTF-8]
CPU 12th Gen Intel Core i3-12100F [4.09GHz] (4C/8T)
GPU Radeon RX 7600 [ID:0x7480], driver version: 31.0.21023.2010

Command:
VCEEncC64.exe --avsw --codec av1 --preset slower --vbr 100000 --profile main --output-depth 10 --colorrange auto --colormatrix auto --colorprim auto --transfer auto --chromaloc auto --max-cll copy --master-display copy --audio-copy --log log.txt --log-level debug -i "C:\Users\SYS3\Desktop\Encode\MW2 5s clip.mkv" -o "C:\Users\SYS3\Desktop\Encode\MW2 5s clip VCE.mkv"

Source video:
https://drive.google.com/file/d/101RBaA92B9APdI8RD2WIUjv_ORnrVAzH/view?usp=sharing

Debug log:
log.txt

@Vrael0n Vrael0n changed the title Full range video not preserved, reduced to Limited range. Missing colorspace tag. Full range video not preserved, reduced to Limited range. Also missing colorspace tag. Aug 24, 2023
@DimkaTsv
Copy link

DimkaTsv commented Nov 5, 2023

Had you tried something like this?

%~dp0\VCEEncC64.exe -i %1 -o "%~n1_processed%~x1" --codec hevc --profile main --tier high --level 6.2 --preset slow --ref 4 --ltr 3 --vbr 7000 --max-bitrate 10000 --qp-max 36 --pa sc=high,ss=high,activity-type=yuv,lookahead=41,taq=1 --colorrange auto --colormatrix auto --colorprim auto --transfer auto --chromaloc auto --max-cll copy --master-display copy --atc-sei auto --dhdr10-info copy --audio-copy --chapter-copy
pause

Difference in these 2 tags, but probably should help?
--atc-sei auto --dhdr10-info copy

Tried myself, looks fine

General
Unique ID                      : 203196581601957968299048397205525679657 (0x98DE3CF4CE2CDD9D45AC56519746CE29)
Complete name                  : C:\Users\-----\Downloads\MW2 5s clip_processed.mkv
Format                         : Matroska
Format version                 : Version 4
File size                      : 11.9 MiB
Duration                       : 5 s 800 ms
Overall bit rate               : 17.3 Mb/s
Frame rate                     : 60.000 FPS
Writing application            : VCEEnc (x64) 8.16
Writing library                : Lavf59.37.100
ErrorDetectionType             : Per level 1

Video
ID                             : 1
Format                         : HEVC
Format/Info                    : High Efficiency Video Coding
Format profile                 : Main@L6.2@High
HDR format                     : SMPTE ST 2086, HDR10 compatible
Codec ID                       : V_MPEGH/ISO/HEVC
Duration                       : 5 s 800 ms
Bit rate                       : 16.6 Mb/s
Width                          : 3 840 pixels
Height                         : 2 160 pixels
Display aspect ratio           : 16:9
Frame rate mode                : Constant
Frame rate                     : 60.000 FPS
Color space                    : YUV
Chroma subsampling             : 4:2:0 (Type 2)
Bit depth                      : 8 bits
Bits/(Pixel*Frame)             : 0.033
Stream size                    : 11.5 MiB (96%)
Default                        : No
Forced                         : No
Color range                    : Limited
Color primaries                : BT.2020
Transfer characteristics       : PQ
Matrix coefficients            : BT.2020 non-constant
Mastering display color primar : Display P3
Mastering display luminance    : min: 0.0000 cd/m2, max: 1000 cd/m2
Maximum Content Light Level    : 1000 cd/m2
Maximum Frame-Average Light Le : 1000 cd/m2

Audio
ID                             : 2
Format                         : Opus
Codec ID                       : A_OPUS
Duration                       : 5 s 800 ms
Bit rate                       : 348 kb/s
Channel(s)                     : 2 channels
Channel layout                 : L R
Sampling rate                  : 48.0 kHz
Frame rate                     : 49.310 FPS (973 SPF)
Bit depth                      : 32 bits
Compression mode               : Lossy
Delay relative to video        : 80 ms
Stream size                    : 243 KiB (2%)
Default                        : No
Forced                         : No

Frankly speaking even without HDR10 specific preset it transfers HDR10 compatability for some reason.
Also fun fact... Your sample won't even decode with --avhw set on my RX 6750XT. Only default to --avsw.


UPD: My bad. I hadn't noticed that video actually got clamped to limited, as i focused on colorspace instead.

@DimkaTsv
Copy link

DimkaTsv commented Nov 6, 2023

Tried to simplify command to look more like yours. And also made it HEVC_10, not that it is necessary for HDR videos.

%~dp0\VCEEncC64.exe -i %1 -o "%~n1_processed%~x1" --codec hevc --profile main10 --tier high --level 6.2 --preset slow --ref 4 --ltr 3 --vbr 10000 --max-bitrate 15000 --qp-max 36 --pe --vbaq --colorrange auto --colormatrix auto --colorprim auto --transfer auto --chromaloc auto --max-cll copy --master-display copy --atc-sei auto --audio-copy --chapter-copy

VCEEncC output:

--------------------------------------------------------------------------------
MW2 5s clip_processed.mkv
--------------------------------------------------------------------------------
VCEEnc (x64) 8.16 (r1491) by rigaya, Jun 24 2023 02:32:23 (VC 1936/Win)
OS:            Windows 11 x64 (22621) [UTF-8]
CPU:           AMD Ryzen 7 5800X3D 8-Core Processor [4.48GHz] (8C/16T)
GPU:           AMD Radeon RX 6750 XT [31.0.22023.1014]
AMF:           Runtime 1.4.31 / SDK 1.4.29
Input Info:    avsw: av1(yv12(10bit))->nv12 [AVX2], 3840x2160, 60/1 fps
VPP            cspconv(nv12 -> yv12(16bit))
               cspconv(yv12(16bit) -> p010)
Output:        H.265/HEVC  main10 @ Level 6.2 (high tier)
               3840x2160p 0:0 60.000fps (60/1fps)
               avwriter: hevc, opus => matroska
Quality:       slow
VBR:           10000 kbps
Max bitrate:   15000 kbps
QP:            Min: 0:0, Max: 36:36
VBV Bufsize:   10000 kbps
Bframes:       0 frames
Pre Analysis:  off
Ref frames:    4 frames
LTR frames:    3 frames
Motion Est:    Q-pel
Slices:        1
GOP Len:       600 frames
VUI:              matrix:bt2020nc,colorprim:bt2020,transfer:smpte2084,range:full,chromaloc:topleft
MasteringDisp: G(0.265000 0.690000) B(0.150000 0.060000) R(0.680000 0.320000)
               WP(0.312700 0.329000) L(1000.000000 0.000000)
MaxCLL/MaxFALL:1000/1000
Others:        skipframe:on deblock vbaq pe

encoded 348 frames, 24.01 fps, 17633.28 kbps, 12.19 MB
encode time 0:00:14, CPU: 5.0%, GPU: 1.5%, VE: 54.5%
frame type IDR   1
frame type I     1,  avgQP  25.00,  total size   0.15 MB
frame type P   347,  avgQP  31.76,  total size  12.05 MB

C:\Users\-----\Downloads>pause
Для продолжения нажмите любую клавишу . . .

MPC-HC output on processed video:

General
Unique ID                      : 72835380451984259326656640868550648079 (0x36CB95827CCD2847B107C5E0082F210F)
Complete name                  : C:\Users\-----\Downloads\MW2 5s clip_processed.mkv
Format                         : Matroska
Format version                 : Version 4
File size                      : 12.4 MiB
Duration                       : 5 s 800 ms
Overall bit rate               : 18.0 Mb/s
Frame rate                     : 60.000 FPS
Writing application            : VCEEnc (x64) 8.16
Writing library                : Lavf59.37.100
ErrorDetectionType             : Per level 1

Video
ID                             : 1
Format                         : HEVC
Format/Info                    : High Efficiency Video Coding
Format profile                 : Main 10@L6.2@High
HDR format                     : SMPTE ST 2086, HDR10 compatible
Codec ID                       : V_MPEGH/ISO/HEVC
Duration                       : 5 s 800 ms
Bit rate                       : 17.3 Mb/s
Width                          : 3 840 pixels
Height                         : 2 160 pixels
Display aspect ratio           : 16:9
Frame rate mode                : Constant
Frame rate                     : 60.000 FPS
Color space                    : YUV
Chroma subsampling             : 4:2:0 (Type 2)
Bit depth                      : 10 bits
Bits/(Pixel*Frame)             : 0.035
Stream size                    : 11.9 MiB (96%)
Default                        : No
Forced                         : No
Color range                    : Limited
Color primaries                : BT.2020
Transfer characteristics       : PQ
Matrix coefficients            : BT.2020 non-constant
Mastering display color primar : Display P3
Mastering display luminance    : min: 0.0000 cd/m2, max: 1000 cd/m2
Maximum Content Light Level    : 1000 cd/m2
Maximum Frame-Average Light Le : 1000 cd/m2

Audio
ID                             : 2
Format                         : Opus
Codec ID                       : A_OPUS
Duration                       : 5 s 800 ms
Bit rate                       : 348 kb/s
Channel(s)                     : 2 channels
Channel layout                 : L R
Sampling rate                  : 48.0 kHz
Frame rate                     : 49.310 FPS (973 SPF)
Bit depth                      : 32 bits
Compression mode               : Lossy
Delay relative to video        : 80 ms
Stream size                    : 243 KiB (2%)
Default                        : No
Forced                         : No

ffprobe output:

Input #0, matroska,webm, from 'C:\Users\-----\Downloads\MW2 5s clip_processed.mkv':
  Metadata:
    ENCODER         : Lavf59.37.100
  Duration: 00:00:05.80, start: 0.000000, bitrate: 17985 kb/s
  Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn
    Metadata:
      DURATION        : 00:00:05.800000000
  Stream #0:1: Audio: opus, 48000 Hz, stereo, fltp
    Metadata:
      BPS             : 348377
      NUMBER_OF_FRAMES: 286
      NUMBER_OF_BYTES : 249090
      _STATISTICS_WRITING_APP: mkvmerge v78.0 ('Running') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2023-08-08 14:47:44
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:00:05.800000000

So, by any means, everything looks completely normal and without errors.


UPD: My bad. I hadn't noticed that video actually got clamped to limited, as i focused on colorspace instead.

@rigaya
Copy link
Owner

rigaya commented Nov 8, 2023

I have tried adding colormatrix and fullrange flag also for AV1 encoding in VCEEnc 8.17.

@Vrael0n
Copy link
Author

Vrael0n commented Nov 8, 2023

Confirmed fixed in 8.17, range and matrix are now matching source video.

@Vrael0n Vrael0n closed this as completed Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants