public class SoMPEGRenderer extends Inventor
SoMPEGFrameRenderer
and SoMPEGNavRenderer
are provided to give applications more control over video generation.
Warning : Writing in multiple streams at the same time is not possible.
This class is used by the viewer classes to record MPEG video (see for example the SoWinRenderArea method setMPEGRecorder ). The default right-mouse popup menu in the viewer classes provides an option to display a video recording dialog box. This dialog allows the user to conveniently start and stop recording the scene in the viewer window.
The setShareContext
method allows you to share an existing OpenGL context with the MPEG renderer. This avoids the necessity to re-generate textures and display lists if they are already available in another OpenGL context (the viewer context, for instance). This can dramatically reduce offscreen rendering time, depending on your scene graph.
Here's how you might use these methods to share OpenGL contexts: It is important to note that the MPEGRenderer can only generate raw MPEG-1 video streams. In order for the generated video to be played correctly by any video player, it needs to be embedded into a container. This operation can be easily performed by the multimedia tool The
-codec copy argument is important because it allows ffmpeg to only copy the input stream inside the container instead of doing a real re-encoding.
Different container formats can also be used, like AVI or MKV.
See also:
The MPEGRender uses two separate tasks. One to record rendered frames and one to encode the frames in MPEG format (this is a much slower task). If the recording task is stopped, the encoding one can continue. If openFile
is called before the end of this task, two scenarios can occur. If the filename is the same file as the one currently in use by the encoding task, this task is stopped. The behavior is the same if record
is called after stop
. If the filename is different, the file is not opened and encoding continues.
Modifier and Type | Class and Description |
---|---|
static class |
SoMPEGRenderer.Components
Components.
|
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
LUMINANCE
Deprecated.
Use
SoMPEGRenderer.Components.LUMINANCE instead. |
static int |
LUMINANCE_TRANSPARENCY
Deprecated.
Use
SoMPEGRenderer.Components.LUMINANCE_TRANSPARENCY instead. |
static int |
RGB
Deprecated.
Use
SoMPEGRenderer.Components.RGB instead. |
static int |
RGB_TRANSPARENCY
Deprecated.
Use
SoMPEGRenderer.Components.RGB_TRANSPARENCY instead. |
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoMPEGRenderer()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addFrame(byte[] frame)
Low level method to add a new frame to the MPEG output from a buffer of unsigned characters.
|
void |
closeFile()
Closes the MPEG file previously opened with the
openFile() method. |
SbColor |
getBackgroundColor()
Gets the background color for rendering each frame.
|
SoMPEGRenderer.Components |
getComponents()
Returns the number of color components of the frames recorded.
|
float |
getCompressionRate()
Returns the compression rate.
|
SoGLRenderAction |
getGLRenderAction()
Gets the GL Render action used to generate each frame.
|
int |
getNumFramesPerSecond()
Gets the number of frames per second to be encoded in the MPEG output.
|
SoNode |
getSceneGraph()
Gets the scene graph used for generating frames in the MPEG output.
|
SbGLShareContext |
getShareContext()
Gets the OpenGL context shared by the
SoOffscreenRenderer . |
SbVec2s |
getSize()
Gets the frame pixel size.
|
boolean |
isRecording()
Returns true if this renderer is recording.
|
boolean |
isViewerIdle() |
boolean |
openFile(java.lang.String filename)
Calls openFile(filename, (int)10000).
|
boolean |
openFile(java.lang.String filename,
int numFrames)
Specifies the MPEG output file name.
|
void |
pause()
Pauses the recording.
|
void |
record()
Starts the recording.
|
void |
setBackgroundColor(SbColor c)
Sets the background color for rendering each frame.
|
void |
setBitPerSec(float mbps)
This method allows the user to specify a fixed bit rate.
|
void |
setComponents(SoMPEGRenderer.Components components)
Set the number of color components of the frames recorded.
|
void |
setCompressionRate(float value)
Compression rate of the MPEG output.
|
void |
setGLRenderAction(SoGLRenderAction ra)
Sets the GL Render action used to generate each frame.
|
void |
setNumFramesPerSecond(float num)
Sets the number of frames per second encoded in the MPEG output.
|
void |
setSceneGraph(SoNode node)
Sets the scene graph used for generating frames in the MPEG output.
|
void |
setShareContext(SbGLShareContext shareCxt)
Sets the OpenGL context to be shared by the
SoMPEGRenderer . |
void |
setSize(SbVec2s size)
Sets the frame pixel size.
|
void |
setViewerIsIdle(boolean isIdle)
Tells the recorder that the viewer is idle.
|
void |
stop()
Stops the recording and closes the opened file.
|
dispose, getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int LUMINANCE
SoMPEGRenderer.Components.LUMINANCE
instead.@Deprecated public static final int LUMINANCE_TRANSPARENCY
SoMPEGRenderer.Components.LUMINANCE_TRANSPARENCY
instead.@Deprecated public static final int RGB
SoMPEGRenderer.Components.RGB
instead.@Deprecated public static final int RGB_TRANSPARENCY
SoMPEGRenderer.Components.RGB_TRANSPARENCY
instead.public boolean openFile(java.lang.String filename)
public SbVec2s getSize()
setSize()
method.public void setSize(SbVec2s size)
By default, width and height values are 96.
NOTE: This method must be called before openFile
or setFilePointer in order to have an effect. Calling it after calling openFile
or setFilePointer may cause undesirable results.
public void stop()
public boolean isRecording()
public void setViewerIsIdle(boolean isIdle)
public void closeFile()
openFile()
method.public boolean openFile(java.lang.String filename, int numFrames)
If filename is the same as the one currently in use by the encoding task (if there is one), the encoding task is stopped. If the filename is different, the file is not opened and the current encoding task continues.
Returns false if the file cannot be opened, true otherwise.
public boolean isViewerIdle()
public void setComponents(SoMPEGRenderer.Components components)
public void setGLRenderAction(SoGLRenderAction ra)
SoGLRenderAction
will be maintained with a viewport region set to the size given with the method setSize()
.public void setNumFramesPerSecond(float num)
NOTE: This method must be called before openFile
or setFilePointer in order to have an effect. Calling it after calling openFile
or setFilePointer may cause undesirable results.
public SbColor getBackgroundColor()
public int getNumFramesPerSecond()
public void setCompressionRate(float value)
The default value is 0.3.
NOTE: This method must be called before openFile
or setFilePointer in order to have an effect. Calling it after calling openFile
or setFilePointer may cause undesirable results.
public float getCompressionRate()
public SoGLRenderAction getGLRenderAction()
public void setBitPerSec(float mbps)
The default value is 1205862. The maximum value is 104857600. NOTE: This method must be called before openFile
or setFilePointer in order to have an effect. Calling it after calling openFile
or setFilePointer may cause undesirable results.
public void addFrame(byte[] frame)
public void record()
stop
method, the current encoding task (if one) is stopped.
Note: A file must have been opened or a file pointer set.
public void setSceneGraph(SoNode node)
public void pause()
public SoMPEGRenderer.Components getComponents()
public void setShareContext(SbGLShareContext shareCxt)
SoMPEGRenderer
.
Its use is strongly recommended, because it can improve performance when switching between on-screen and off-screen rendering. This is because it allows the display lists and texture objects to be shared between the on-screen and off-screen render context. The shared context info is normally obtained by calling the viewer's getShareContext method.
NOTE: It has no effect when the hardware (or driver) does not allow sharing with the off-screen context, for example if Pbuffers are not supported.
public void setBackgroundColor(SbColor c)
The default value can be set using the environment variable OIV_BACKGROUND_COLOR. Specify three floats (R, G, B) in the range 0. to 1., separated by spaces.
public SbGLShareContext getShareContext()
SoOffscreenRenderer
.public SoNode getSceneGraph()
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com