最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - understanding HEVC NAL SEI termination and byte alignment parsing with ffmpeg - Stack Overflow

programmeradmin0浏览0评论

The NAL SEI timecode message I am currently writing to file is 00 00 01 4E 01 88 06 XX XX XX XX XX 10 80 (The termination portion being 10 80, payloadSize set to 0x06 and the XX bytes being an encoding of the frames/seconds/minutes/hours).

My goal is to read the timecode with ffmpeg -i video.h265 -c:v copy -bsf:v trace_headers -f null - and ffprobe -show_frames video.mov with no errors.

The 3 left most 0 bits of the final 0x10 byte are the conclusion of the time_offset_length (Equal to 0) data. Following this, I am intending to have a rbsp_stop_one_bit followed by four rbsp_alignment_zero_bits to result in byte alignment.

With this termination configuration (No trailing 0x80 byte and the payloadSize set to 0x05 like 00 00 01 4E 01 88 05 XX XX XX XX XX 10), ffmpeg reports Invalid value at time_offset_length[i]: bitstream ended.

With the addition of the trailing 0x80 byte and changing the payloadSize to 0x06 to match, ffmpeg does not throw a warning but instead indicates there are extra, unused bits:

[trace_headers @ 0000015aff793a80] Prefix Supplemental Enhancement Information
[trace_headers @ 0000015aff793a80] 0           forbidden_zero_bit                                          0 = 0
[trace_headers @ 0000015aff793a80] 1           nal_unit_type                                          100111 = 39
[trace_headers @ 0000015aff793a80] 7           nuh_layer_id                                           000000 = 0
[trace_headers @ 0000015aff793a80] 13          nuh_temporal_id_plus1                                     001 = 1
[trace_headers @ 0000015aff793a80] 16          last_payload_type_byte                               10001000 = 136
[trace_headers @ 0000015aff793a80] 24          last_payload_size_byte                               00000110 = 6
[trace_headers @ 0000015aff793a80] Time Code
[trace_headers @ 0000015aff793a80] 32          num_clock_ts                                               01 = 1
[trace_headers @ 0000015aff793a80] 34          clock_timestamp_flag[0]                                     1 = 1
[trace_headers @ 0000015aff793a80] 35          units_field_based_flag[0]                                   0 = 0
[trace_headers @ 0000015aff793a80] 36          counting_type[0]                                        00000 = 0
[trace_headers @ 0000015aff793a80] 41          full_timestamp_flag[0]                                      1 = 1
[trace_headers @ 0000015aff793a80] 42          discontinuity_flag[0]                                       0 = 0
[trace_headers @ 0000015aff793a80] 43          cnt_dropped_flag[0]                                         0 = 0
[trace_headers @ 0000015aff793a80] 44          n_frames[0]                                         000110101 = 53
[trace_headers @ 0000015aff793a80] 53          seconds_value[0]                                       010010 = 18
[trace_headers @ 0000015aff793a80] 59          minutes_value[0]                                       010100 = 20
[trace_headers @ 0000015aff793a80] 65          hours_value[0]                                          01010 = 10
[trace_headers @ 0000015aff793a80] 70          time_offset_length[0]                                   00000 = 0
[trace_headers @ 0000015aff793a80] 75          bit_equal_to_one                                            1 = 1
[trace_headers @ 0000015aff793a80] 76          bit_equal_to_zero                                           0 = 0
[trace_headers @ 0000015aff793a80] 77          bit_equal_to_zero                                           0 = 0
[trace_headers @ 0000015aff793a80] 78          bit_equal_to_zero                                           0 = 0
[trace_headers @ 0000015aff793a80] 79          bit_equal_to_zero                                           0 = 0
[trace_headers @ 0000015aff793a80] 80          rbsp_stop_one_bit                                           1 = 1
[trace_headers @ 0000015aff793a80] 81          rbsp_alignment_zero_bit                                     0 = 0
[trace_headers @ 0000015aff793a80] 82          rbsp_alignment_zero_bit                                     0 = 0
[trace_headers @ 0000015aff793a80] 83          rbsp_alignment_zero_bit                                     0 = 0
[trace_headers @ 0000015aff793a80] 84          rbsp_alignment_zero_bit                                     0 = 0
[trace_headers @ 0000015aff793a80] 85          rbsp_alignment_zero_bit                                     0 = 0
[trace_headers @ 0000015aff793a80] 86          rbsp_alignment_zero_bit                                     0 = 0
[trace_headers @ 0000015aff793a80] 87          rbsp_alignment_zero_bit                                     0 = 0

Without the bit_equal_to_one, ffmpeg gives a generic error Failed to read unit 0 (type 39) after reading the time_offset_length correctly.

What is the meaning of bit_equal_to_one and bit_equal_to_zero in this context and is this the intended SEI termination method? Why are those bits not parsed as the alignment bits?

发布评论

评论列表(0)

  1. 暂无评论