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
https://ffmpeg.org/ffmpeg-bitstream-filters.html: The list of available bitstream filters and their usage.
NvDecDecoder
: NVDEC decoding requires the input video packets to be Annex B.apply_bsf()
: Applies bitstream filtering to the packet as one-off operation.
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: 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.