YARP
Yet Another Robot Platform
FfmpegGrabber Class Reference

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 image from the frame grabber. 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 isRecording (bool &recording_enabled) override
 Check if the recording has been enabled (e.g. More...
 
bool getRecordingAudioBufferMaxSize (yarp::dev::AudioBufferSize &) override
 
bool getRecordingAudioBufferCurrentSize (yarp::dev::AudioBufferSize &) override
 
bool resetRecordingAudioBuffer () override
 
bool setHWGain (double gain) override
 Sets the hardware gain of the grabbing device (if supported by the hardware) More...
 
bool setSWGain (double gain) override
 Sets a software gain for the grabbed audio. More...
 
- Public Member Functions inherited from yarp::dev::IFrameGrabberOf< yarp::sig::ImageOf< yarp::sig::PixelRgb > >
virtual bool getImage (yarp::sig::ImageOf< yarp::sig::PixelRgb > &image)=0
 Get an image from the frame grabber. 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 image from the frame grabber. More...
 
- Public Member Functions inherited from yarp::dev::IFrameGrabberImageBase
virtual ~IFrameGrabberImageBase ()
 Destructor. More...
 
virtual int height () const =0
 Return the height of each frame. More...
 
virtual int width () const =0
 Return the width of each frame. More...
 
- Public Member Functions inherited from yarp::dev::IAudioGrabberSound
virtual ~IAudioGrabberSound ()
 Destructor. More...
 
virtual bool getSound (yarp::sig::Sound &sound, size_t min_number_of_samples, size_t max_number_of_samples, double max_samples_timeout_s)=0
 Get a sound from a device. More...
 
virtual bool startRecording ()=0
 Start the recording. More...
 
virtual bool stopRecording ()=0
 Stop the recording. More...
 
virtual bool isRecording (bool &recording_enabled)=0
 Check if the recording has been enabled (e.g. More...
 
virtual bool getRecordingAudioBufferMaxSize (yarp::dev::AudioBufferSize &size)=0
 
virtual bool getRecordingAudioBufferCurrentSize (yarp::dev::AudioBufferSize &size)=0
 
virtual bool resetRecordingAudioBuffer ()=0
 
virtual bool setSWGain (double gain)=0
 Sets a software gain for the grabbed audio. More...
 
virtual bool setHWGain (double gain)=0
 Sets the hardware gain of the grabbing device (if supported by the hardware) More...
 
- Public Member Functions inherited from yarp::dev::IAudioVisualGrabber
virtual ~IAudioVisualGrabber ()
 Destructor. More...
 
virtual bool getAudioVisual (yarp::sig::ImageOf< yarp::sig::PixelRgb > &image, yarp::sig::Sound &sound)=0
 Get an image and sound. More...
 
- Public Member Functions inherited from yarp::dev::IAudioVisualStream
virtual ~IAudioVisualStream ()
 Destructor. More...
 
virtual bool hasAudio ()=0
 
virtual bool hasVideo ()=0
 
virtual bool hasRawVideo ()
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
 DeviceDriver ()
 
 DeviceDriver (const DeviceDriver &other)=delete
 
 DeviceDriver (DeviceDriver &&other) noexcept=delete
 
DeviceDriveroperator= (const DeviceDriver &other)=delete
 
DeviceDriveroperator= (DeviceDriver &&other) noexcept=delete
 
 ~DeviceDriver () override
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver. More...
 
bool close () override
 Close the DeviceDriver. More...
 
virtual std::string id () const
 Return the id assigned to the PolyDriver. More...
 
virtual void setId (const std::string &id)
 Set the id for this device. 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 open (Searchable &config)
 Initialize the object. More...
 
virtual bool close ()
 Shut the object down. 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 34 of file FfmpegGrabber.h.

Constructor & Destructor Documentation

◆ FfmpegGrabber()

FfmpegGrabber::FfmpegGrabber ( )
inline

Definition at line 43 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 610 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 660 of file FfmpegGrabber.cpp.

◆ getImage()

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

Get an image from the frame grabber.

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

Implements yarp::dev::IFrameGrabberOf< yarp::sig::ImageOf< yarp::sig::PixelRgb > >.

Definition at line 641 of file FfmpegGrabber.cpp.

◆ getRecordingAudioBufferCurrentSize()

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

Implements yarp::dev::IAudioGrabberSound.

Definition at line 107 of file FfmpegGrabber.h.

◆ getRecordingAudioBufferMaxSize()

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

Implements yarp::dev::IAudioGrabberSound.

Definition at line 103 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 650 of file FfmpegGrabber.cpp.

◆ hasAudio()

bool FfmpegGrabber::hasAudio ( )
inlineoverridevirtual

Implements yarp::dev::IAudioVisualStream.

Definition at line 83 of file FfmpegGrabber.h.

◆ hasVideo()

bool FfmpegGrabber::hasVideo ( )
inlineoverridevirtual

Implements yarp::dev::IAudioVisualStream.

Definition at line 87 of file FfmpegGrabber.h.

◆ height()

int FfmpegGrabber::height ( ) const
inlineoverridevirtual

Return the height of each frame.

Returns
image height

Implements yarp::dev::IFrameGrabberImageBase.

Definition at line 75 of file FfmpegGrabber.h.

◆ isRecording()

bool FfmpegGrabber::isRecording ( bool &  recording_enabled)
inlineoverridevirtual

Check if the recording has been enabled (e.g.

via startRecording()/stopRecording())

Parameters
recording_enabledthe status of the device
Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Definition at line 99 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 458 of file FfmpegGrabber.cpp.

◆ openFile()

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

Definition at line 450 of file FfmpegGrabber.cpp.

◆ openFirewire()

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

Definition at line 434 of file FfmpegGrabber.cpp.

◆ openV4L()

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

Definition at line 326 of file FfmpegGrabber.cpp.

◆ resetRecordingAudioBuffer()

bool FfmpegGrabber::resetRecordingAudioBuffer ( )
inlineoverridevirtual

Implements yarp::dev::IAudioGrabberSound.

Definition at line 111 of file FfmpegGrabber.h.

◆ setHWGain()

bool FfmpegGrabber::setHWGain ( double  gain)
inlineoverridevirtual

Sets the hardware gain of the grabbing device (if supported by the hardware)

Parameters
gainthe audio gain (1.0 is the default value)
Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Definition at line 115 of file FfmpegGrabber.h.

◆ setSWGain()

bool FfmpegGrabber::setSWGain ( double  gain)
inlineoverridevirtual

Sets a software gain for the grabbed audio.

Parameters
gainthe audio gain (1.0 is the default value)
Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Definition at line 119 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 91 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 95 of file FfmpegGrabber.h.

◆ width()

int FfmpegGrabber::width ( ) const
inlineoverridevirtual

Return the width of each frame.

Returns
image width

Implements yarp::dev::IFrameGrabberImageBase.

Definition at line 77 of file FfmpegGrabber.h.

Member Data Documentation

◆ _hasAudio

bool FfmpegGrabber::_hasAudio
protected

Definition at line 134 of file FfmpegGrabber.h.

◆ _hasVideo

bool FfmpegGrabber::_hasVideo
protected

Definition at line 134 of file FfmpegGrabber.h.

◆ active

bool FfmpegGrabber::active
protected

Definition at line 132 of file FfmpegGrabber.h.

◆ formatParamsAudio

AVDictionary* FfmpegGrabber::formatParamsAudio
protected

Definition at line 127 of file FfmpegGrabber.h.

◆ formatParamsVideo

AVDictionary* FfmpegGrabber::formatParamsVideo
protected

Definition at line 126 of file FfmpegGrabber.h.

◆ imageSync

bool FfmpegGrabber::imageSync
protected

Definition at line 138 of file FfmpegGrabber.h.

◆ m_capture

void* FfmpegGrabber::m_capture
protected

Opaque ffmpeg structure for image capture.

Definition at line 152 of file FfmpegGrabber.h.

◆ m_channels

int FfmpegGrabber::m_channels
protected

Definition at line 148 of file FfmpegGrabber.h.

◆ m_h

int FfmpegGrabber::m_h
protected

Height of the images a grabber produces.

Definition at line 146 of file FfmpegGrabber.h.

◆ m_rate

int FfmpegGrabber::m_rate
protected

Definition at line 149 of file FfmpegGrabber.h.

◆ m_uri

std::string FfmpegGrabber::m_uri
protected

Uri of the images a grabber produces.

Definition at line 141 of file FfmpegGrabber.h.

◆ m_w

int FfmpegGrabber::m_w
protected

Width of the images a grabber produces.

Definition at line 144 of file FfmpegGrabber.h.

◆ needRateControl

bool FfmpegGrabber::needRateControl
protected

Definition at line 135 of file FfmpegGrabber.h.

◆ pace

double FfmpegGrabber::pace
protected

Definition at line 137 of file FfmpegGrabber.h.

◆ packet

AVPacket FfmpegGrabber::packet
protected

Definition at line 131 of file FfmpegGrabber.h.

◆ pAudioFormatCtx

AVFormatContext* FfmpegGrabber::pAudioFormatCtx
protected

Definition at line 130 of file FfmpegGrabber.h.

◆ pFormatCtx

AVFormatContext* FfmpegGrabber::pFormatCtx
protected

Definition at line 128 of file FfmpegGrabber.h.

◆ pFormatCtx2

AVFormatContext* FfmpegGrabber::pFormatCtx2
protected

Definition at line 129 of file FfmpegGrabber.h.

◆ shouldLoop

bool FfmpegGrabber::shouldLoop
protected

Definition at line 136 of file FfmpegGrabber.h.

◆ startTime

double FfmpegGrabber::startTime
protected

Definition at line 133 of file FfmpegGrabber.h.

◆ system_resource

void* FfmpegGrabber::system_resource
protected

Definition at line 124 of file FfmpegGrabber.h.


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