Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#11305 closed defect (invalid)

filter_complex/trim destroys HDR metadata

Reported by: zealot0630 Owned by:
Priority: important Component: avcodec
Version: 7.0 Keywords: hevc_nvenc hdr
Cc: MasterQuestionable Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by zealot0630)

Summary of the bug:
How to reproduce:

ffmpeg -y -hide_banner \
-i "2024-11-17 16-01-22.mkv" -filter_complex \
'[0:0]trim=start=00\\:00\\:00\\.000:end=00\\:00\\:03\\.000[ov0];
[0:1]atrim=start=00\\:00\\:00\\.000:end=00\\:00\\:03\\.000[oa0]' \
-map "[ov0]" -map "[oa0]" -map_metadata 0 \
-c:v:0 hevc_nvenc -c:a:0 aac \
-f mp4 "output.mp4"

ffmpeg outputs:

Input #0, matroska,webm, from '2024-11-17 16-01-22.mkv':
  Metadata:
    ENCODER         : Lavf61.1.100
  Duration: 00:24:43.47, start: 0.000000, bitrate: 70103 kb/s
  Stream #0:0: Video: hevc (Main 10), yuv420p10le(pc, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn
      Metadata:
        DURATION        : 00:24:43.467000000
      Side data:
        Content Light Level Metadata, MaxCLL=1000, MaxFALL=1000
        Mastering Display Metadata, has_primaries:1 has_luminance:1 r(0.6800,0.3200) g(0.2650,0.6900) b(0.1500 0.0600) wp(0.3127, 0.3290) min_luminance=0.000000, max_luminance=1000.000000
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
      Metadata:
        title           : Track1
        DURATION        : 00:24:43.413000000
Stream mapping:
  Stream #0:0 (hevc) -> trim:default
  Stream #0:1 (aac) -> atrim:default
  trim:default -> Stream #0:0 (hevc_nvenc)
  atrim:default -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf61.1.100
  Stream #0:0: Video: hevc (Main 10) (hev1 / 0x31766568), p010le(pc, bt2020nc/bt2020/smpte2084, progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 2000 kb/s, 60 fps, 15360 tbn
      Metadata:
        encoder         : Lavc61.3.100 hevc_nvenc
      Side data:
        cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
  Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
      Metadata:
        encoder         : Lavc61.3.100 aac
[out#0/mp4 @ 000002b8050fe6c0] video:149KiB audio:49KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 3.133152%
frame=  180 fps= 72 q=41.0 Lsize=     203KiB time=00:00:02.95 bitrate= 565.1kbits/s speed=1.18x
[aac @ 000002b805396a00] Qavg: 1094.995

Content Light Level Metadata and Mastering Display Metadata are lost after encoding.

Change History (4)

comment:1 by zealot0630, 3 months ago

Description: modified (diff)

comment:2 by zealot0630, 3 months ago

Just found it being fixed in 7.1, nice work !

Last edited 3 months ago by zealot0630 (previous) (diff)

comment:3 by Balling, 3 months ago

Resolution: invalid
Status: newclosed

comment:4 by MasterQuestionable, 3 months ago

Cc: MasterQuestionable added
Component: avfilteravcodec
Keywords: hevc_nvenc added; filter_complex removed

͏    I guess it's very likely bug in "hevc_nvenc" of handling the Side Data.
͏    And likely irrelevant of "filter_complex".

͏    Plus I doubt your filtergraph really works. (likely unintended escape usage)

Note: See TracTickets for help on using tickets.