AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxOSG::VideoFFMPEGPipeCapture Class Reference

#include <VideoFFMPEGPipeCapture.h>

+ Inheritance diagram for agxOSG::VideoFFMPEGPipeCapture:

Classes

struct  CodecHash
 

Public Types

typedef agx::HashTable
< OutputCodec, agx::String,
CodecHash > 
CodecStringConversionMap
 Map for storing codec string conversion for FFMPEG. More...
 
enum  OutputCodec : agx::UInt32 { OutputCodec::H264 = 0, OutputCodec::H264RGB = 1, OutputCodec::XVID = 2 }
 Enum describing the different types of codecs that are available. More...
 

Public Member Functions

 VideoFFMPEGPipeCapture (agx::UInt width, agx::UInt height, agx::Real fps, agxSDK::Simulation *sim=nullptr)
 Constructor. More...
 
virtual void apply (osg::RenderInfo &renderInfo)
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
 DrawCallback (ImageCaptureBase *capture)
 
bool getCaptureStarted () const
 Return whether the capturing is enabled or not. More...
 
DrawCallback * getDrawCallback ()
 
bool getEnableLossless () const
 Get true/false if lossless encoding should be enabled. This will produce videos not supported by older media players. More...
 
bool getEnableSyncWithSimulation () const
 
agx::String getFilename () const
 Gets the video filename, excluding the postfix. More...
 
agx::Real getFps ()
 Return the specified desired frame rate for capture. More...
 
ImageCaptureBase * getImageCapture ()
 
agx::Real getImageCaptureFPS ()
 Get the image capture FPS. Synchronize this with video FPS to control the real time factor. (videoFPS / imageFPS == 1.0 for realtime) More...
 
int getImageNum () const
 
agx::Vec2u getImageResolution () const
 
OutputCodec getOutputCodec () const
 Get the video codec for the output. Available codecs are given in OutPutCodecs. More...
 
int getReferenceCount () const
 
agxSDK::Simulation * getSimulation ()
 
agx::UInt getVideoCRF () const
 get the CRF of the video More...
 
agx::Real getVideoFPS () const
 Get the current FPS of the video. More...
 
agx::String getVideoPostFix () const
 Gets the video postfix. More...
 
bool hasActiveVideo () const
 Returns true if we have active video that is being created. More...
 
void init ()
 Initializes the FFMPEG process and the named pipes. More...
 
template<typename T >
bool is () const
 Subclass test. More...
 
virtual void operator() (osg::RenderInfo &renderInfo) const
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void resetTime ()
 
void setEnableLossless (bool enable)
 Set true/false if lossless encoding should be enabled. This will produce videos not supported by older media players. More...
 
void setEnableSyncWithSimulation (bool enableSync)
 
void setFilename (const agx::String &filename)
 Sets the filename for the video, excluding the postfix. More...
 
void setFps (agx::Real fps)
 Set the desired frame rate (rate of capture). More...
 
void setImageCapture (ImageCaptureBase *ic)
 
void setImageCaptureFPS (agx::Real imageFPS)
 Set the image capture FPS. Synchronize this with video FPS to control the real time factor. (videoFPS / imageFPS == 1.0 for realtime) More...
 
void setImageResolution (agx::UInt width, agx::UInt height)
 
void setMaxImages (int i)
 
Set a limit of the maximum number of images that should be captured

Set -1 for no limit More...

 
void setOutputVideoCodec (OutputCodec codec)
 Set the video codec for the output. Available codecs are given in OutPutCodecs. More...
 
void setSimulation (agxSDK::Simulation *simulation)
 
void setVideoCRF (agx::UInt crf)
 Set the CRF of the video. More...
 
void setVideoFPS (agx::Real videoFPS)
 Set the FPS of the video. More...
 
void setVideoPostFix (const agx::String &postFix)
 Sets the video postfix. More...
 
virtual void startCapture (int startImageNumber=0)
 Enable/disable capturing. More...
 
virtual bool stopCapture ()
 Return false if stopping an already stopped capture process. More...
 
