spdl.io.BSF

class BSF(codec: TCodec, bsf: str)[source]

Apply bitstream filtering on packets object.

The primal usecase of BFS in SPDL is to convert the H264 video packets to Annex B for video decoding.

See also

Example

src = “foo.mp4” demuxer = spdl.io.Demuxer(src) # Note: When demuxing in streaming fashion, the packets does not have codec information. # To initialize BSF, the codec must be retrieved from Demuxer class. bsf = spdl.io.BSF(demuxer.video_codec)

for packets in demuxer.streaming_demux_video(…):

packets = bsf.filter(packets)

packets = bsf.flush() …

Parameters:

codec – The input codec.

Methods

filter(packets[, flush])

Apply the filter to the input packets

flush()

filter(packets: TPackets, flush: bool = False) TPackets | None[source]

Apply the filter to the input packets

Parameters:
  • packets – The input packets.

  • flush – If True, then notify the filter that this is the end of the stream and let it flush the internally buffered packets.

Returns:

Filtered packet object or None if the internal filtering mechanism holds the packets and does not return any packet.

flush() TPackets | None[source]