Bitstream Filters

class av.bitstream.BitStreamFilterContext

Bases: object

Initializes a bitstream filter: a way to directly modify packet data.

Wraps AVBSFContext

Parameters:
  • in_stream (Stream, Codec, str, or None) – Defines the input codec for the bitfilter. A Stream copies the full input codec parameters, while a Codec or a codec-name str only pins the input codec, which is all a codec-specific filter (such as h264_mp4toannexb) needs to initialize.

  • out_stream (Stream) – A stream whose codec is overwritten using the output parameters from the bitfilter.

filter(Packet packet: Packet | None = None)

Processes a packet based on the filter_description set during initialization. Multiple packets may be created.

Type:

list[Packet]

flush()

Reset the internal state of the filter. Should be called e.g. when seeking. Can be used to make the filter usable again after draining it with EOF marker packet.