VideoDemuxer Class Reference

VideoDemuxer Class Reference#

3 min read time

Applies to Linux

rocDecode: VideoDemuxer Class Reference

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

#include <video_demuxer.h>

Data Structures

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

Public Member Functions

AVCodecID GetCodecID ()
 Returns the FFmpeg codec ID of the demultiplexed video stream.
 
 VideoDemuxer (const char *input_file_path)
 Constructs a demuxer that reads the video stream from a file path. More...
 
 VideoDemuxer (StreamProvider *stream_provider)
 Constructs a demuxer that reads the video stream from a custom StreamProvider. More...
 
 ~VideoDemuxer ()
 Destroys the demuxer and releases the underlying FFmpeg resources.
 
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. More...
 
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. More...
 
const uint32_t GetWidth () const
 Returns the width, in pixels, of the demultiplexed video stream.
 
const uint32_t GetHeight () const
 Returns the height, in pixels, of the demultiplexed video stream.
 
const uint32_t GetChromaHeight () const
 Returns the chroma plane height, in pixels, for the stream's chroma format.
 
const uint32_t GetBitDepth () const
 Returns the bit depth of the demultiplexed video stream.
 
const uint32_t GetBytePerPixel () const
 Returns the number of bytes per pixel for the stream's chroma format.
 
const uint32_t GetBitRate () const
 Returns the bit rate, in bits per second, reported by the input stream.
 
const double GetFrameRate () const
 Returns the real (base) frame rate of the demultiplexed video stream.
 
bool IsVFR () const
 Returns true if the stream is variable frame rate (its real and average frame rates differ).
 
int64_t TsFromTime (double ts_sec)
 Converts a timestamp in seconds to the stream's internal time base units. More...
 
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. More...
 

Detailed Description

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

Constructor & Destructor Documentation

◆ VideoDemuxer() [1/2]

VideoDemuxer::VideoDemuxer ( const char *  input_file_path)
inline

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

Parameters
input_file_pathPath to the input video file.

◆ VideoDemuxer() [2/2]

VideoDemuxer::VideoDemuxer ( StreamProvider stream_provider)
inline

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

Parameters
stream_providerThe stream provider to demux from.

Member Function Documentation

◆ Demux()

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

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

Parameters
videoSet to a pointer to the extracted packet data.
video_sizeSet to the size, in bytes, of the extracted packet.
ptsOptional; 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.

◆ Seek()

bool VideoDemuxer::Seek ( VideoSeekContext seek_ctx,
uint8_t **  pp_video,
int *  video_size 
)
inline

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

Parameters
seek_ctxDescribes 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_videoSet to a pointer to the demuxed packet data at the sought frame.
video_sizeSet to the size, in bytes, of the demuxed packet.
Returns
true on success.

◆ TsFromFrameNumber()

int64_t VideoDemuxer::TsFromFrameNumber ( int64_t  frame_num)
inline

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

Parameters
frame_numFrame number.
Returns
The equivalent timestamp in the stream's time base units.

◆ TsFromTime()

int64_t VideoDemuxer::TsFromTime ( double  ts_sec)
inline

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

Parameters
ts_secTimestamp, in seconds.
Returns
The equivalent timestamp in the stream's time base units.

The documentation for this class was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocdecode/checkouts/develop/projects/rocdecode/utils/video_demuxer.h