bool stopProcess ()
 Stops the ffmpeg process and finalizes the video file, allowing a new video capture to be started using startCapture(). More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

template<typename T >
static bool ValidateCast (const Referenced *object)
 

Static Public Attributes

static CodecStringConversionMap OutputCodecStrings
 

Protected Member Functions

virtual ~VideoFFMPEGPipeCapture ()
 
void allocateObserverVector () const
 
void closeExternalFFMPEGProcess ()
 
void deleteUsingDeleteHandler () const
 
agx::String generatePipeName () const
 
agx::String getCompleteFileName () const
 
agx::String getFFMPEGBinaryPath () const
 
agx::String getPipeName () const
 
void setCaptureStarted (bool f)
 
void shutdown ()
 
void startExternalFFMPEGProcess ()
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Definition at line 35 of file VideoFFMPEGPipeCapture.h.

Member Typedef Documentation

Map for storing codec string conversion for FFMPEG.

Definition at line 59 of file VideoFFMPEGPipeCapture.h.

Member Enumeration Documentation

Enum describing the different types of codecs that are available.

Enumerator
H264 
H264RGB 
XVID 

Definition at line 41 of file VideoFFMPEGPipeCapture.h.

Constructor & Destructor Documentation

agxOSG::VideoFFMPEGPipeCapture::VideoFFMPEGPipeCapture ( agx::UInt  width,
agx::UInt  height,
agx::Real  fps,
agxSDK::Simulation *  sim = nullptr 
)

Constructor.

Parameters
widthThe width of the finalized video
heightThe height of the finalized video
fpsThe video FPS
simattached simulation, used for timestep synchronization
virtual agxOSG::VideoFFMPEGPipeCapture::~VideoFFMPEGPipeCapture ( )
protectedvirtual

Member Function Documentation

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
virtual void agxOSG::ImageCaptureBase::apply ( osg::RenderInfo &  renderInfo)
virtualinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agxOSG::VideoFFMPEGPipeCapture::closeExternalFFMPEGProcess ( )
protected
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
agxOSG::ImageCaptureBase::DrawCallback ( ImageCaptureBase *  capture)
inherited
agx::String agxOSG::VideoFFMPEGPipeCapture::generatePipeName ( ) const
protected
bool agxOSG::ImageCaptureBase::getCaptureStarted ( ) const
inherited

Return whether the capturing is enabled or not.

agx::String agxOSG::VideoFFMPEGPipeCapture::getCompleteFileName ( ) const
protected
static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
DrawCallback* agxOSG::ImageCaptureBase::getDrawCallback ( )
inherited
bool agxOSG::VideoFFMPEGPipeCapture::getEnableLossless ( ) const

Get true/false if lossless encoding should be enabled. This will produce videos not supported by older media players.

bool agxOSG::ImageCaptureBase::getEnableSyncWithSimulation ( ) const
inherited
agx::String agxOSG::VideoFFMPEGPipeCapture::getFFMPEGBinaryPath ( ) const
protected
agx::String agxOSG::VideoFFMPEGPipeCapture::getFilename ( ) const

Gets the video filename, excluding the postfix.

agx::Real agxOSG::ImageCaptureBase::getFps ( )
inherited

Return the specified desired frame rate for capture.

ImageCaptureBase* agxOSG::ImageCaptureBase::getImageCapture ( )
inherited
agx::Real agxOSG::VideoFFMPEGPipeCapture::getImageCaptureFPS ( )

Get the image capture FPS. Synchronize this with video FPS to control the real time factor. (videoFPS / imageFPS == 1.0 for realtime)

int agxOSG::ImageCaptureBase::getImageNum ( ) const
inherited
agx::Vec2u agxOSG::ImageCaptureBase::getImageResolution ( ) const
inherited
OutputCodec agxOSG::VideoFFMPEGPipeCapture::getOutputCodec ( ) const

Get the video codec for the output. Available codecs are given in OutPutCodecs.

