The blo Library
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
blo::AVFileIn Class Reference

Audio/Video file input using FFmpeg. More...

#include <AVFileIn.h>

Public Types

enum class  SeekPosition { atOrAfter , atOrBefore }
 
enum class  SeekFrame { key , any }
 

Public Member Functions

 AVFileIn ()
 Default constructor.
 
 AVFileIn (const char *filename)
 Constructs AV file input.
 
 AVFileIn (const char *filename, const AVInputFormat *pInputFormat)
 Constructs AV file input.
 
 AVFileIn (const char *deviceName, const char *formatName, double frameRate)
 Constructs video device input.
 
 AVFileIn (const char *deviceName, const char *formatName, double frameRate, int width, int height)
 Constructs video device input.
 
 AVFileIn (const AVFileIn &rhs)=delete
 Copy constructor.
 
virtual ~AVFileIn ()
 Destructor.
 
AVFileIn & operator= (const AVFileIn &rhs)=delete
 
void open (const char *filename)
 Opens input file.
 
void open (const char *filename, const AVInputFormat *pInputFormat)
 Opens input file.
 
void open (const char *deviceName, const char *formatName, double frameRate)
 Opens input video device.
 
void open (const char *deviceName, const char *formatName, double frameRate, int width, int height)
 Opens input video device.
 
bool isOpen () const
 Tests if the file is open.
 
void close ()
 Closes file.
 
double startTime () const
 File start time.
 
double duration () const
 File duration.
 
int bitrate () const
 File bitrate.
 
int numStreams () const
 Number of streams in file.
 
int defaultStreamNumber ()
 Default stream number in file.
 
int numStreams (AVMediaType mediatype) const
 Number of streams of specified media in file.
 
void streamNumbers (AVMediaType mediatype, int *pDstStreamNumbers) const
 Stream numbers of specified media in file.
 
int numAudioStreams () const
 Number of audio streams in file.
 
void audioStreamNumbers (int *pDstStreamNumbers) const
 Stream numbers of audio streams in file.
 
int numVideoStreams () const
 Number of video streams in file.
 
void videoStreamNumbers (int *pDstStreamNumbers) const
 Stream numbers of video streams in file.
 
int numDataStreams () const
 Number of data streams in file.
 
void dataStreamNumbers (int *pDstStreamNumbers) const
 Stream numbers of data streams in file.
 
int numSubtitleStreams () const
 Number of subtitle streams in file.
 
void subtitleStreamNumbers (int *pDstStreamNumbers) const
 Stream numbers of subtitle streams in file.
 
int numAttachmentStreams () const
 Number of attachment streams in file.
 
void attachmentStreamNumbers (int *pDstStreamNumbers) const
 Stream numbers of attachment streams in file.
 
int numUnknownStreams () const
 Number of unknown streams in file.
 
void unknownStreamNumbers (int *pDstStreamNumbers) const
 Stream numbers of unknown streams in file.
 
double startTime (int streamNumber) const
 Stream start time.
 
double duration (int streamNumber) const
 Stream duration.
 
int bitrate (int streamNumber) const
 Stream bitrate.
 
bool hasCodec (int streamNumber) const
 Tests if stream codec is available.
 
AVMediaType mediaType (int streamNumber) const
 Media type of stream.
 
AVCodecID codecID (int streamNumber) const
 Codec ID of stream.
 
unsigned int codecTag (int streamNumber) const
 Codec tag of stream.
 
bool isAudio (int streamNumber) const
 Tests if stream is audio stream.
 
bool isVideo (int streamNumber) const
 Tests if stream is video stream.
 
bool isData (int streamNumber) const
 Tests if stream is data stream.
 
bool isSubtitle (int streamNumber) const
 Tests if stream is subtitle stream.
 
bool isAttachment (int streamNumber) const
 Tests if stream is attachment stream.
 
bool isUnknown (int streamNumber) const
 Tests if stream is unknown stream.
 
int sampleRate (int streamNumber) const
 Audio stream sample rate.
 
AVSampleFormat sampleFormat (int streamNumber) const
 Audio stream sample format.
 
uint64_t channelLayout (int streamNumber) const
 Audio stream channel layout.
 
int channels (int streamNumber) const
 Audio stream number of channels.
 
