VideoDemuxer API reference#

2026-09-23

3 min read time

Applies to Linux

The VideoDemuxer utility class is exposed in utils/video_demuxer.h.

class VideoDemuxer#
#include <video_demuxer.h>

Demultiplexes a video stream into elementary packets that are passed to the rocDecode parser.

Public Functions

inline AVCodecID GetCodecID()#

Returns the FFmpeg codec ID of the demultiplexed video stream.

inline VideoDemuxer(const char *input_file_path)#

Constructs a demuxer that reads the video stream from a file path.

Parameters:

input_file_path – Path to the input video file.

inline VideoDemuxer(StreamProvider *stream_provider)#

Constructs a demuxer that reads the video stream from a custom StreamProvider.

Parameters:

stream_provider – The stream provider to demux from.

inline ~VideoDemuxer()#

Destroys the demuxer and releases the underlying FFmpeg resources.

inline bool Demux(uint8_t **video, int *video_size, int64_t *pts = nullptr)#

Extracts the next elementary video packet from the stream, starting at the beginning.

Parameters:
  • video – Set to a pointer to the extracted packet data.

  • video_size – Set to the size, in bytes, of the extracted packet.

  • pts – Optional; if non-null, set to the packet’s presentation timestamp.

Returns:

true if a packet was extracted, false at end of stream or on error.

inline bool Seek(VideoSeekContext &seek_ctx, uint8_t **pp_video, int *video_size)#

Seeks to a frame identified by seek_ctx and demuxes it, instead of demuxing sequentially.

Parameters:
  • seek_ctx – Describes the frame to seek to (by frame number or timestamp) and the seek mode; also receives the presentation timestamp, duration, and decoded frame count for the found frame.

  • pp_video – Set to a pointer to the demuxed packet data at the sought frame.

  • video_size – Set to the size, in bytes, of the demuxed packet.

Returns:

true on success.

inline const uint32_t GetWidth() const#

Returns the width, in pixels, of the demultiplexed video stream.

inline const uint32_t GetHeight() const#

Returns the height, in pixels, of the demultiplexed video stream.

inline const uint32_t GetChromaHeight() const#

Returns the chroma plane height, in pixels, for the stream’s chroma format.

inline const uint32_t GetBitDepth() const#

Returns the bit depth of the demultiplexed video stream.

inline const uint32_t GetBytePerPixel() const#

Returns the number of bytes per pixel for the stream’s chroma format.

inline const uint32_t GetBitRate() const#

Returns the bit rate, in bits per second, reported by the input stream.

inline const double GetFrameRate() const#

Returns the real (base) frame rate of the demultiplexed video stream.

inline bool IsVFR() const#

Returns true if the stream is variable frame rate (its real and average frame rates differ).

inline int64_t TsFromTime(double ts_sec)#

Converts a timestamp in seconds to the stream’s internal time base units.

Parameters:

ts_sec – Timestamp, in seconds.

Returns:

The equivalent timestamp in the stream’s time base units.

inline int64_t TsFromFrameNumber(int64_t frame_num)#

Converts a frame number to the stream’s internal time base units, using the stream’s frame rate.

Parameters:

frame_num – Frame number.

Returns:

The equivalent timestamp in the stream’s time base units.

class StreamProvider#
#include <video_demuxer.h>

Abstract interface that feeds a custom stream of bytes to the demuxer.

Implement this to demux from a source other than a file path, such as an in-memory buffer or a network stream.

Public Functions

virtual int GetData(uint8_t *buf, int buf_size) = 0#

Reads up to buf_size bytes of stream data into buf.

Returns:

The number of bytes read, or a negative value at end of stream.

virtual size_t GetBufferSize() = 0#

Returns the preferred buffer size to use for GetData reads.