我需要使用 python BitStream 从 HEVC 比特流中读取 POC 编号。目前我阅读了最终单元标题。有没有简单的方法来获得它?
我启用了跟踪 HM14.0,但 EncTrace.txt 不包括我的所有数据包。
任何想法?
编辑:我附上了我的python代码。这是我的比特流文件。
import re
import collections
import bitstring
from bitstring import BitStream, BitArray, ConstBitStream, pack
from bitstring import ByteStore, offsetcopy
import unicodedata
text_file = open("nal_Output.txt", "wb")
s = BitStream(filename='new.str')
#Find number of packets
pcks = list(s.findall('0x000001', bytealigned=True))
s.pos=0
num_of_pcks = len(pcks)
num_of_POC_pcks =0
for x in range(0, num_of_pcks):
s.pos =pcks[x]+24
#print x
if x < num_of_pcks-1:
no_p = pcks[x+1]-pcks[x]-24
else:
no_p = 0
forbidden_zero_bit = s.read('uint:1')
nal_unit_type = s.read('uint:6')
nuh_layer_id = s.read('uint:6')
nuh_temporal_id_plus1 = s.read('uint:3')
#nal unit type 39 is for SEI messages: one byte message
if int(nal_unit_type) >31 :
#print 'nal=39'
#size_of_pck = (no_p+24+8)/8
packet = 0
elif int(nal_unit_type) <32:
#print int(nal_unit_type)
num_of_POC_pcks = num_of_POC_pcks+1
size_of_pck = (no_p+24)/8
text_file.write("NumBytesInNALunit: {0}\n".format(str(size_of_pck)))
s.read(no_p)
print num_of_POC_pcks
text_file.close()