int frameSize (int streamNumber) const
 Audio stream frame size.
 
double avgFrameRate (int streamNumber) const
 Video stream average frame rate.
 
double frameRate (int streamNumber) const
 Video stream frame rate.
 
AVPixelFormat pixelFormat (int streamNumber) const
 Video stream pixel format.
 
int width (int streamNumber) const
 Video stream frame width.
 
int height (int streamNumber) const
 Video stream frame height.
 
double storageAspectRatio (int streamNumber) const
 Video stream frame storage aspect ratio.
 
double pixelAspectRatio (int streamNumber) const
 Video stream frame pixel aspect ratio.
 
double displayAspectRatio (int streamNumber) const
 Video stream frame display aspect ratio.
 
bool hasAlphaChannel (int streamNumber) const
 Absence or presence of alpha channel in video stream frame.
 
void seek (double timeStamp, SeekPosition seekPosition, SeekFrame seekFrame)
 Seeks to the frame at the specified time stamp.
 
void seek (int streamNumber, double timeStamp, SeekPosition seekPosition, SeekFrame seekFrame)
 Seeks to the frame at the specified time stamp.
 
bool readNextFrame (int &streamNumber, double *p_pts=nullptr, double *p_dts=nullptr, bool *pIsKeyFrame=nullptr)
 Reads the next frame.
 
bool readThroughNextFrameInStream (int streamNumber, double *p_pts=nullptr, double *p_dts=nullptr, bool *pIsKeyFrame=nullptr)
 Reads the file through the next frame in the specified stream.
 
bool decodeAudioFrame (int &frameSize, bool &isLastFrameInPacket, double *p_pts=nullptr)
 Decodes the current audio frame.
 
template<typename T >
bool convertAudioFrame (uint64_t dstChannelLayout, T *pDst, int dstLen)
 Converts the current decoded audio frame.
 
template<typename T >
bool convertAudioFrame_Mono (T *pDst, int dstLen)
 Converts the current decoded audio frame to mono.
 
template<typename T >
bool convertAudioFrame_Stereo (T *pDst, int dstLen)
 Converts the current decoded audio frame to stereo.
 
bool decodeVideoFrame (int &width, int &height, double *p_pts=nullptr, int *pFrameNum=nullptr, InterlacedFrame *pInterlacedFrame=nullptr, bool *pIsKeyFrame=nullptr)
 Decodes the current video frame.
 
