This section introduces several modules which are useful in assembling OpenVIP networks.
The Concat
module is used to join two or more
input streams in a single output stream.
The following table lists the module's parameters in network file format.
Table 4.87. Concat parameters
Parameter | Values | Description | Required |
---|---|---|---|
count | positive integer | input modules count | yes |
type | audio, video, data | which stream to operate on | yes |
The parameter count
determines the number
of module's input connectors whose type is determined by the second
parameter. The module has a single output connector which is of the same
type as the input connectors.
The input streams must have the same properties, i.e. dimensions and FPS in case of video streams, sample rate and number of channels in case of audio streams. Otherwise you have to process them with filters such as Resize, Resample, Number of channels or modules such as FPSChanger before using Concat.
Imagine you have two input files input1.avi
and input2.avi
of size 640x480 with 24 fps and
stereo audio sampled at 44.1 kHz. The following network joins them in a
single output called output.avi
; the two clips are
separated using a 5 seconds long pause produced by NullGenerator.
<?xml version="1.0" ?> <!DOCTYPE network PUBLIC "-//OPENVIP//DTD Network Format V1.0//EN" "http://openvip.sourceforge.net/dtds/openvip-network.dtd"> <network xmlns="http://openvip.sourceforge.net/network-format" version="1.0"> <module id="loader1" class="Input"> <param name="filename">input1.avi</param> </module> <module id="loader2" class="Input"> <param name="filename">input2.avi</param> </module> <module id="nullgen_video" class="NullGenerator"> <param name="type">video</param> <param name="length">5</param> <param name="frame_width">640</param> <param name="frame_height">480</param> <param name="fps">24</param> <param name="aspect_ratio">1</param> </module> <module id="nullgen_audio" class="NullGenerator"> <param name="type">audio</param> <param name="length">5</param> <param name="samplerate">44100</param> <param name="channels">2</param> </module> <module id="concat_video" class="Concat"> <param name="type">video</param> <param name="count">3</param> </module> <module id="concat_audio" class="Concat"> <param name="type">audio</param> <param name="count">3</param> </module> <module id="saver" class="Output"> <param name="filename">output.avi</param> <param name="format">FFMpeg</param> </module> <connect module_in="loader1" conn_in="video0" module_out="concat_video" conn_out="video0"/> <connect module_in="nullgen_video" conn_in="video0" module_out="concat_video" conn_out="video1"/> <connect module_in="loader2" conn_in="video0" module_out="concat_video" conn_out="video2"/> <connect module_in="loader1" conn_in="audio0" module_out="concat_audio" conn_out="audio0"/> <connect module_in="nullgen_audio" conn_in="audio0" module_out="concat_audio" conn_out="audio1"/> <connect module_in="loader2" conn_in="audio0" module_out="concat_audio" conn_out="audio2"/> <connect module_in="concat_video" conn_in="video0" module_out="saver" conn_out="video0"/> <connect module_in="concat_audio" conn_in="audio0" module_out="saver" conn_out="audio0"/> </network>
The FPSChanger
module is used on an existing
video stream to change their FPS.
The following table lists the module's parameters in network file format.
Table 4.88. FPSChanger parameters
Parameter | Values | Description | Required |
---|---|---|---|
fps | positive real number | output stream FPS | no |
output_length | positive integer | number of frames in the output stream | no |
It is necessary to specify exactly one of the two parameters. The second one is calculated using the formula output_length=(fps/input_fps)*input_length, where input_length and input_fps are properties of the input stream.
The NullGenerator
module produces an empty
stream (i.e. black video frames or silence).
The following table lists the module's parameters in network file format.
Table 4.89. NullGenerator parameters
Parameter | Values | Description | Required |
---|---|---|---|
type | audio, video | which stream to produce | yes |
length | positive real number | length of output (in seconds) | yes |
The module has always a single output connector and no input connectors.
The value of type
can be either
video
or audio
. Depending on this
value you have to specify one of the two groups of parameters:
Table 4.90. Additional parameters for video
Parameter | Values | Description | Required |
---|---|---|---|
frame_width | positive integer | frame width | yes |
frame_height | positive integer | frame height | yes |
fps | positive real number | frames per second | yes |
aspect_ratio | positive real number | aspect ratio | yes |
frame_format | integer | internal frame format | no |
These parameters are self-explanatory except
frame_format
; it identifies the internal format
used by OpenVIP to store the data structure. For a list of possible
values see the file IVideoFrame.idl
.
Table 4.91. Additional parameters for audio
Parameter | Values | Description | Required |
---|---|---|---|
samplerate | positive integer | sample rate in Hz | yes |
channels | positive integer | number of audio channels | yes |
For an example see the Concat section.
The Overlay
module is used to paste
semi-transparent (alpha channel) images from one video stream over another
video stream.
The following table lists the module's parameters in network file format.
Table 4.92. Overlay parameters
Parameter | Values | Description | Required |
---|---|---|---|
static_overlay | boolean (0 or 1) | use only first frame from overlay stream? | no (default 0) |
x | integer | overlay x-position | no (default 0) |
y | integer | overlay y-position | no (default 0) |
The module has two input video connectors and a single output video connector. Video frames send to the second input connector are pasted over those from the first input connector; the blended image is then sent to the output.
The overlay clip and the background clip needn't have the same
dimensions; the position where the overlay is placed is governed by the
x
and y
parameters
(default setting corresponds to the upper left corner).
The overlay clip can be shorter than the background clip - the
last video frame from the overlay clip is then repeated. Switching
static_overlay
on causes that only the first
video frame from the overlay clip will be used.
Imagine you have a 50x50 logo called logo.png
which you want to paste to the upper right corner of your 640x480 clip
called input.avi
. The following network does the
job saving the output to
output.avi
.
<?xml version="1.0" ?> <!DOCTYPE network PUBLIC "-//OPENVIP//DTD Network Format V1.0//EN" "http://openvip.sourceforge.net/dtds/openvip-network.dtd"> <network xmlns="http://openvip.sourceforge.net/network-format" version="1.0"> <module id="loader1" class="Input"> <param name="filename">input.avi</param> </module> <module id="loader2" class="Input"> <param name="filename">logo.png</param> </module> <module id="overlay" class="Overlay"> <param name="x">590</param> </module> <module id="saver" class="Output"> <param name="filename">output.avi</param> <param name="format">FFMpeg</param> </module> <connect module_in="loader1" conn_in="video0" module_out="overlay" conn_out="video0"/> <connect module_in="loader2" conn_in="video0" module_out="overlay" conn_out="video1"/> <connect module_in="overlay" conn_in="video0" module_out="saver" conn_out="video0"/> <connect module_in="loader1" conn_in="audio0" module_out="saver" conn_out="audio0"/> </network>
The Subset
module is used to extract a
portion from an existing stream.
The following table lists the module's parameters in network file format.
Table 4.93. Subset parameters
Parameter | Values | Description | Required |
---|---|---|---|
type | audio, video, data | which stream to operate on | yes |
pos | positive real number | beginning of the selected block (in seconds) | yes |
length | positive real number | length of the selected block (in seconds) | yes |
The module has a single input connector and a single output
connector whose types are given by the first parameter. The output is
identical to the part of input stream which is specified by
pos
and length
parameters.
The following network takes first 15 seconds from file
input.avi
and saves them to
output.avi
.
<?xml version="1.0" ?> <!DOCTYPE network PUBLIC "-//OPENVIP//DTD Network Format V1.0//EN" "http://openvip.sourceforge.net/dtds/openvip-network.dtd"> <network xmlns="http://openvip.sourceforge.net/network-format" version="1.0"> <module id="loader" class="Input"> <param name="filename">input.avi</param> </module> <module id="subset_video" class="Subset" > <param name="type">video</param> <param name="pos">0</param> <param name="length">15</param> </module> <module id="subset_audio" class="Subset" > <param name="type">audio</param> <param name="pos">0</param> <param name="length">15</param> </module> <module id="saver" class="Output"> <param name="filename">output.avi</param> <param name="format">FFMpeg</param> </module> <connect module_in="loader" conn_in="video0" module_out="subset_video" conn_out="video0"/> <connect module_in="loader" conn_in="audio0" module_out="subset_audio" conn_out="audio0"/> <connect module_in="subset_video" conn_in="video0" module_out="saver" conn_out="video0"/> <connect module_in="subset_audio" conn_in="audio0" module_out="saver" conn_out="audio0"/> </network>