Insight3D can record videos, either as a video file or as individual frames as separate image files.
The CameraVideoRecording type records WMV videos. An instance of this type can be obtained from the CameraVideoRecording property. To begin recording, call the StartRecording(String, Int32, Int32) method. Each time the scene is rendered, such as through animation or by moving the mouse, a frame is sent to the WMV file.
This method takes the filename to save to, as well as two other parameters: video bit rate and the video frame rate. The video bit rate defines the video's bit rate in kilobits per second, i.e. the number of bits each second of video playback uses. A higher bit rate results in better image quality than a lower bit rate, but the higher bit rate file will be larger than the lower.
The video frame rate is in frames per second and is independent of the frame rate you experience with the application. For example, if the video frame rate is set to 30 and the application is rendering 300 frames per second to the WMV file, the WMV file will still play back at 30 frames per second.
The following example shows how to start and stop recording a WMV file:
CameraVideoRecording recording = Scene.Camera.VideoRecording; recording.StartRecording(directory, wmvFilename, CameraVideoFormat.WMV, 5000, 30); // ... recording.StopRecording();
The following example records a WMV file while animating:
CameraVideoRecording recording = Scene.Camera.VideoRecording; recording.StartRecording(directory, wmvFilename, CameraVideoFormat.H264, 5000, 30); AnimationPlayForward(); // ... AnimationPause(); recording.StopRecording();
The StartRecording(String, String, CameraSnapshotFileFormat, Int32, Int32) method begins recording a frame stack. With frame stacks, every rendered frame is saved to a separate image file. One would do this to record each raw uncompressed frame for use in a movie editor where the frames can be edited and output in any movie format at whatever compression.
The following code sample demonstrates frame stack recording:
CameraVideoRecording recording = Scene.Camera.VideoRecording; recording.StartRecording(frameStackDirectory, frameStackPrefix, CameraSnapshotFileFormat.Jpeg, 0, 2); // ... recording.StopRecording();
The frames can be saved in several different image formats, indicated by the CameraSnapshotFileFormat parameter. Each filename is made up of a prefix followed by a number defined in the method's input parameters. In the above example, each saved JPG file's name begins with frame_ followed by a 2 digit number beginning with 0. Make sure that the number of frame digits is large enough such that filenames do not repeat and overwrite each other.