Flightgear on next has support for video encoding of the main window. This requires that ffmpeg/libav libraries are available at build time.
Videos are generated in the current directory. This can be changed by setting property /sim/video/directory.
- As of 2021-12-12, only Unix builds of Flightgear include support for video encoding.
- We do not (yet) record sound.
- Prior to 2021-12-19, fixed-dt only worked in SimpleTime mode (see menu File/Time Mode and/or property /sim/time/simple-time/enabled).
On Unix, we require these libraries and their header files to be available at build time:
If these libraries are installed, a standard cmake build should automatically include video encoding support.
As of 2021-12-27, download_and_compile.sh installs these libraries automatically.
On Devuan (and probably other Debian-based distributions), they can be manually installed with:
sudo apt install libavcodec-dev libavutil-dev libswscale-dev libavformat-dev
Creating video of live Flightgear
Starting/stopping video encoding
Use menu items File/Video Start and File/Video Stop to start/stop video encoding.
- Videos files are called fgvideo-<aircraft>-YYYYMMDD-HHMMSS.<container>, for example fgvideo-harrier-gr3-20211209-234105.mp4.
- A convenience link is created that points to the latest video, called fgvideo-<aircraft>.<container>, for example fgvideo-harrier-gr3.mp4 -> fgvideo-harrier-gr3-20211209-234105.mp4.
- If an error occurs, for example support for video encoding was not included at build time, Flightgear will show a popup warning message.
Video encoding settings
Menu File/Video Control opens a dialogue that allows control over various settings, including:
- Container name, such as mp4 or ogv.
- Radio buttons are provided for common containers.
- Run ffmpeg -formats in a separate terminal to see available containers.
- Codec name, such as mpeg2video, libx264, libx265.
- Radio buttons are provided for common codecs.
- Run ffmpeg -codecs in a separate terminal to see available codecs.
- Encoding quality in range 0..1. Use -1 for codec's default.
- Encoding speed in range 0..1. Use -1 for codec's default.
- Encoding target bitrate in bits per second. Use 0 for codec's default.
Creating video from Flightgear recordings
Flightgear can automatically generate a video when replaying a recording file, stopping video encoding when we reach the end of the recording.
Usually one would use a Continuous recording for this, as they contain full information regardless of the recording duration.
- From within Flightgear:
- In the Load Flight Recorder Tape dialogue, set the Auto-create video checkbox.
- Optionally also set Fixed dt (see below).
- With the command line --load-tape option:
- Also specify --load-tape-create-video.
- Optionally specify --load-tape-fixed-dt=... (see below).
Setting fixed-dt to a non-zero value forces Flightgear to increment the FDM time in seconds by the specified amount each frame, instead of by the elapsed real-world time between frames. For example using a value of 0.04 will force a frame rate of 25fps.
This allows creation of high quality videos from recordings, regardless of the rendering settings or speed of the host, at the expense of potentially taking longer than real time to replay the recording.
Command line examples
Create a high quality video of a recording by running Flightgear with these command-line args:
--load-tape=... --load-tape-create-video=1 --prop:bool:/sim/time/simple-time/enabled=true --load-tape-fixed-dt=0.04 --graphics-preset=high-quality
Also fix video settings by setting the relevant properties:
--load-tape=... --load-tape-create-video=1 --prop:bool:/sim/time/simple-time/enabled=true --load-tape-fixed-dt=0.04 --graphics-preset=high-quality --prop:/sim/video/container=mp4 --prop:/sim/video/codec=libx265 --prop:/sim/video/quality=0.75 --prop:/sim/video/speed=1
This 5 minute video flying around Manhattan with high rendering settings was created on a fairly slow laptop, taking about an hour to replay and encode: http://op59.net/fgvideo-harrier-gr3-20211206-230342-manhattan.mp4