Template Class BSF

Class Documentation

template<MediaType media>
class BSF

Bitstream filter for packet manipulation.

BSF (Bitstream Filter) applies transformations to compressed packets without decoding/encoding. Common uses include format conversions, extracting parameters, or packet manipulation.

See https://ffmpeg.org/ffmpeg-bitstream-filters.html for available filters.

Template Parameters:

media – The media type (Audio, Video, or Image).

Public Functions

BSF(const Codec<media> &codec, const std::string &bsf)

Construct a bitstream filter.

Parameters:
  • codecCodec information for the filter.

  • bsf – Bitstream filter name or specification.

BSF(const BSF&) = delete

Deleted copy constructor.

BSF &operator=(const BSF&) = delete

Deleted copy assignment operator.

BSF(BSF&&) = delete

Deleted move constructor.

BSF &operator=(BSF&&) = delete

Deleted move assignment operator.

~BSF()

Destructor.

Codec<media> get_codec() const

Get the codec information after filtering.

Returns:

Codec information that may be modified by the filter.

std::optional<PacketsPtr<media>> filter(PacketsPtr<media> packets, bool flush = false)

Apply the bitstream filter to packets.

Parameters:
  • packetsPackets to filter.

  • flush – Whether to flush the filter.

Returns:

Filtered packets, or std::nullopt if no packets are available yet.

std::optional<PacketsPtr<media>> flush()

Flush the filter to retrieve any remaining packets.

Returns:

Remaining filtered packets, or std::nullopt if no packets are available.