jriker1
12th May 2024, 19:58
I haven't had this before but now have a MKV HEVC file that is dolbyvision data but no HDR data. It's IMAX content. Normally I re-encode videos with like this:
ffmpeg -i <source>.mkv -sn -an -f yuv4mpegpipe -strict -1 -pix_fmt yuv420p10le - | x265-10b - --input-depth 10 --output-depth 10 --y4m --preset slow --hdr10 --hdr10-opt --high-tier --repeat-headers --crf 19 --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50)" --max-cll "1000,401" --chromaloc 2 --no-sao --range limited --keyint 24 --colormatrix bt2020nc --colorprim bt2020 --transfer smpte2084 --dolby-vision-rpu rpu.bin --dolby-vision-profile 8.1 --vbv-bufsize 160000 --vbv-maxrate 160000 <output>.hevc
Since this doesn't have HDR content I tried removing hdr10 and hdr10-opt references as well as the master-display part. Seems specifically when I remove the master-display block it errors. So I do like:
ffmpeg -i <source>.mkv -sn -an -f yuv4mpegpipe -strict -1 -pix_fmt yuv420p10le - | x265-10b - --input-depth 10 --output-depth 10 --y4m --preset slow --high-tier --repeat-headers --crf 19 --chromaloc 0 --no-sao --range limited --keyint 24 --colormatrix bt2020nc --colorprim bt2020 --transfer smpte2084 --dolby-vision-rpu rpu.bin --dolby-vision-profile 8.1 --vbv-bufsize 160000 --vbv-maxrate 160000 <output>.hevc
It errors. If I put the master-display back in it starts encoding. Not sure relevant or not but I get
Chapter 21
x265 [error]: Dolby Vision profile - 8.1 requires Mastering display color volume information
Stream #0:0: Video: wrapped_avframe, yuv420p10le(pc, progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn (default)
Metadata:
BPS : 16537168
DURATION : 03:01:08.566000000
NUMBER_OF_FRAMES: 260585
x265 [error]: x265_encoder_open() failed for Enc,
NUMBER_OF_BYTES : 22466913562
_STATISTICS_WRITING_APP: mkvmerge v62.0.0.1 ('Apollo') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2021-11-11 18:06:09
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
encoder : Lavc61.3.100 wrapped_avframe
Side data:
DOVI configuration record: version: 1.0, profile: 5, level: 6, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 0
x265 [warning]: Dolby Vision RPU count is greater than frame count in x265
x265 [info]: VES muxing with Dolby Vision RPU file successful in x265
aborted at input frame 1, output frame 0 in x265
[vost#0:0/wrapped_avframe @ 0000021184071480] Error submitting a packet to the muxer: Broken pipex
Last message repeated 1 times
[out#0/yuv4mpegpipe @ 00000211840489c0] Error muxing a packet
[out#0/yuv4mpegpipe @ 00000211840489c0] Task finished with error code: -32 (Broken pipe)
[out#0/yuv4mpegpipe @ 00000211840489c0] Terminating thread with return code -32 (Broken pipe)
[out#0/yuv4mpegpipe @ 00000211840489c0] Error writing trailer: Broken pipe
[out#0/yuv4mpegpipe @ 00000211840489c0] Error closing file: Broken pipe
[out#0/yuv4mpegpipe @ 00000211840489c0] video:3KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 4847280.422078%
frame= 7 fps=4.9 q=-0.0 Lsize= 145800KiB time=00:00:00.62 bitrate=1909122.1kbits/s dup=2 drop=0 speed=0.44x
Conversion failed!
So I see it has a reference to requiring master-display dasta for dolbyvision but the source has none.
{
"frames": [
{
"media_type": "video",
"stream_index": 0,
"key_frame": 1,
"pts": 0,
"pts_time": "0.000000",
"best_effort_timestamp": 0,
"best_effort_timestamp_time": "0.000000",
"duration": 41,
"duration_time": "0.041000",
"pkt_pos": "9375",
"pkt_size": "6039",
"width": 3840,
"height": 2160,
"crop_top": 0,
"crop_bottom": 0,
"crop_left": 0,
"crop_right": 0,
"pix_fmt": "yuv420p10le",
"sample_aspect_ratio": "1:1",
"pict_type": "I",
"interlaced_frame": 0,
"top_field_first": 0,
"repeat_pict": 0,
"color_range": "pc",
"chroma_location": "left",
"side_data_list": [
{
"side_data_type": "Dolby Vision RPU Data"
},
{
"side_data_type": "Dolby Vision Metadata",
"rpu_type": 2,
"rpu_format": 18,
"vdr_rpu_profile": 0,
"vdr_rpu_level": 0,
"chroma_resampling_explicit_filter_flag": 0,
"coef_data_type": 0,
"coef_log2_denom": 23,
"vdr_rpu_normalized_idc": 1,
"bl_video_full_range_flag": 1,
"bl_bit_depth": 10,
"el_bit_depth": 10,
"vdr_bit_depth": 12,
"spatial_resampling_filter_flag": 0,
"el_spatial_resampling_filter_flag": 0,
"disable_residual_flag": 1,
"vdr_rpu_id": 0,
"mapping_color_space": 0,
"mapping_chroma_format_idc": 0,
"nlq_method_idc": -1,
"nlq_method_idc_name": "none",
"num_x_partitions": 1,
"num_y_partitions": 1,
"components": [
{
"pivots": "0 256 512 768 984",
"pieces": [
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 2,
"poly_coef": "7273 1035734 -1204442"
},
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 2,
"poly_coef": "56311 585767 -158576"
},
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 2,
"poly_coef": "102259 395554 39642"
},
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 2,
"poly_coef": "226020 61045 265788"
}
]
},
{
"pivots": "0 1023",
"pieces": [
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 1,
"poly_coef": "3683871 1114816"
}
]
},
{
"pivots": "0 1023",
"pieces": [
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 1,
"poly_coef": "3641776 1118367"
}
]
}
],
"dm_metadata_id": 0,
"scene_refresh_flag": 1,
"ycc_to_rgb_matrix": "8192/8192 799/8192 1681/8192 8192/8192 -933/8192 1091/8192 8192/8192 267/8192 -5545/8192",
"ycc_to_rgb_offset": "0/268435456 134217728/268435456 134217728/268435456",
"rgb_to_lms_matrix": "17081/16384 -349/16384 -349/16384 -349/16384 17081/16384 -349/16384 -349/16384 -349/16384 17081/16384",
"signal_eotf": 65535,
"signal_eotf_param0": 0,
"signal_eotf_param1": 0,
"signal_eotf_param2": 0,
"signal_bit_depth": 12,
"signal_color_space": 2,
"signal_chroma_format": 0,
"signal_full_range_flag": 1,
"source_min_pq": 62,
"source_max_pq": 3696,
"source_diagonal": 42
}
]
}
]
}
Thoughts?
ffmpeg -i <source>.mkv -sn -an -f yuv4mpegpipe -strict -1 -pix_fmt yuv420p10le - | x265-10b - --input-depth 10 --output-depth 10 --y4m --preset slow --hdr10 --hdr10-opt --high-tier --repeat-headers --crf 19 --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50)" --max-cll "1000,401" --chromaloc 2 --no-sao --range limited --keyint 24 --colormatrix bt2020nc --colorprim bt2020 --transfer smpte2084 --dolby-vision-rpu rpu.bin --dolby-vision-profile 8.1 --vbv-bufsize 160000 --vbv-maxrate 160000 <output>.hevc
Since this doesn't have HDR content I tried removing hdr10 and hdr10-opt references as well as the master-display part. Seems specifically when I remove the master-display block it errors. So I do like:
ffmpeg -i <source>.mkv -sn -an -f yuv4mpegpipe -strict -1 -pix_fmt yuv420p10le - | x265-10b - --input-depth 10 --output-depth 10 --y4m --preset slow --high-tier --repeat-headers --crf 19 --chromaloc 0 --no-sao --range limited --keyint 24 --colormatrix bt2020nc --colorprim bt2020 --transfer smpte2084 --dolby-vision-rpu rpu.bin --dolby-vision-profile 8.1 --vbv-bufsize 160000 --vbv-maxrate 160000 <output>.hevc
It errors. If I put the master-display back in it starts encoding. Not sure relevant or not but I get
Chapter 21
x265 [error]: Dolby Vision profile - 8.1 requires Mastering display color volume information
Stream #0:0: Video: wrapped_avframe, yuv420p10le(pc, progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn (default)
Metadata:
BPS : 16537168
DURATION : 03:01:08.566000000
NUMBER_OF_FRAMES: 260585
x265 [error]: x265_encoder_open() failed for Enc,
NUMBER_OF_BYTES : 22466913562
_STATISTICS_WRITING_APP: mkvmerge v62.0.0.1 ('Apollo') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2021-11-11 18:06:09
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
encoder : Lavc61.3.100 wrapped_avframe
Side data:
DOVI configuration record: version: 1.0, profile: 5, level: 6, rpu flag: 1, el flag: 0, bl flag: 1, compatibility id: 0
x265 [warning]: Dolby Vision RPU count is greater than frame count in x265
x265 [info]: VES muxing with Dolby Vision RPU file successful in x265
aborted at input frame 1, output frame 0 in x265
[vost#0:0/wrapped_avframe @ 0000021184071480] Error submitting a packet to the muxer: Broken pipex
Last message repeated 1 times
[out#0/yuv4mpegpipe @ 00000211840489c0] Error muxing a packet
[out#0/yuv4mpegpipe @ 00000211840489c0] Task finished with error code: -32 (Broken pipe)
[out#0/yuv4mpegpipe @ 00000211840489c0] Terminating thread with return code -32 (Broken pipe)
[out#0/yuv4mpegpipe @ 00000211840489c0] Error writing trailer: Broken pipe
[out#0/yuv4mpegpipe @ 00000211840489c0] Error closing file: Broken pipe
[out#0/yuv4mpegpipe @ 00000211840489c0] video:3KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 4847280.422078%
frame= 7 fps=4.9 q=-0.0 Lsize= 145800KiB time=00:00:00.62 bitrate=1909122.1kbits/s dup=2 drop=0 speed=0.44x
Conversion failed!
So I see it has a reference to requiring master-display dasta for dolbyvision but the source has none.
{
"frames": [
{
"media_type": "video",
"stream_index": 0,
"key_frame": 1,
"pts": 0,
"pts_time": "0.000000",
"best_effort_timestamp": 0,
"best_effort_timestamp_time": "0.000000",
"duration": 41,
"duration_time": "0.041000",
"pkt_pos": "9375",
"pkt_size": "6039",
"width": 3840,
"height": 2160,
"crop_top": 0,
"crop_bottom": 0,
"crop_left": 0,
"crop_right": 0,
"pix_fmt": "yuv420p10le",
"sample_aspect_ratio": "1:1",
"pict_type": "I",
"interlaced_frame": 0,
"top_field_first": 0,
"repeat_pict": 0,
"color_range": "pc",
"chroma_location": "left",
"side_data_list": [
{
"side_data_type": "Dolby Vision RPU Data"
},
{
"side_data_type": "Dolby Vision Metadata",
"rpu_type": 2,
"rpu_format": 18,
"vdr_rpu_profile": 0,
"vdr_rpu_level": 0,
"chroma_resampling_explicit_filter_flag": 0,
"coef_data_type": 0,
"coef_log2_denom": 23,
"vdr_rpu_normalized_idc": 1,
"bl_video_full_range_flag": 1,
"bl_bit_depth": 10,
"el_bit_depth": 10,
"vdr_bit_depth": 12,
"spatial_resampling_filter_flag": 0,
"el_spatial_resampling_filter_flag": 0,
"disable_residual_flag": 1,
"vdr_rpu_id": 0,
"mapping_color_space": 0,
"mapping_chroma_format_idc": 0,
"nlq_method_idc": -1,
"nlq_method_idc_name": "none",
"num_x_partitions": 1,
"num_y_partitions": 1,
"components": [
{
"pivots": "0 256 512 768 984",
"pieces": [
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 2,
"poly_coef": "7273 1035734 -1204442"
},
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 2,
"poly_coef": "56311 585767 -158576"
},
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 2,
"poly_coef": "102259 395554 39642"
},
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 2,
"poly_coef": "226020 61045 265788"
}
]
},
{
"pivots": "0 1023",
"pieces": [
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 1,
"poly_coef": "3683871 1114816"
}
]
},
{
"pivots": "0 1023",
"pieces": [
{
"mapping_idc": 0,
"mapping_idc_name": "polynomial",
"poly_order": 1,
"poly_coef": "3641776 1118367"
}
]
}
],
"dm_metadata_id": 0,
"scene_refresh_flag": 1,
"ycc_to_rgb_matrix": "8192/8192 799/8192 1681/8192 8192/8192 -933/8192 1091/8192 8192/8192 267/8192 -5545/8192",
"ycc_to_rgb_offset": "0/268435456 134217728/268435456 134217728/268435456",
"rgb_to_lms_matrix": "17081/16384 -349/16384 -349/16384 -349/16384 17081/16384 -349/16384 -349/16384 -349/16384 17081/16384",
"signal_eotf": 65535,
"signal_eotf_param0": 0,
"signal_eotf_param1": 0,
"signal_eotf_param2": 0,
"signal_bit_depth": 12,
"signal_color_space": 2,
"signal_chroma_format": 0,
"signal_full_range_flag": 1,
"source_min_pq": 62,
"source_max_pq": 3696,
"source_diagonal": 42
}
]
}
]
}
Thoughts?