bool convertVideoFrame (AVPixelFormat dstPixelFormat, uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame.
 
bool convertVideoFrame_Y_C1 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to Y.
 
bool convertVideoFrame_RGB_C3 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to RGB.
 
bool convertVideoFrame_BGR_C3 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to BGR.
 
bool convertVideoFrame_RGB_C4 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to RGB.
 
bool convertVideoFrame_BGR_C4 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to BGR.
 
bool convertVideoFrame_RGBA_C4 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to RGBA.
 
bool convertVideoFrame_BGRA_C4 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to BGRA.
 
bool convertVideoFrame_ARGB_C4 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to ARGB.
 
bool convertVideoFrame_ABGR_C4 (uint8_t *pDst, int dstStep, int dstWidth, int dstHeight)
 Converts the current decoded video frame to ABGR.
 

Protected Member Functions

virtual void onReadFrame (int streamNumber)
 Called on successful frame read.
 

Detailed Description

Audio/Video file input using FFmpeg.

Member Enumeration Documentation

◆ SeekFrame

enum class blo::AVFileIn::SeekFrame
strong
Enumerator
key 

Seek to a key frame.

any 

Seek to any frame (key frames and non-key frames).

◆ SeekPosition

enum class blo::AVFileIn::SeekPosition
strong
Enumerator
atOrAfter 

Seek to position at or after.

atOrBefore 

Seek to position at or before.

Constructor & Destructor Documentation

◆ AVFileIn() [1/6]

blo::AVFileIn::AVFileIn ( )

Default constructor.

◆ AVFileIn() [2/6]

blo::AVFileIn::AVFileIn ( const char *  filename)
explicit

Constructs AV file input.

Parameters
filenameFilename string.

◆ AVFileIn() [3/6]

blo::AVFileIn::AVFileIn ( const char *  filename,
const AVInputFormat *  pInputFormat 
)

Constructs AV file input.

Parameters
filenameFilename string.
pInputFormatPointer to input format to use (force), or nullptr to use default.

◆ AVFileIn() [4/6]

blo::AVFileIn::AVFileIn ( const char *  deviceName,
const char *  formatName,
double  frameRate 
)

Constructs video device input.

Note
Under Windows, formatName is "vfwcap" and deviceName is the device number as a string (e.g., "0"), or formatName is "dshow" and deviceName is "type=name", where type is audio or video and name is the device name (e.g., "video=Logitech HD Webcam C615"). Under Linux, deviceName is "/dev/videoN", where N is the device number, and formatName is "video4linux" or "video4linux2".
Parameters
deviceNameDevice name string.
formatNameFormat name string.
frameRateFrame rate in frames/s.

◆ AVFileIn() [5/6]

blo::AVFileIn::AVFileIn ( const char *  deviceName,
const char *  formatName,
double  frameRate,
int  width,
int  height 
)

Constructs video device input.

Note
Under Windows, formatName is "vfwcap" and deviceName is the device number as a string (e.g., "0"), or formatName is "dshow" and deviceName is "type=name", where type is audio or video and name is the device name (e.g., "video=Logitech HD Webcam C615"). Under Linux, deviceName is "/dev/videoN", where N is the device number, and formatName is "video4linux" or "video4linux2".
Parameters
deviceNameDevice name string.
formatNameFormat name string.
frameRateFrame rate in frames/s.
widthThe width of the frames.
heightThe height of the frames.

◆ AVFileIn() [6/6]

blo::AVFileIn::AVFileIn ( const AVFileIn &  rhs)
delete

Copy constructor.

◆ ~AVFileIn()

virtual blo::AVFileIn::~AVFileIn ( )
virtual

Destructor.

Member Function Documentation

◆ attachmentStreamNumbers()

void blo::AVFileIn::attachmentStreamNumbers ( int *  pDstStreamNumbers) const

Stream numbers of attachment streams in file.

Note
Size of dstStreamNumbers must be at least numAttachmentStreams().
Parameters
pDstStreamNumbersPointer to the destination stream numbers.

◆ audioStreamNumbers()

void blo::AVFileIn::audioStreamNumbers ( int *  pDstStreamNumbers) const

Stream numbers of audio streams in file.

Note
Size of dstStreamNumbers must be at least numAudioStreams().
Parameters
pDstStreamNumbersPointer to the destination stream numbers.

◆ avgFrameRate()

double blo::AVFileIn::avgFrameRate ( int  streamNumber) const

Video stream average frame rate.

Parameters
streamNumberStream number.
Returns
Average frame rate in frames/s.

◆ bitrate() [1/2]

int blo::AVFileIn::bitrate ( ) const

File bitrate.

Returns
Bitrate in bit/s.

◆ bitrate() [2/2]

int blo::AVFileIn::bitrate ( int  streamNumber) const

Stream bitrate.

Parameters
streamNumberStream number.
Returns
Bitrate in bit/s.

◆ channelLayout()

uint64_t blo::AVFileIn::channelLayout ( int  streamNumber) const

Audio stream channel layout.

Parameters
streamNumberStream number.
Returns
Channel layout.

◆ channels()

int blo::AVFileIn::channels ( int  streamNumber) const

Audio stream number of channels.

Parameters
streamNumberStream number.
Returns
Number of channels.

◆ close()

void blo::AVFileIn::close ( )

Closes file.

◆ codecID()

AVCodecID blo::AVFileIn::codecID ( int  streamNumber) const

Codec ID of stream.

Parameters
streamNumberStream number.
Returns
Codec ID of stream.

◆ codecTag()

unsigned int blo::AVFileIn::codecTag ( int  streamNumber) const

Codec tag of stream.

This function returns the four type tag of the stream, least significant byte (LSB) first.

Parameters
streamNumberStream number.
Returns
Codec tag of stream.

◆ convertAudioFrame()

template<typename T >
BLO_EXPIMP_TEMPLATE template BLO_API bool blo::AVFileIn::convertAudioFrame ( uint64_t  dstChannelLayout,
T *  pDst,
int  dstLen 
)

Converts the current decoded audio frame.

This function converts the current decoded audio frame to the specified channel layout and sample format.

Note
Channels in the audio frame are interleaved.
Template Parameters
TData type.
Parameters
dstChannelLayoutThe channel layout to convert the current decoded frame to.
pDstPointer to the destination audio buffer.
dstLenLength of the destination audio buffer in samples (all channels). It must be equal to channels( dstChannelLayout ) * frameSize, where frameSize is output from decodeAudioFrame().
Returns
Whether or not the convert was successful.

◆ convertAudioFrame_Mono()

template<typename T >
BLO_EXPIMP_TEMPLATE template BLO_API bool blo::AVFileIn::convertAudioFrame_Mono ( T *  pDst,
int  dstLen 
)

Converts the current decoded audio frame to mono.

This function converts the current decoded audio frame to mono channel layout and the specified sample format.

Template Parameters
TData type.
Parameters
pDstPointer to the destination audio buffer.
dstLenLength of the destination audio buffer in samples (all channels). It must be equal to frameSize, where frameSize is output from decodeAudioFrame().
Returns
Whether or not the convert was successful.

◆ convertAudioFrame_Stereo()

template<typename T >
BLO_EXPIMP_TEMPLATE template BLO_API bool blo::AVFileIn::convertAudioFrame_Stereo ( T *  pDst,
int  dstLen 
)

Converts the current decoded audio frame to stereo.

This function converts the current decoded audio frame to stereo channel layout and the specified sample format.

Note
Channels in the audio frame are interleaved.
Template Parameters
TData type.
Parameters
pDstPointer to the destination audio buffer.
dstLenLength of the destination audio buffer in samples (all channels). It must be equal to 2 * frameSize, where frameSize is output from decodeAudioFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame()

bool blo::AVFileIn::convertVideoFrame ( AVPixelFormat  dstPixelFormat,
uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame.

Parameters
dstPixelFormatThe pixel format to decode the frame to.
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_ABGR_C4()

bool blo::AVFileIn::convertVideoFrame_ABGR_C4 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to ABGR.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_ARGB_C4()

bool blo::AVFileIn::convertVideoFrame_ARGB_C4 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to ARGB.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_BGR_C3()

bool blo::AVFileIn::convertVideoFrame_BGR_C3 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to BGR.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_BGR_C4()

bool blo::AVFileIn::convertVideoFrame_BGR_C4 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to BGR.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_BGRA_C4()

bool blo::AVFileIn::convertVideoFrame_BGRA_C4 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to BGRA.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_RGB_C3()

bool blo::AVFileIn::convertVideoFrame_RGB_C3 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to RGB.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_RGB_C4()

bool blo::AVFileIn::convertVideoFrame_RGB_C4 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to RGB.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_RGBA_C4()

bool blo::AVFileIn::convertVideoFrame_RGBA_C4 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to RGBA.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ convertVideoFrame_Y_C1()

bool blo::AVFileIn::convertVideoFrame_Y_C1 ( uint8_t *  pDst,
int  dstStep,
int  dstWidth,
int  dstHeight 
)

Converts the current decoded video frame to Y.

Parameters
pDstPointer to the destination image.
dstStepStep in bytes between the rows in the destination image.
dstWidthWidth of the destination image in pixels.
It must be equal to width, where width is output from decodeVideoFrame().
dstHeightHeight of the destination image in pixels.
It must be equal to height, where height is output from decodeVideoFrame().
Returns
Whether or not the convert was successful.

◆ dataStreamNumbers()

void blo::AVFileIn::dataStreamNumbers ( int *  pDstStreamNumbers) const

Stream numbers of data streams in file.

Note
Size of dstStreamNumbers must be at least numDataStreams().
Parameters
pDstStreamNumbersPointer to the destination stream numbers.

◆ decodeAudioFrame()

bool blo::AVFileIn::decodeAudioFrame ( int &  frameSize,
bool &  isLastFrameInPacket,
double *  p_pts = nullptr 
)

Decodes the current audio frame.

This function decodes the current audio frame in the packet.
Audio packets can contain multiple frames, so this function may need to be called multiple times in order to decode all frames in the packet.

Parameters
frameSizeFrame size in samples/channel.
isLastFrameInPacketWheather or not the frame is the last one in the packet.
p_ptsPointer to the presentation time stamp (PTS) of the frame.
Returns
Whether or not the decode was successful.

◆ decodeVideoFrame()

bool blo::AVFileIn::decodeVideoFrame ( int &  width,
int &  height,
double *  p_pts = nullptr,
int *  pFrameNum = nullptr,
InterlacedFrame *  pInterlacedFrame = nullptr,
bool *  pIsKeyFrame = nullptr 
)

Decodes the current video frame.

Parameters
widthWidth of the image in pixels.
heightHeight of the image in pixels.
p_ptsPointer to the presentation time stamp (PTS).
pFrameNumPointer to the frame number.
pInterlacedFramePointer to the type of interlacing.
pIsKeyFramePointer to the whether or not the frame is a key frame.
Returns
Whether or not the decode was successful.

◆ defaultStreamNumber()

int blo::AVFileIn::defaultStreamNumber ( )

Default stream number in file.

Returns
Default stream number in file.

◆ displayAspectRatio()

double blo::AVFileIn::displayAspectRatio ( int  streamNumber) const

Video stream frame display aspect ratio.

Parameters
streamNumberStream number.
Returns
Frame display aspect ratio.

◆ duration() [1/2]

double blo::AVFileIn::duration ( ) const

File duration.

Returns
Duration in seconds.

◆ duration() [2/2]

double blo::AVFileIn::duration ( int  streamNumber) const

Stream duration.

Parameters
streamNumberStream number.
Returns
Duration in seconds.

◆ frameRate()

double blo::AVFileIn::frameRate ( int  streamNumber) const

Video stream frame rate.

Parameters
streamNumberStream number.
Returns
Frame rate in frames/s.

◆ frameSize()

int blo::AVFileIn::frameSize ( int  streamNumber) const

Audio stream frame size.

Parameters
streamNumberStream number.
Returns
Frame size in samples/channel.

◆ hasAlphaChannel()

bool blo::AVFileIn::hasAlphaChannel ( int  streamNumber) const

Absence or presence of alpha channel in video stream frame.

Parameters
streamNumberStream number.
Returns
true if frame has alpha channel, false otherwise.

◆ hasCodec()

bool blo::AVFileIn::hasCodec ( int  streamNumber) const

Tests if stream codec is available.

Parameters
streamNumberStream number.
Returns
true if codec is available, false otherwise.

◆ height()

int blo::AVFileIn::height ( int  streamNumber) const

Video stream frame height.

Parameters
streamNumberStream number.
Returns
Frame height.

◆ isAttachment()

bool blo::AVFileIn::isAttachment ( int  streamNumber) const

Tests if stream is attachment stream.

Parameters
streamNumberStream number.
Returns
true if stream is attachment stream, false otherwise.

◆ isAudio()

bool blo::AVFileIn::isAudio ( int  streamNumber) const

Tests if stream is audio stream.

Parameters
streamNumberStream number.
Returns
true if stream is audio stream, false otherwise.

◆ isData()

bool blo::AVFileIn::isData ( int  streamNumber) const

Tests if stream is data stream.

Parameters
streamNumberStream number.
Returns
true if stream is data stream, false otherwise.

◆ isOpen()

bool blo::AVFileIn::isOpen ( ) const

Tests if the file is open.

Returns
true if file is open, false otherwise.

◆ isSubtitle()

bool blo::AVFileIn::isSubtitle ( int  streamNumber) const

Tests if stream is subtitle stream.

Parameters
streamNumberStream number.
Returns
true if stream is subtitle stream, false otherwise.

◆ isUnknown()

bool blo::AVFileIn::isUnknown ( int  streamNumber) const

Tests if stream is unknown stream.

Parameters
streamNumberStream number.
Returns
true if stream is unknown stream, false otherwise.

◆ isVideo()

bool blo::AVFileIn::isVideo ( int  streamNumber) const

Tests if stream is video stream.

Parameters
streamNumberStream number.
Returns
true if stream is video stream, false otherwise.

◆ mediaType()

AVMediaType blo::AVFileIn::mediaType ( int  streamNumber) const

Media type of stream.

Parameters
streamNumberStream number.
Returns
Media type of stream.

◆ numAttachmentStreams()

int blo::AVFileIn::numAttachmentStreams ( ) const

Number of attachment streams in file.

Returns
Number of attachment streams in file.

◆ numAudioStreams()

int blo::AVFileIn::numAudioStreams ( ) const

Number of audio streams in file.

Returns
Number of audio streams in file.

◆ numDataStreams()

int blo::AVFileIn::numDataStreams ( ) const

Number of data streams in file.

Returns
Number of data streams in file.

◆ numStreams() [1/2]

int blo::AVFileIn::numStreams ( ) const

Number of streams in file.

Returns
Number of streams in file.

◆ numStreams() [2/2]

int blo::AVFileIn::numStreams ( AVMediaType  mediatype) const

Number of streams of specified media in file.

Parameters
mediatypeThe media type.
Returns
Number of streams of specified media in file.

◆ numSubtitleStreams()

int blo::AVFileIn::numSubtitleStreams ( ) const

Number of subtitle streams in file.

Returns
Number of subtitle streams in file.

◆ numUnknownStreams()

int blo::AVFileIn::numUnknownStreams ( ) const

Number of unknown streams in file.

Returns
Number of unknown streams in file.

◆ numVideoStreams()

int blo::AVFileIn::numVideoStreams ( ) const

Number of video streams in file.

Returns
Number of video streams in file.

◆ onReadFrame()

virtual void blo::AVFileIn::onReadFrame ( int  streamNumber)
protectedvirtual

Called on successful frame read.

This function is called upon each successfully frame read.
This function does nothing in the base class AVFileIn.

Parameters
streamNumberThe stream number that the frame is in.

◆ open() [1/4]

void blo::AVFileIn::open ( const char *  deviceName,
const char *  formatName,
double  frameRate 
)

Opens input video device.

Note
Under Windows, formatName is "vfwcap" and deviceName is the device number as a string (e.g., "0"), or formatName is "dshow" and deviceName is "type=name", where type is audio or video and name is the device name (e.g., "video=Logitech HD Webcam C615"). Under Linux, deviceName is "/dev/videoN", where N is the device number, and formatName is "video4linux" or "video4linux2".
Parameters
deviceNameDevice name string.
formatNameFormat name string.
frameRateFrame rate in frames/s.

◆ open() [2/4]

void blo::AVFileIn::open ( const char *  deviceName,
const char *  formatName,
double  frameRate,
int  width,
int  height 
)

Opens input video device.

Note
Under Windows, formatName is "vfwcap" and deviceName is the device number as a string (e.g., "0"), or formatName is "dshow" and deviceName is "type=name", where type is audio or video and name is the device name (e.g., "video=Logitech HD Webcam C615"). Under Linux, deviceName is "/dev/videoN", where N is the device number, and formatName is "video4linux" or "video4linux2".
Parameters
deviceNameDevice name string.
formatNameFormat name string.
frameRateFrame rate in frames/s.
widthThe width of the frames.
heightThe height of the frames.

◆ open() [3/4]

void blo::AVFileIn::open ( const char *  filename)

Opens input file.

Parameters
filenameFilename string.

◆ open() [4/4]

void blo::AVFileIn::open ( const char *  filename,
const AVInputFormat *  pInputFormat 
)

Opens input file.

Parameters
filenameFilename string.
pInputFormatFile format to use (force), or nullptr to use default.

◆ operator=()

AVFileIn & blo::AVFileIn::operator= ( const AVFileIn &  rhs)
delete

◆ pixelAspectRatio()

double blo::AVFileIn::pixelAspectRatio ( int  streamNumber) const

Video stream frame pixel aspect ratio.

Parameters
streamNumberStream number.
Returns
Frame pixel aspect ratio.

◆ pixelFormat()

AVPixelFormat blo::AVFileIn::pixelFormat ( int  streamNumber) const

Video stream pixel format.

Parameters
streamNumberStream number.
Returns
Pixel format.

◆ readNextFrame()

bool blo::AVFileIn::readNextFrame ( int &  streamNumber,
double *  p_pts = nullptr,
double *  p_dts = nullptr,
bool *  pIsKeyFrame = nullptr 
)

Reads the next frame.

Note
DTS is always less than or equal to PTS.
Parameters
streamNumberThe stream number that the frame is in.
p_ptsPointer to the presentation time stamp (PTS).
p_dtsPointer to the decode time stamp (DTS).
pIsKeyFramePointer to the whether or not the frame is a key frame.
Returns
Whether or not the read was successful. Also returns false if the end of the file has been reached.

◆ readThroughNextFrameInStream()

bool blo::AVFileIn::readThroughNextFrameInStream ( int  streamNumber,
double *  p_pts = nullptr,
double *  p_dts = nullptr,
bool *  pIsKeyFrame = nullptr 
)

Reads the file through the next frame in the specified stream.

This function reads frames until after it has read the next frame in the specified stream.

Note
DTS is always less than or equal to PTS.
Parameters
streamNumberThe stream number.
p_ptsPointer to the presentation time stamp (PTS).
p_dtsPointer to the decode time stamp (DTS).
pIsKeyFramePointer to the whether or not the frame is a key frame.
Returns
Whether or not the read was successful. Also returns false if the end of the file has been reached.

◆ sampleFormat()

AVSampleFormat blo::AVFileIn::sampleFormat ( int  streamNumber) const

Audio stream sample format.

Parameters
streamNumberStream number.
Returns
Sample format.

◆ sampleRate()

int blo::AVFileIn::sampleRate ( int  streamNumber) const

Audio stream sample rate.

Parameters
streamNumberStream number.
Returns
Sample rate in samples/s.

◆ seek() [1/2]

void blo::AVFileIn::seek ( double  timeStamp,
SeekPosition  seekPosition,
SeekFrame  seekFrame 
)

Seeks to the frame at the specified time stamp.

Parameters
timeStampThe time stamp.
seekPositionType of position to seek to.
seekFrameType of frame to seek to.

◆ seek() [2/2]

void blo::AVFileIn::seek ( int  streamNumber,
double  timeStamp,
SeekPosition  seekPosition,
SeekFrame  seekFrame 
)

Seeks to the frame at the specified time stamp.

Note
When seeking to a key frame, the resulting key frame may not be in the specified stream number.
Parameters
streamNumberThe stream number.
timeStampThe time stamp.
seekPositionType of position to seek to.
seekFrameType of frame to seek to.

◆ startTime() [1/2]

double blo::AVFileIn::startTime ( ) const

File start time.

Returns
Start time in seconds.

◆ startTime() [2/2]

double blo::AVFileIn::startTime ( int  streamNumber) const

Stream start time.

Parameters
streamNumberStream number.
Returns
Start time in seconds.

◆ storageAspectRatio()

double blo::AVFileIn::storageAspectRatio ( int  streamNumber) const

Video stream frame storage aspect ratio.

Parameters
streamNumberStream number.
Returns
Frame storage aspect ratio.

◆ streamNumbers()

void blo::AVFileIn::streamNumbers ( AVMediaType  mediatype,
int *  pDstStreamNumbers 
) const

Stream numbers of specified media in file.

Note
Size of dstStreamNumbers must be at least numStreams( AVMediaType mediatype ).
Parameters
mediatypeThe media type.
pDstStreamNumbersPointer to the destination stream numbers.

◆ subtitleStreamNumbers()

void blo::AVFileIn::subtitleStreamNumbers ( int *  pDstStreamNumbers) const

Stream numbers of subtitle streams in file.

Note
Size of dstStreamNumbers must be at least numSubtitleStreams().
Parameters
pDstStreamNumbersPointer to the destination stream numbers.

◆ unknownStreamNumbers()

void blo::AVFileIn::unknownStreamNumbers ( int *  pDstStreamNumbers) const

Stream numbers of unknown streams in file.

Note
Size of dstStreamNumbers must be at least numUnknownStreams().
Parameters
pDstStreamNumbersPointer to the destination stream numbers.

◆ videoStreamNumbers()

void blo::AVFileIn::videoStreamNumbers ( int *  pDstStreamNumbers) const

Stream numbers of video streams in file.

Note
Size of dstStreamNumbers must be at least numVideoStreams().
Parameters
pDstStreamNumbersPointer to the destination stream numbers.

◆ width()

int blo::AVFileIn::width ( int  streamNumber) const

Video stream frame width.

Parameters
streamNumberStream number.
Returns
Frame width.

The documentation for this class was generated from the following file: