Marine systems simulation
Screenshots, videos and camera control

Screen shots from FhVis

Add the following SimObject to your XML file:

<Lib LibName="base"
Simobject="CameraShot"
Time="15"
Name="Camera1"
FrameRate="6"
Filename="shot.jpg"
/>

and run FhSim. If no extension to the filename is specified, .jpg will be added automatically by fhSim. If desired, other formats may be specified, such as .tif or .png.

Recording video from FhVis

Add the following SimObject to your XML file and run FhSim. This will create a number of image files with file extension .tif.

<Lib LibName = "base"
Simobject = "CameraShot"
Time = "15"
Name = "Camera1"
Video = "1"
Stop = "100"
Filename = "video1.tif"
Framerate = "24"
Refinement = "1"
/>

Ensure that your visualization frame-rate is high enough (24fps is recommended), and that your maximum time-step is small enough (0.0045s or smaller is recommended).

Install ffmpeg from http://ffmpeg.org or ImageMagick, or use the version in the ImageMagick SDK. Join the image files by using ffmpeg, in the following form

ffmpeg -i img%d.png -r 30 -c:v libx264 -x264opts crf=20 video.avi

The options of the H.264 encoder is written in a colon separated list after the tag -x264opts. The crf option controls quality. This is to be set to a number from 1 (best quality and largest file) and up. 20-30 will typically give small files with sufficient quality. crf gives good control of the quality, but no control of the file size. If predictable file size is important, one may use the 'bit-rate' option instead, with the added option of two-pass encoding.

Further information on h264 encoder options: https://trac.ffmpeg.org/wiki/Encode/H.264

While h264 encoding gives the best quality for a given file size, not all players supports this codec. Most notably is the embedded player in Microsoft Powerpoint. Office can not play h264 video unless the codec is specifically installed, for instance the k-lite codec pack: http://codecguide.com/download_kl.htm

To generate a powerpoint compatible file use the following command:

ffmpeg -i img%d.png -r 30 -b:v 4096k video.avi

Video quality is controlled with the -b:v tag, currently set to 4096 kbps

Automatic control using a CameraTrajectoryPlayer

It is also possible to add a SimObject that controls the camera movement by moving it along a spline curve defined by a set of nodes containing (time,x,y,z,roll,pitch,yaw). More than one such SimObject can be defined in an XML file, but do not let the time intervals overlap. Note that the NumNodes attribute must be updated if more nodes are added, or they will be ignored!

The Type attribute is not used yet, but can be used in the future to specify other controls, such as following targets.

<OBJECTS>
<Lib LibName="base"
SimObject = "CameraTrajectoryPlayer"
Name = "CTP1"
Type = "SplinePosAngle"
NumNodes = "11"
/>
</OBJECTS>
<INTERCONNECTIONS>
<Connection
CTP1.Node1 = " 5, 0, 0, 0, 0, 0, 0"
CTP1.Node2 = " 15, -50, 0, 50, 0.1, -0.1, 0.2"
CTP1.Node3 = " 30, -100, 0, 80, 0.2, -0.1, 0.2"
CTP1.Node4 = " 60, -100, 0, 130, 0, 0, 0.2"
CTP1.Node5 = " 250, -100, 0, 130, 0, 0, 0.2"
CTP1.Node6 = " 350, -100, 0, 130, 0, 0, 0.2"
CTP1.Node7 = " 450, -240, 0, 130, 0, 0, 0.2"
CTP1.Node8 = " 600, -240, 0, 130, 0, 0, 0.2"
CTP1.Node9 = " 700, 0, 240, 100, 0, -0.2, -1.37"
CTP1.Node10 = " 1000, 0, 120, 115, 0, -0.2, -1.37"
CTP1.Node11 = " 1500, 0, 110, 114, 0, -0.3, -1.57"
/>
</INTERCONNECTIONS>