Is there some kind of common binary codec codec library for python?

Good for java - MINA .

As soon as I heard that there is something similar for python. But I can’t recall.

EDIT: To be more specific, I would like to have a tool that helps me create an encoding for some binary stream.

EDIT2: I would like to list the solutions here (thanks to Scott for related topics) Listed in order, I would use it.

+3
source share
2

bitstring? ( : ).

. , , - .

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')
        ...
+4

Source: https://habr.com/ru/post/1760270/


All Articles