2024-05-23 17:41:25 发布
网友
有一个很好的java-MINA。在
一旦我听说python也有类似的东西。但不能提醒。在
编辑: 更具体地说,我想有一个工具,可以帮助我创建一个编码的二进制流。在
编辑2: 我想在这里列出解决方案(感谢Scott提供相关主题) 列在我使用它的顺序上。
你试过bitstring模块了吗?(完全披露:我写的)。在
它旨在使二进制数据的构造和解析尽可能简单。看一下a few examples看看它是否符合您的需要。在
此片段对H.264视频文件进行了一些解析:
from bitstring import ConstBitStream s = ConstBitStream(filename='somefile.h264') profile_idc = s.read('uint:8') # Multiple reads in one go returns a list: constraint_flags = s.readlist('4*uint:1') reserved_zero_4bits = s.read('bin:4') level_idc = s.read('uint:8') seq_parameter_set_id = s.read('ue') if profile_idc in [100, 110, 122, 244, 44, 83, 86]: chroma_format_idc = s.read('ue') if chroma_format_idc == 3: separate_colour_plane_flag = s.read('uint:1') bit_depth_luma_minus8 = s.read('ue') bit_depth_chroma_minus8 = s.read('ue') ...
python在标准库中有pack/unpack,可以用来解释二进制数据并将它们映射到结构
见“11.3。使用二进制数据记录布局“herehttp://docs.python.org/tutorial/stdlib2.html
或者在这里http://docs.python.org/library/struct.html
你试过bitstring模块了吗?(完全披露:我写的)。在
它旨在使二进制数据的构造和解析尽可能简单。看一下a few examples看看它是否符合您的需要。在
此片段对H.264视频文件进行了一些解析:
python在标准库中有pack/unpack,可以用来解释二进制数据并将它们映射到结构
见“11.3。使用二进制数据记录布局“herehttp://docs.python.org/tutorial/stdlib2.html
或者在这里http://docs.python.org/library/struct.html
相关问题 更多 >
编程相关推荐