AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
VideoFFMPEGPipeCapture.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17
18#ifndef AGXOSG_VIDEOFFMPEGPIPECAPTURE_H
19#define AGXOSG_VIDEOFFMPEGPIPECAPTURE_H
20
21#include <agxOSG/ImageCapture.h>
23
24typedef void *HANDLE;
25
26namespace agxOSG
27{
36 {
37 public:
38 class DrawCallback;
39
42 {
43 H264 = 0,
44 H264RGB = 1,
45 XVID = 2
46 };
47
48 // Codec hashFunc
49 struct CodecHash
50 {
51 template <typename T>
53 {
54 return static_cast<agx::UInt32>(t);
55 }
56 };
57
61
62 public:
64
71
73 void init();
74
76 void setFilename(const agx::String& filename);
77
79 void setFilenameExtension(const agx::String& extension);
80
83
86
88 void setVideoFPS(agx::Real videoFPS);
89
92
95
98
101
104
106 void setEnableLossless(bool enable);
107
109 bool getEnableLossless() const;
110
113
116
118 bool hasActiveVideo() const;
119
125
126 protected:
128
130
132
134
136
138
139 private:
140
141 virtual void writeImage(osg::Image *image, agx::Index index);
142
143 private:
144 agx::String m_filename;
145 agx::Real m_videoFPS;
146 agx::String m_pipeName;
147 OutputCodec m_outputCodec;
148 agx::UInt m_crf;
149 agx::UInt m_numWrittenFramesToPipe;
150 bool m_firstFrame;
151 bool m_enableLossless;
152
153#ifdef _MSC_VER
154 HANDLE hPipe;
155#else
156 FILE* m_fifo;
157#endif
158 agxOSG::ExternalProcessRef m_imageServerProcess;
159 };
160}
161
162#endif /* AGXOSG_VideoFFMPEGPipeCapture_H */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
void * HANDLE
#define AGXOSG_EXPORT
bool stopProcess()
Stops the ffmpeg process and finalizes the video file, allowing a new video capture to be started usi...
void setVideoFPS(agx::Real videoFPS)
Set the FPS of the video.
bool getEnableLossless() const
Get true/false if lossless encoding should be enabled. This will produce videos not supported by olde...
VideoFFMPEGPipeCapture(agx::UInt width, agx::UInt height, agx::Real fps, agxSDK::Simulation *sim=nullptr)
Constructor.
agx::Real getImageCaptureFPS()
Get the image capture FPS. Synchronize this with video FPS to control the real time factor....
agx::String getFilename() const
Gets the video filename, including the extension.
OutputCodec getOutputCodec() const
Get the video codec for the output. Available codecs are given in OutPutCodecs.
void setImageCaptureFPS(agx::Real imageFPS)
Set the image capture FPS. Synchronize this with video FPS to control the real time factor....
bool hasActiveVideo() const
Returns true if we have active video that is being created.
agx::String generatePipeName() const
static CodecStringConversionMap OutputCodecStrings
agx::String getPipeName() const
void setFilenameExtension(const agx::String &extension)
Sets the video file extension (without the .)
void setEnableLossless(bool enable)
Set true/false if lossless encoding should be enabled. This will produce videos not supported by olde...
agx::UInt getVideoCRF() const
get the CRF of the video
void setVideoCRF(agx::UInt crf)
Set the CRF of the video.
OutputCodec
Enum describing the different types of codecs that are available.
agx::String getFFMPEGBinaryPath() const
agx::String getFilenameExtension() const
Gets the file extension (without the .)
void setOutputVideoCodec(OutputCodec codec)
Set the video codec for the output. Available codecs are given in OutPutCodecs.
agx::HashTable< OutputCodec, agx::String, CodecHash > CodecStringConversionMap
Map for storing codec string conversion for FFMPEG.
void setFilename(const agx::String &filename)
Sets the filename for the video, including the file extension.
void init()
Initializes the FFMPEG process and the named pipes.
agx::Real getVideoFPS() const
Get the current FPS of the video.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
Inheritance with partial specialization due to bug with ref_ptr containers.
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
uint32_t UInt32
Definition: Integer.h:32
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:41
UInt32 Index
Definition: Integer.h:44