YARP
Yet Another Robot Platform

ffmpeg_grabber: An image frame grabber device using ffmpeg to capture images from AVI files. More...

#include <ffmpeg/FfmpegGrabber.h>

+ Inheritance diagram for FfmpegGrabber:

Public Member Functions

 FfmpegGrabber ()
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver. More...
 
bool close () override
 Close the DeviceDriver. More...
 
bool getImage (yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
 Get an rgb image from the frame grabber, if required demosaicking/color reconstruction is applied. More...
 
bool getSound (yarp::sig::Sound &sound, size_t min_number_of_samples, size_t max_number_of_samples, double max_samples_timeout_s) override
 Get a sound from a device. More...
 
int height () const override
 Return the height of each frame. More...
 
int width () const override
 Return the width of each frame. More...
 
virtual bool getAudioVisual (yarp::sig::ImageOf< yarp::sig::PixelRgb > &image, yarp::sig::Sound &sound) override
 Get an image and sound. More...
 
bool hasAudio () override
 
bool hasVideo () override
 
bool startRecording () override
 Start the recording. More...
 
bool stopRecording () override
 Stop the recording. More...
 
bool getRecordingAudioBufferMaxSize (yarp::dev::AudioBufferSize &) override
 
bool getRecordingAudioBufferCurrentSize (yarp::dev::AudioBufferSize &) override
 
bool resetRecordingAudioBuffer () override
 
- Public Member Functions inherited from yarp::dev::IFrameGrabberImage
virtual ~IFrameGrabberImage ()
 Destructor. More...
 
virtual bool getImageCrop (cropType_id_t cropType, yarp::sig::VectorOf< std::pair< int, int > > vertices, yarp::sig::ImageOf< yarp::sig::PixelRgb > &image)
 Get a crop of the rgb image from the frame grabber, if required demosaicking/color reconstruction is applied. More...
 
- Public Member Functions inherited from yarp::dev::IAudioGrabberSound
virtual ~IAudioGrabberSound ()
 Destructor. More...
 
- Public Member Functions inherited from yarp::dev::IAudioVisualGrabber
virtual ~IAudioVisualGrabber ()
 Destructor. More...
 
- Public Member Functions inherited from yarp::dev::IAudioVisualStream
virtual ~IAudioVisualStream ()
 Destructor. More...
 
virtual bool hasRawVideo ()
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
 ~DeviceDriver () override=default
 Destructor. More...
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver. More...
 
virtual DeviceDrivergetImplementation ()
 Some drivers are bureaucrats, pointing at others. More...
 
- Public Member Functions inherited from yarp::os::IConfig
virtual ~IConfig ()
 Destructor. More...
 
virtual bool configure (Searchable &config)
 Change online parameters. More...
 

Protected Member Functions

bool openFirewire (yarp::os::Searchable &config, AVFormatContext **ppFormatCtx)
 
bool openV4L (yarp::os::Searchable &config, AVFormatContext **ppFormatCtx, AVFormatContext **ppFormatCtx2)
 
bool openFile (AVFormatContext **ppFormatCtx, const char *fname)
 

Protected Attributes

void * system_resource
 
AVDictionary * formatParamsVideo
 
AVDictionary * formatParamsAudio
 
AVFormatContext * pFormatCtx
 
AVFormatContext * pFormatCtx2
 
AVFormatContext * pAudioFormatCtx
 
AVPacket packet
 
bool active
 
double startTime
 
bool _hasAudio
 
bool _hasVideo
 
bool needRateControl
 
bool shouldLoop
 
double pace
 
bool imageSync
 
std::string m_uri
 Uri of the images a grabber produces. More...
 
int m_w
 Width of the images a grabber produces. More...
 
int m_h
 Height of the images a grabber produces. More...
 
int m_channels
 
int m_rate
 
void * m_capture
 Opaque ffmpeg structure for image capture. More...
 

Detailed Description

ffmpeg_grabber: An image frame grabber device using ffmpeg to capture images from AVI files.

Definition at line 36 of file FfmpegGrabber.h.

Constructor & Destructor Documentation

◆ FfmpegGrabber()

FfmpegGrabber::FfmpegGrabber ( )
inline

Definition at line 45 of file FfmpegGrabber.h.

Member Function Documentation

◆ close()

bool FfmpegGrabber::close ( )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 607 of file FfmpegGrabber.cpp.

◆ getAudioVisual()

bool FfmpegGrabber::getAudioVisual ( yarp::sig::ImageOf< yarp::sig::PixelRgb > &  image,
yarp::sig::Sound sound 
)
overridevirtual

Get an image and sound.

Parameters
imagethe image to be filled
soundthe sound to be filled
Returns
true/false upon success/failure

Implements yarp::dev::IAudioVisualGrabber.

Definition at line 657 of file FfmpegGrabber.cpp.

◆ getImage()

bool FfmpegGrabber::getImage ( yarp::sig::ImageOf< yarp::sig::PixelRgb > &  image)
overridevirtual

Get an rgb image from the frame grabber, if required demosaicking/color reconstruction is applied.

Parameters
imagethe image to be filled
Returns
true/false upon success/failure

Implements yarp::dev::IFrameGrabberImage.

Definition at line 638 of file FfmpegGrabber.cpp.

◆ getRecordingAudioBufferCurrentSize()

bool FfmpegGrabber::getRecordingAudioBufferCurrentSize ( yarp::dev::AudioBufferSize )
inlineoverridevirtual

Implements yarp::dev::IAudioGrabberSound.

Definition at line 105 of file FfmpegGrabber.h.

◆ getRecordingAudioBufferMaxSize()

bool FfmpegGrabber::getRecordingAudioBufferMaxSize ( yarp::dev::AudioBufferSize )
inlineoverridevirtual

Implements yarp::dev::IAudioGrabberSound.

Definition at line 101 of file FfmpegGrabber.h.

◆ getSound()

bool FfmpegGrabber::getSound ( yarp::sig::Sound sound,
size_t  min_number_of_samples,
size_t  max_number_of_samples,
double  max_samples_timeout_s 
)
overridevirtual

Get a sound from a device.

Examples: getSound(s, 0, 100, 0.1); returns a sound whose size can vary between 0 and 100, with a maximum blocking time of 0.1 getSound(s, 100, 100, 0.0); returns a sound with exact size of 100. It may block forever (more specifically, until sound size is at least 100). getSound(s, 100, 100000, 0.0); returns a sound with a minimum size of 0, while trying to transfer all the internal buffer. It may block forever (more specifically, until sound size is at least 100).

Parameters
soundthe sound to be filled
min_number_of_samples.The function will block until the driver is able to collect at least min_number_of_samples. If set to zero, the function may return empty sounds.
max_number_of_samples.The function will block until the driver is either able to collect max_number_of_samples or the timeout expires.
max_samples_timeout_s.The timeout (in seconds) to retrieve max_number_of_samples.
Returns
true upon success, false for an invalid set of parameters, such as max_number_of_samples<min_number_of_samples, etc.

Implements yarp::dev::IAudioGrabberSound.

Definition at line 647 of file FfmpegGrabber.cpp.

◆ hasAudio()

bool FfmpegGrabber::hasAudio ( )
inlineoverridevirtual

Implements yarp::dev::IAudioVisualStream.

Definition at line 85 of file FfmpegGrabber.h.

◆ hasVideo()

bool FfmpegGrabber::hasVideo ( )
inlineoverridevirtual

Implements yarp::dev::IAudioVisualStream.

Definition at line 89 of file FfmpegGrabber.h.

◆ height()

int FfmpegGrabber::height ( ) const
inlineoverridevirtual

Return the height of each frame.

Returns
image height

Implements yarp::dev::IFrameGrabberImage.

Definition at line 77 of file FfmpegGrabber.h.

◆ open()

bool FfmpegGrabber::open ( yarp::os::Searchable config)
overridevirtual

Open the DeviceDriver.

Parameters
configis a list of parameters for the device. Which parameters are effective for your device can vary. See device invocation examples. If there is no example for your device, you can run the "yarpdev" program with the verbose flag set to probe what parameters the device is checking. If that fails too, you'll need to read the source code (please nag one of the yarp developers to add documentation for your device).
Returns
true/false upon success/failure

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 459 of file FfmpegGrabber.cpp.

◆ openFile()

bool FfmpegGrabber::openFile ( AVFormatContext **  ppFormatCtx,
const char *  fname 
)
protected

Definition at line 451 of file FfmpegGrabber.cpp.

◆ openFirewire()

bool FfmpegGrabber::openFirewire ( yarp::os::Searchable config,
AVFormatContext **  ppFormatCtx 
)
protected

Definition at line 435 of file FfmpegGrabber.cpp.

◆ openV4L()

bool FfmpegGrabber::openV4L ( yarp::os::Searchable config,
AVFormatContext **  ppFormatCtx,
AVFormatContext **  ppFormatCtx2 
)
protected

Definition at line 327 of file FfmpegGrabber.cpp.

◆ resetRecordingAudioBuffer()

bool FfmpegGrabber::resetRecordingAudioBuffer ( )
inlineoverridevirtual

Implements yarp::dev::IAudioGrabberSound.

Definition at line 109 of file FfmpegGrabber.h.

◆ startRecording()

bool FfmpegGrabber::startRecording ( )
inlineoverridevirtual

Start the recording.

Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Definition at line 93 of file FfmpegGrabber.h.

◆ stopRecording()

bool FfmpegGrabber::stopRecording ( )
inlineoverridevirtual

Stop the recording.

Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Definition at line 97 of file FfmpegGrabber.h.

◆ width()

int FfmpegGrabber::width ( ) const
inlineoverridevirtual

Return the width of each frame.

Returns
image width

Implements yarp::dev::IFrameGrabberImage.

Definition at line 79 of file FfmpegGrabber.h.

Member Data Documentation

◆ _hasAudio

bool FfmpegGrabber::_hasAudio
protected

Definition at line 124 of file FfmpegGrabber.h.

◆ _hasVideo

bool FfmpegGrabber::_hasVideo
protected

Definition at line 124 of file FfmpegGrabber.h.

◆ active

bool FfmpegGrabber::active
protected

Definition at line 122 of file FfmpegGrabber.h.

◆ formatParamsAudio

AVDictionary* FfmpegGrabber::formatParamsAudio
protected

Definition at line 117 of file FfmpegGrabber.h.

◆ formatParamsVideo

AVDictionary* FfmpegGrabber::formatParamsVideo
protected

Definition at line 116 of file FfmpegGrabber.h.

◆ imageSync

bool FfmpegGrabber::imageSync
protected

Definition at line 128 of file FfmpegGrabber.h.

◆ m_capture

void* FfmpegGrabber::m_capture
protected

Opaque ffmpeg structure for image capture.

Definition at line 142 of file FfmpegGrabber.h.

◆ m_channels

int FfmpegGrabber::m_channels
protected

Definition at line 138 of file FfmpegGrabber.h.

◆ m_h

int FfmpegGrabber::m_h
protected

Height of the images a grabber produces.

Definition at line 136 of file FfmpegGrabber.h.

◆ m_rate

int FfmpegGrabber::m_rate
protected

Definition at line 139 of file FfmpegGrabber.h.

◆ m_uri

std::string FfmpegGrabber::m_uri
protected

Uri of the images a grabber produces.

Definition at line 131 of file FfmpegGrabber.h.

◆ m_w

int FfmpegGrabber::m_w
protected

Width of the images a grabber produces.

Definition at line 134 of file FfmpegGrabber.h.

◆ needRateControl

bool FfmpegGrabber::needRateControl
protected

Definition at line 125 of file FfmpegGrabber.h.

◆ pace

double FfmpegGrabber::pace
protected

Definition at line 127 of file FfmpegGrabber.h.

◆ packet

AVPacket FfmpegGrabber::packet
protected

Definition at line 121 of file FfmpegGrabber.h.

◆ pAudioFormatCtx

AVFormatContext* FfmpegGrabber::pAudioFormatCtx
protected

Definition at line 120 of file FfmpegGrabber.h.

◆ pFormatCtx

AVFormatContext* FfmpegGrabber::pFormatCtx
protected

Definition at line 118 of file FfmpegGrabber.h.

◆ pFormatCtx2

AVFormatContext* FfmpegGrabber::pFormatCtx2
protected

Definition at line 119 of file FfmpegGrabber.h.

◆ shouldLoop

bool FfmpegGrabber::shouldLoop
protected

Definition at line 126 of file FfmpegGrabber.h.

◆ startTime

double FfmpegGrabber::startTime
protected

Definition at line 123 of file FfmpegGrabber.h.

◆ system_resource

void* FfmpegGrabber::system_resource
protected

Definition at line 114 of file FfmpegGrabber.h.


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