cdgriffith / FastFlix

FastFlix is a free GUI for H.264, HEVC and AV1 hardware and software encoding!
https://fastflix.org/
MIT License
1.17k stars 59 forks source link

BT.2020 Colorspace Not Maintained #582

Closed Ryushin closed 3 months ago

Ryushin commented 4 months ago

FastFlix Version: 5.7.2

Operating System: Win 10

Describe the bug I'm taking content that is BT.709 and converting it to BT.2020 (no HDR) using Handbrake. Then I pull that into Topaz AI and output a Prores file with the following color matrix:

Video
ID                                       : 1
Format                                   : ProRes
Format version                           : Version 0
Format profile                           : 422 LT
Codec ID                                 : apcs
Duration                                 : 2 h 26 min
Bit rate mode                            : Variable
Bit rate                                 : 276 Mb/s
Width                                    : 3 840 pixels
Height                                   : 1 608 pixels
Display aspect ratio                     : 2.40:1
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)                       : 1.866
Stream size                              : 282 GiB (100%)
Title                                    : Man on Fire (2004) HD
Writing library                          : Apple
Encoded date                             : 2024-07-14 17:29:08 UTC
Tagged date                              : 2024-07-14 17:29:08 UTC
Color primaries                          : BT.2020
Transfer characteristics                 : BT.2020 (10-bit)
Matrix coefficients                      : BT.2020 non-constant
matrix_coefficients_Original             : BT.709
Menus                                    : 2

I put the Prores file into Fastflix, and the output color matrix has changed:

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5@Main
Codec ID                                 : V_MPEGH/ISO/HEVC
Duration                                 : 2 h 26 min
Bit rate                                 : 11.0 Mb/s
Width                                    : 3 840 pixels
Height                                   : 1 608 pixels
Display aspect ratio                     : 2.40:1
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.074
Stream size                              : 11.2 GiB (98%)
Writing library                          : x265 3.5+98-753305aff:[Windows][GCC 12.2.0][64 bit] 10bit
Encoding settings                        : cpuid=1111039 / frame-threads=5 / numa-pools=32 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3840x1608 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=3 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-eob / no-eos / no-hrd / info / hash=0 / temporal-layers=0 / open-gop / min-keyint=23 / keyint=250 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=8 / scenecut=40 / no-hist-scenecut / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=0 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=1 / no-limit-modes / me=1 / subme=2 / merange=57 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=3 / selective-sao=4 / early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=0.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=17.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=9 / transfer=14 / colormatrix=9 / chromaloc=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / scenecut-aware-qp=0conformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0 / no-vbv-live-multi-pass / no-mcstf / no-sbrc
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : BT.2020 (10-bit)
Matrix coefficients                      : BT.709
matrix_coefficients_Original             : BT.2020 non-constant

Not sure why Fastflix is change the Matrix coefficients back to BT.709.

cdgriffith commented 3 months ago

Hi @Ryushin can you run ffprobe -v quiet -loglevel panic -print_format json -show_format -show_streams <videoname>

FastFlix will pass through what is in the "color_space": "bt2020nc" tag, so I'm curious what appears there in this case, and where the BT.709 is coming from.

Ryushin commented 3 months ago

Hi @Ryushin can you run ffprobe -v quiet -loglevel panic -print_format json -show_format -show_streams <videoname>

FastFlix will pass through what is in the "color_space": "bt2020nc" tag, so I'm curious what appears there in this case, and where the BT.709 is coming from.

Sure. Here is the complete output:

{
    "streams": [
        {
            "index": 0,
            "codec_name": "prores",
            "codec_long_name": "Apple ProRes (iCodec Pro)",
            "profile": "LT",
            "codec_type": "video",
            "codec_tag_string": "apcs",
            "codec_tag": "0x73637061",
            "width": 3840,
            "height": 1632,
            "coded_width": 3840,
            "coded_height": 1632,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 0,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "40:17",
            "pix_fmt": "yuv422p10le",
            "level": -99,
            "color_space": "bt2020nc",
            "color_transfer": "bt2020-10",
            "color_primaries": "bt2020",
            "field_order": "progressive",
            "refs": 1,
            "id": "0x1",
            "r_frame_rate": "24000/1001",
            "avg_frame_rate": "24000/1001",
            "time_base": "1/24000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 257329072,
            "duration": "10722.044667",
            "bit_rate": "285125140",
            "bits_per_raw_sample": "10",
            "nb_frames": "257072",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2024-06-04T10:51:58.000000Z",
                "handler_name": "VideoHandler",
                "vendor_id": "FFMP",
                "encoder": "Lavc60.37.100 prores_ks"
            }
        }
    ],
    "format": {
        "filename": Movie_Name_4K_Upscale_amq13.mov",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "10722.044667",
        "size": "382143624203",
        "bit_rate": "285127425",
        "probe_score": 100,
        "tags": {
            "major_brand": "qt  ",
            "minor_version": "512",
            "compatible_brands": "qt  ",
            "videoai": "Enhanced using amq-13. Changed resolution to 3840x1632",
            "title": "Movie Name HD",
            "creation_time": "2024-06-04T10:51:58.000000Z",
            "encoder": "Lavf60.20.100"
        }
    }
}

I did find that it was a new version of Topaz Video AI that added the new line "matrix_coefficients_Original : BT.709", while the older version didn't and Fastflix encoded BT.2020 perfectly fine. So I've reverted backup to the older version so I can get some projects done that I was working on.

cdgriffith commented 3 months ago

Got ya, is this output from the older version then that is working, or from the newer version?

This one looks as expected with:

            "color_space": "bt2020nc",
            "color_transfer": "bt2020-10",
            "color_primaries": "bt2020",

So I am assuming this one is working? Could I also see the other version?

Ryushin commented 3 months ago

Got ya, is this output from the older version then that is working, or from the newer version?

This one looks as expected with:

            "color_space": "bt2020nc",
            "color_transfer": "bt2020-10",
            "color_primaries": "bt2020",

So I am assuming this one is working? Could I also see the other version?

That wa the output from the newer version that wasn't working. The old version looks like this:

{
    "streams": [
        {
            "index": 0,
            "codec_name": "prores",
            "codec_long_name": "Apple ProRes (iCodec Pro)",
            "profile": "LT",
            "codec_type": "video",
            "codec_tag_string": "apcs",
            "codec_tag": "0x73637061",
            "width": 3840,
            "height": 1632,
            "coded_width": 3840,
            "coded_height": 1632,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 0,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "40:17",
            "pix_fmt": "yuv422p10le",
            "level": -99,
            "color_space": "bt2020nc",
            "color_transfer": "bt2020-10",
            "color_primaries": "bt2020",
            "field_order": "progressive",
            "refs": 1,
            "id": "0x1",
            "r_frame_rate": "24000/1001",
            "avg_frame_rate": "24000/1001",
            "time_base": "1/24000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 257329072,
            "duration": "10722.044667",
            "bit_rate": "285124679",
            "bits_per_raw_sample": "10",
            "nb_frames": "257072",
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "creation_time": "2024-06-04T10:51:58.000000Z",
                "handler_name": "VideoHandler",
                "vendor_id": "FFMP",
                "encoder": "Lavc60.27.101 prores_ks"
            }
        }
    ],
    "format": {
        "filename": "/netshares/movies/.zfs/snapshot/autosnap_2024-08-04_11:00:09_hourly/Incoming/AI_Upscale/Movie Name_HD_RB_Video_amq13.mov",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "10722.044667",
        "size": "382143005707",
        "bit_rate": "285126964",
        "probe_score": 100,
        "tags": {
            "major_brand": "qt  ",
            "minor_version": "512",
            "compatible_brands": "qt  ",
            "videoai": "Enhanced using amq-13. Changed resolution to 3840x1632",
            "title": "Movie Name HD",
            "creation_time": "2024-06-04T10:51:58.000000Z",
            "encoder": "Lavf60.14.101"
        }
    }
}
Ryushin commented 3 months ago

It wouldn't surprise me if it's actually something in the file itself caused by Topaz. Topaz Video AI is upgraded almost every month. Both files look correct that I can tell.

cdgriffith commented 3 months ago

Looking at my code and that source I am seeing yours has a dash, and in my valid color transfer list I have an underscore. I am adding the dash as well to see if that works in 5.8.0, beta: https://github.com/cdgriffith/FastFlix/releases/tag/5.8.0b0

If the one that had issues before still doesn't work in 5.8.0, please send me a screen shot of the advanced tab with what color options it shows as well as the x265-params inside the ffmpeg command from the raw output tab.

cdgriffith commented 3 months ago

Added in 5.8.0! https://github.com/cdgriffith/FastFlix/releases/tag/5.8.0