agx::String agxOSG::VideoFFMPEGPipeCapture::getPipeName ( ) const
protected
int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
agxSDK::Simulation* agxOSG::ImageCaptureBase::getSimulation ( )
inherited
agx::UInt agxOSG::VideoFFMPEGPipeCapture::getVideoCRF ( ) const

get the CRF of the video

agx::Real agxOSG::VideoFFMPEGPipeCapture::getVideoFPS ( ) const

Get the current FPS of the video.

agx::String agxOSG::VideoFFMPEGPipeCapture::getVideoPostFix ( ) const

Gets the video postfix.

bool agxOSG::VideoFFMPEGPipeCapture::hasActiveVideo ( ) const

Returns true if we have active video that is being created.

void agxOSG::VideoFFMPEGPipeCapture::init ( )

Initializes the FFMPEG process and the named pipes.

template<typename T >
bool agx::Referenced::is ( ) const
inherited
virtual void agxOSG::ImageCaptureBase::operator() ( osg::RenderInfo &  renderInfo) const
virtualinherited
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

void agxOSG::ImageCaptureBase::resetTime ( )
inherited
void agxOSG::ImageCaptureBase::setCaptureStarted ( bool  f)
protectedinherited
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxOSG::VideoFFMPEGPipeCapture::setEnableLossless ( bool  enable)

Set true/false if lossless encoding should be enabled. This will produce videos not supported by older media players.

void agxOSG::ImageCaptureBase::setEnableSyncWithSimulation ( bool  enableSync)
inherited
void agxOSG::VideoFFMPEGPipeCapture::setFilename ( const agx::String &  filename)

Sets the filename for the video, excluding the postfix.

void agxOSG::ImageCaptureBase::setFps ( agx::Real  fps)
inherited

Set the desired frame rate (rate of capture).

void agxOSG::ImageCaptureBase::setImageCapture ( ImageCaptureBase *  ic)
inherited
void agxOSG::VideoFFMPEGPipeCapture::setImageCaptureFPS ( agx::Real  imageFPS)

Set the image capture FPS. Synchronize this with video FPS to control the real time factor. (videoFPS / imageFPS == 1.0 for realtime)

void agxOSG::ImageCaptureBase::setImageResolution ( agx::UInt  width,
agx::UInt  height 
)
inherited
void agxOSG::ImageCaptureBase::setMaxImages ( int  i)
inherited

Set a limit of the maximum number of images that should be captured

Set -1 for no limit

void agxOSG::VideoFFMPEGPipeCapture::setOutputVideoCodec ( OutputCodec  codec)

Set the video codec for the output. Available codecs are given in OutPutCodecs.

void agxOSG::ImageCaptureBase::setSimulation ( agxSDK::Simulation *  simulation)
inherited
void agxOSG::VideoFFMPEGPipeCapture::setVideoCRF ( agx::UInt  crf)

Set the CRF of the video.

void agxOSG::VideoFFMPEGPipeCapture::setVideoFPS ( agx::Real  videoFPS)

Set the FPS of the video.

void agxOSG::VideoFFMPEGPipeCapture::setVideoPostFix ( const agx::String &  postFix)

Sets the video postfix.

void agxOSG::ImageCaptureBase::shutdown ( )
protectedinherited
virtual void agxOSG::ImageCaptureBase::startCapture ( int  startImageNumber = 0)
virtualinherited

Enable/disable capturing.

void agxOSG::VideoFFMPEGPipeCapture::startExternalFFMPEGProcess ( )
protected
virtual bool agxOSG::ImageCaptureBase::stopCapture ( )
virtualinherited

Return false if stopping an already stopped capture process.

bool agxOSG::VideoFFMPEGPipeCapture::stopProcess ( )

Stops the ffmpeg process and finalizes the video file, allowing a new video capture to be started using startCapture().

Returns
false if the ffmpeg process returned a non-zero value, true otherwise
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

CodecStringConversionMap agxOSG::VideoFFMPEGPipeCapture::OutputCodecStrings
static

Definition at line 60 of file VideoFFMPEGPipeCapture.h.


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