tinySceneGraph Home Images Features

Creating video files from tsgEdit using ffmpeg plugin

Friends of tinySG,

ffmpeg plugin tinySG's image processor has the ability to dump images to disk after each processing stage or filter. Originally designed for debugging purposes, a new plugin to tsgEdit utilises this feature to create video files of tinySG scenes. The plugin drives a standard ffmpeg command line encoder and provides a graphical interface to it's most important options.

In order to create a video, just enable the capture feature of the image processor. This will save each rendered frame into a directory on your disk even if there are no active image filters. To avoid render delays caused by disk I/O, rendered frames are pushed to a queued, which is consumed by another write-to-disk thread.

Once the image series is saved to disk, use the video plugin to select framerate, video format and size and let ffmpeg assemble the captured frames into a video file. Stdin and stdout of ffmpeg.exe are redirected to tsgEdit so that the output appears inside the plugins log viewer.

Although ffmpeg could do the job even without intermediate saving to disk, this approach avoids any code dependencies and is pretty flexible, supporting all command line options provided by ffmpeg.



Clock control

tsgEdit implements several modes to control rendering: ffmpeg plugin
  • Render on demand: The next frame is started as soon something relevant to the scene changes. As a consequence, if nothing changes, no new frames are generated.
  • Continuous rendering: tsgEdit renders as fast as possible.
  • Fixed framerate rendering: This mode is probably the most useful mode for creating video files and recording animations. It decouples the realtime clock from the frame timestamps. Each frame is set to a timestamp, maintaining a constant time interval between frames.
The plugin will intercept the output of ffmpeg and display it in it's own log window. On Linux, this is done via popen, while the windows implementation is slightly more complicated (see msdn on how to do this).

tinySG volume rendering video tinySG ISS mpeg video tinySG anaglyphic ISS movie
Video showing tsgEdit rendering a MRT dataset. (avi, 320x200@10Hz, 4MB). Click image to view. Flight around the ISS. (mpeg, 320x200@20Hz, 15.2MB). Click image to view. Flight around the ISS rendered with anaglyph stereo (mpeg, 320x200@20Hz, 11.6MB). Click image to view.

In summary, this little plugin makes it easy to create all kinds of videos thanks to the power of ffmpeg. The actual code in tinySG is pretty small and very easy to understand and maintain. Once tinySG has an animation system as it's predecessor already had, videos could be created entirely by scripting, without the need of interactively moving the camera or adjust any scene settings.

Keep rendering,
Christian


Copyright by Christian Marten, 2012-2014
Last change: 08.06.2012