1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /><title>entrans</title><link rel="stylesheet" href="manual.css" type="text/css" /><link rev="made" href="mailto:mnauw@users.sourceforge.net" /><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><link rel="start" href="index.html" title="GStreamer Transcoding" /><link rel="up" href="package.html" title="Chapter 2. Package Documentation" /><link rel="prev" href="package.html" title="Chapter 2. Package Documentation" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="command"><strong>entrans</strong></span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="package.html"><< Previous</a> </td><th width="60%" align="center">Chapter 2. Package Documentation</th><td width="20%" align="right"> </td></tr></table><hr /></div><div class="refentry" lang="en" xml:lang="en"><a id="entrans"></a><div class="titlepage"></div><div class="refnamediv"><a id="name"></a><h2>Name</h2><p><span class="command"><strong>entrans</strong></span> — build and run GStreamer pipeline</p></div><div class="refsynopsisdiv"><a id="synopsis"></a><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">entrans</code> [OPTION...] {--} {PIPELINE-OPTION...}</p></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p>
3
<span class="command"><strong>entrans</strong></span> builds and runs a <a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> pipeline, primarily intended for
4
transcoding, encoding or recording purposes.
6
On the one hand, it is much like
7
<span class="citerefentry"><span class="refentrytitle"><span class="command"><strong>gst-launch</strong></span></span>(1)</span> in that it has no ambitions to go beyond command-line
8
(or script) driven processing.
10
On the other hand, it has quite a few enhancements that provide application-level
11
functionality sufficiently comfortable and suitable for
12
plain-and-simple (and robust) transcoding, encoding or recording
13
using the <a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> framework and plugins:
14
</p><div class="itemizedlist"><ul><li><p>
15
Pipeline to run can be specified manually, or can be built dynamically
16
based on inputstream and pipeline fragments
17
(see <a class="xref" href="entrans.html#operation" title="Operation">“Operation”</a>), which takes
18
care of most of the boilerplate (and of some pitfalls to watch out for
19
with transcoding pipelines, see also <a class="xref" href="entrans.html#muxing-pipelines" title="Muxing Pipelines">“Muxing Pipelines”</a>).
21
Provides some typically relevant (configurable) interesting info
22
regarding the pipeline (elements, properties, queues, …) and
23
caps flowing in pipeline.
25
Regular progress updates are provided.
27
Limited support for tag setting (whenever a
28
<code class="interfacename">TagSetter</code> is present).
30
Property configuration support; settings can be applied from what is
31
stored in a config file and there is also some custom support for
32
setting “<span class="quote">popular options</span>” (e.g. bitrate).
34
Last but not least (convenient), processing can be restricted to
35
specific portions of the input(stream) (mind <a class="xref" href="entrans.html#requirements" title="Requirements">“Requirements”</a>).
37
Graceful shutdown of processing at any time,
38
and still well-formed output as result
39
(mind <a class="xref" href="entrans.html#requirements" title="Requirements">“Requirements”</a>).
40
</p></li></ul></div><p>
41
Another (technical) difference is that it is written
42
in <a class="ulink" href="http://www.python.org/" target="_top">python</a>,
43
using the python bindings for the <a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> framework (gst-python),
44
which makes many of the enhancements much more comfortable to implement
45
and easy to adjust (to taste).
46
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="operation"></a><h2>Operation</h2><p>
47
As already alluded to above, <span class="command"><strong>entrans</strong></span> fundamentally operates
48
in one of the following ways, also loosely called modes:
49
</p><div class="itemizedlist"><ul><li><p><b>Raw mode. </b>
50
The pipeline to construct, run and manage is explictly given
51
manually (see <code class="option">--raw</code>).
52
On the one hand, this mode allows full freedom in
53
pipeline construction and can be great for diagnosing and
55
On the other hand, if this freedom is not properly used, all sorts
56
of things can go wrong (blocking, …) see <a class="xref" href="entrans.html#muxing-pipelines" title="Muxing Pipelines">“Muxing Pipelines”</a> and
57
<a class="xref" href="entrans.html#requirements" title="Requirements">“Requirements”</a> [do not even try to run in this mode if what is stated
58
there is not fully clear and understood].
59
For now, this mode is also required for performing
60
e.g. video-passthrough transcoding (perhaps more appropriately
61
called re-muxing in this case).
62
</p></li><li><p><b>Dynamic mode. </b>
63
<span class="emphasis"><em>decodebin</em></span>
64
is applied to the inputstream, which will
65
automagically provide all the streams present in the input in
66
their decoded raw (video, audio or other, e.g. text) form.
67
Each of these streams is then connected to an instance of a pipeline
68
(fragment) given by <code class="option">--video</code>, <code class="option">--audio</code>
69
or <code class="option">--other</code>, each typically containing filters and/or
70
encoder. An optional subsequent step is trying to connect this to an
71
appropriately selected muxer for the output.
72
</p></li></ul></div><p>
73
In any case, no (advanced) error processing or sane-ness checking
74
is performed on either pipeline or pipeline fragments.
75
As such, linking, negotiation or other matters can very well fail,
76
e.g. if fragments do not contain encoder elements that are compatible
77
with the muxer in question. It is also possible for some
78
parts of the pipeline to simply remain disconnected and
79
the corresponding stream being effectively discarded (this might
80
also be used as a feature ;-) ).
81
Reporting on any of these occurrences is of course done in as much
82
as the pipeline provides info on what is happening.
84
Though this may sound ominous, in practice, this comes down to
85
either things working out just nicely
86
or finding out about something going wrong in a more or less fast and
88
Having a look at <a class="xref" href="entrans.html#examples" title="Examples">“Examples”</a> should increases chances on the former
89
being the case, and should even provide enough for a jump-start based on some
90
<a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> experience.
92
Processing can be halted at any time by sending a <em class="parameter"><code>SIGINT</code></em>
93
or <em class="parameter"><code>SIGTERM</code></em> signal to <span class="command"><strong>entrans</strong></span>.
94
This will make <span class="command"><strong>entrans</strong></span> block the data-flow and send an end-of-stream event
95
through the pipeline to ensure graceful termination of streaming.
96
As such, it should be noted that termination may not occur instantly,
97
it might take a moment for things to “<span class="quote">run out</span>”
98
(particularly with some <span class="emphasis"><em>queue</em></span>s around).
100
If in rare cases this mechanism were to fail, sending such a signal
101
a second time will forego any attempts at graceful shutdown
102
and will make <span class="command"><strong>entrans</strong></span> end things the hard way with <span class="emphasis"><em>no</em></span>
103
guarantee on the output being <span class="emphasis"><em>fully</em></span> OK
104
(it will most likely not be) …
106
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
107
Due to the way the python interpreter handles signals,
108
even the above may not work if things are messed up <span class="emphasis"><em>seriously</em></span>,
109
e.g. when python interpreter is caught up somewhere in <a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> backend code.
110
This, however, has only been known to happen as a prelude
111
to finding some serious application bug or <a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> plugin/core bug.
112
Regardless, e.g. <em class="parameter"><code>SIGKILL</code></em> is then your friend …
114
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="options"></a><h2>Options</h2><p><span class="command"><strong>entrans</strong></span> accepts the options presented in the following sections,
115
most of which have shortname (one-letter) or longname forms.
116
The ordering of the options is not strict, and options can be single-valued
118
</p><div class="itemizedlist"><ul><li><p>
119
In the former case, which is the default unless otherwise
120
indicated below, only the value given last is retained.
121
In particular, this includes boolean options.
122
If such an option is given, the corresponding setting is turned “<span class="quote">on</span>”.
123
The setting can also be explictly turned “<span class="quote">off</span>”
124
by providing the corresponding
125
<code class="option">--no-<em class="replaceable"><code>longname</code></em></code> option.
127
Otherwise, for multi-valued options, all values given are taken into
129
In these cases, it may sometimes also be possible to pass several values per
130
single option occurrence, by comma-separating these values as indicated in each
131
such case below. This will typically be the case in those instances where there
132
can be no ambiguity since the supplied value does not include
133
“<span class="quote">free-text</span>”.
134
</p></li></ul></div><p>
135
</p><div class="variablelist"><dl><dt><span class="term"><code class="option">-h</code>, </span><span class="term"><code class="option">--help</code></span></dt><dd><p>Show a brief help message.</p></dd></dl></div><div class="refsect2" lang="en" xml:lang="en"><a id="pipeline-options"></a><h3>Pipeline options</h3><p>
136
At least one of the following options should be provided
137
following <code class="option">--</code> (in each case, see <span class="citerefentry"><span class="refentrytitle"><span class="command"><strong>gst-launch</strong></span></span>(1)</span> for
138
the syntax of <em class="replaceable"><code>pipeline-description</code></em>).
139
Clearly, as explained previously, the former option excludes
140
all of the latter ones.
141
</p><div class="variablelist"><dl><dt><span class="term">
142
<code class="option">--raw <em class="replaceable"><code>pipeline-description</code></em></code>
143
</span></dt><dd><p>Makes <span class="command"><strong>entrans</strong></span> run in raw mode, and provides
144
the complete pipeline for this mode of operation.
146
Again, this should be used with expertise and being aware of comments
147
in <a class="xref" href="entrans.html#muxing-pipelines" title="Muxing Pipelines">“Muxing Pipelines”</a> and <a class="xref" href="entrans.html#requirements" title="Requirements">“Requirements”</a>.
148
</p></dd><dt><span class="term"><code class="option">--video[<span class="optional">:<em class="replaceable"><code>streamnumber</code></em></span>]
149
<em class="replaceable"><code>pipeline-description</code></em></code></span></dt><dd><p>
150
<em class="replaceable"><code>pipeline-description</code></em>
151
describes a pipeline fragment for video data processing,
152
typically consisting of 0 or more filters followed by an encoder.
153
</p></dd><dt><span class="term"><code class="option">--audio[<span class="optional">:<em class="replaceable"><code>streamnumber</code></em></span>]
154
<em class="replaceable"><code>pipeline-description</code></em></code></span></dt><dd><p>Similar to <code class="option">--video</code>, except that it provides
155
a pipeline for (optionally) processing and encoding audio data.
156
</p></dd><dt><span class="term"><code class="option">--other[<span class="optional">:<em class="replaceable"><code>streamnumber</code></em></span>]
157
<em class="replaceable"><code>pipeline-description</code></em></code></span></dt><dd><p>Similar to the above options, except that it provides
158
a pipeline for (optionally) processing and/or encoding data
159
that does not fit in the above categories, e.g. subtitles.
160
</p></dd><dt><span class="term"><code class="option">--decoder
161
<em class="replaceable"><code>decoder-factory</code></em></code></span></dt><dd><p>Use <em class="replaceable"><code>decoder-factory</code></em> instead of
162
the default <span class="emphasis"><em>decodebin</em></span> to construct the decoding
163
part of the pipeline in dynamic mode (as mentioned earlier).
164
The given element should have compatible behaviour/signals
165
with <span class="emphasis"><em>decodebin</em></span>, such as for instance the
166
new experimental <span class="emphasis"><em>decodebin2</em></span>.
167
</p></dd></dl></div><p>
168
The above (partial) pipelines should typically have an encoder as last
169
element. In any case, it should best not be a generic element, as that
170
might cause confusion as to how to link to the muxer (see also
171
<a class="xref" href="entrans.html#muxing-pipelines" title="Muxing Pipelines">“Muxing Pipelines”</a>).
173
It is also possible to “<span class="quote">close</span>” any of the above
174
pipeline fragments by ending it with a sink element. In this case,
175
the resulting stream will not be muxed and each can
176
have independent output, e.g. streamed to a file.
177
As each of these would evidently need to have distinct names,
178
there is (extremely) limited support for variable substitutions.
179
Each (video and audio) stream that dynamically becomes available is
180
(independently) numbered, starting from 1, and as such
181
assigned an (audio or video) stream number.
182
Any element property of type <span class="type">string</span> will be
183
subject to having <code class="literal">${vn}</code>, <code class="literal">${an}</code>
184
and <code class="literal">${on}</code> replaced by the video, audio and other
185
stream number (at that time) respectively in video, audio or other
187
If any of the above have a <em class="replaceable"><code>streamnumber</code></em> appended,
188
then that fragment will only apply to that particular stream, otherwise
189
it will be the default fragment. If no specific or default fragment
190
has been provided for a particular stream, then that stream will be discarded.
191
This effect is similar to the use of <code class="option">--vn</code>, <code class="option">--an</code>
192
or <code class="option">--on</code> (see next section).
194
As an additional convenience, all (partial) pipelines passed to <span class="command"><strong>entrans</strong></span>
195
will perform a simple form of glob-expansion for raw video and
196
audio mimetypes in capsfilters. That is, e.g. <code class="literal">video/*</code>
197
will be expanded to raw video mimetypes
198
(also distributing properties if any, of course).
199
This allows e.g. for scaling without particular attention for what colorspace
200
may be in use at a particular stage.
201
</p></div><div class="refsect2" lang="en" xml:lang="en"><a id="io-options"></a><h3>Input/output options</h3><p>
202
The option in this section are only applicable
203
in dynamic mode, so incompatible with <code class="option">--raw</code>.
205
</p><div class="variablelist"><dl><dt><span class="term"><code class="option">-i <em class="replaceable"><code>uri</code></em></code>, </span><span class="term"><code class="option">--input <em class="replaceable"><code>uri</code></em></code></span></dt><dd><p>
206
Indicates the input source. If <em class="replaceable"><code>uri</code></em> is a
207
valid URI, then a proper source element will be selected, otherwise it is simply
208
taken as a (relative) path of an inputfile. If <em class="replaceable"><code>uri</code></em> is
209
<code class="literal">-</code>, then stdin will be used as input.
210
</p></dd><dt><span class="term"><code class="option">-o <em class="replaceable"><code>uri</code></em></code>, </span><span class="term"><code class="option">--output <em class="replaceable"><code>uri</code></em></code></span></dt><dd><p>
211
Indicates the output destination. If <em class="replaceable"><code>output</code></em> is a
212
valid URI, then a corresponding sink element is selected, otherwise
213
it is taken as a (relative) path of an outputfile
214
(output to stdout is not supported).
215
The (file)suffix of <em class="replaceable"><code>uri</code></em> is used to automagically
216
choose an appropriate muxer, which can be overridden with
217
<code class="option">--muxer</code>
218
</p></dd><dt><span class="term"><code class="option">--muxer <em class="replaceable"><code>mux-element</code></em></code></span></dt><dd><p>
219
Use <em class="replaceable"><code>mux-element</code></em> in stead of the automatically
220
selected one, or if one fails to be auto-selected.
221
<em class="replaceable"><code>mux-element</code></em> must be of <code class="literal">Muxer</code> class.
222
</p></dd></dl></div><p>
224
As mentioned in the previous section, all streams found in the input are
225
assigned a stream number and considered for processing, unless somehow
226
restricted by the following options.
228
</p><div class="variablelist"><dl><dt><span class="term"><code class="option">--vn <em class="replaceable"><code>streamnumber[<span class="optional">,…</span>]</code></em></code>, </span><span class="term"><code class="option">--an <em class="replaceable"><code>streamnumber[<span class="optional">,…</span>]</code></em></code>, </span><span class="term"><code class="option">--on <em class="replaceable"><code>streamnumber[<span class="optional">,…</span>]</code></em></code></span></dt><dd><p>
229
[multi-valued] Only the video, audio or other streams with (respectively) listed
230
<em class="replaceable"><code>streamnumber</code></em> will be considered, others disregarded.
231
Furthermore, streams of each type will be muxed into the target in the order
232
in which their <em class="replaceable"><code>streamnumber</code></em>s are given in these options,
233
and in overall first video, then audio and others.
234
</p></dd><dt><span class="term"><code class="option">--sync-link</code></span></dt><dd><p>
235
This option is mainly meant for testing and diagnostic purposes.
236
It basically disables the stream(re)-ordering mechanism as implied by and
237
explained in the above option (though still retains stream selection).
238
</p></dd><dt><span class="term"><code class="option">--at <em class="replaceable"><code>tag[<span class="optional">,…</span>]</code></em></code></span></dt><dd><p>
239
[multi-valued] Audio streams can (though need not) be accompanied by a language tag
240
(typically a 2- or 3-letter language code). The regular expression
241
<em class="replaceable"><code>tag</code></em>
242
is matched against each detected audio stream's language tag and only
243
streams without language tag or streams with a matching language tag are
244
processed, others disregarded. This selection method <span class="emphasis"><em>cannot</em></span>
245
be combined with the above streamnumber based selection.
247
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> The current (or another?) method of
248
implementing this selection may very well not work with all muxer elements. As
249
such, this option can be given a try, but if not successful, the much more
250
robust <code class="option">--an</code> should be used instead. The proper
251
number(s) to use for this may be derived from (ordered) tag information that is
252
provided by some elements and reported at start-up.
254
</p></dd><dt><span class="term"><code class="option">--stamp</code></span></dt><dd><p>
255
This is enabled by default, and makes <span class="command"><strong>entrans</strong></span> insert an <a class="ulink" href="http://www.gstreamer.net/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-identity.html" target="_top"><span class="emphasis"><em>identity</em></span></a> element
256
(with single-segment True) before the connected pipeline-fragment
257
to perform timestamp re-sequencing. This is typically useful when
258
muxing into a format that records timestamps (and does not hurt
259
when the format does not).
260
</p></dd></dl></div><p>
261
</p></div><div class="refsect2" lang="en" xml:lang="en"><a id="basic-options"></a><h3>Basic options</h3><p>
262
Whereas no specific dependencies exist for all other options,
263
the <a class="xref" href="entrans.html#requirements" title="Requirements">“Requirements”</a> section applies particularly
264
to the following options (in more or less degree).
265
</p><div class="variablelist"><dl><dt><span class="term"><code class="option">-c
266
<em class="replaceable"><code>[<span class="optional">[<span class="optional">(</span>]<em class="replaceable"><code>format</code></em>[<span class="optional">)</span>]:</span>]t1-t2[<span class="optional">,…</span>]</code></em></code>, </span><span class="term"><code class="option">--cut
267
<em class="replaceable"><code>[<span class="optional">[<span class="optional">(</span>]<em class="replaceable"><code>format</code></em>[<span class="optional">)</span>]:</span>]t1-t2[<span class="optional">,…</span>]</code></em></code></span></dt><dd><p>
269
Only process the indicated sections of the pipeline (by default the complete
270
input is processed). The option <code class="option">-s</code> determines the method used
271
for selecting the desired data.
273
If no <em class="replaceable"><code>format</code></em> is provided,
274
the <em class="replaceable"><code>tN</code></em> parameters can be given in timecode format
275
HH:MM:SS.FRACTION or as a (video)framenumber, which is a number following
276
<code class="literal">f</code> or <code class="literal">F</code>. Any buffer that
277
overlaps with the indicated section is taken into account. The last indicated
278
section may be open-ended, i.e. the end point may be omitted.
281
However, if <em class="replaceable"><code>format</code></em> is the nickname of a pre-defined
282
or custom format (defined by some element in the pipeline), then it is used as
283
unit for the <em class="replaceable"><code>tN</code></em> numbers.
284
In this case, option <code class="option">-s</code> below must select a seek-based method,
285
and the seek will be executed in <em class="replaceable"><code>format</code></em> if it is provided
286
without matching (…), otherwise the given units will be (query) converted
287
to time format first, and these results will be used to seek in time.
288
</p></dd><dt><span class="term"><code class="option">-s <em class="replaceable"><code>method</code></em></code>, </span><span class="term"><code class="option">--section <em class="replaceable"><code>method</code></em></code></span></dt><dd><p>
289
Possible choices for <em class="replaceable"><code>method</code></em> are:
290
</p><div class="variablelist"><dl><dt><span class="term"><code class="literal">seek</code></span></dt><dd><p>
291
Sections are selected by means of regular <a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> seeks.
292
A flushing seek is performed for the first section,
293
segment seek for the others, and a normal seek for the last section.
294
This is also the default method and is OK for most circumstances.
295
In some cases, however, the other methods may be in order,
296
e.g. when (the driving element in) the pipeline does not support
297
some type of seek that would be used.
298
</p></dd><dt><span class="term"><code class="literal">seek-key</code></span></dt><dd><p>
299
This is similar to the case above, but each seek is also a keyframe seek,
300
that is, the actual selection may not be exactly the one
301
that was requested but may start at the nearest keyframe
302
preceding the desired start.
303
This would typically be required when performing re-muxing
304
without fully decoding and re-encoding the material.
305
</p></dd><dt><span class="term"><code class="literal">cut-time</code></span></dt><dd><p>
306
In this case, the pipeline is run from the start (without any seeks)
307
and all but the desired sections are disregarded.
308
The decision whether or not to drop a piece of data is based on its timestamp.
309
This is the recommended (only possible) method to use
310
when performing A/V sync correction using data-timestamp shifting,
311
e.g. by means of the <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-shift.html" target="_top"><span class="emphasis"><em>shift</em></span></a> element. It can also be used
312
to end a live source(s) driven pipeline after a specified duration.
313
</p></dd><dt><span class="term"><code class="literal">cut</code></span></dt><dd><p>
314
This method applies in case any/all of the above fail, e.g. some element
315
does not support seek or unreliable timestamps are produced in the pipeline.
316
No seeks or anything special is done, the pipeline is run from the start and all but the
317
indicated sections is dropped. Timestamps on the datastream are disregarded,
318
and the incoming data is restamped based on framecount and framerate
319
(video), or on sample count and samplerate (audio).
320
In particular, audio cutting is performed up to sample precision.
321
</p></dd></dl></div><p>
322
Note that the last 2 methods require the desired sections to be in ascending
323
order, whereas the former methods make it possible to select sections
324
that are out-of-order with regards to the input material.
325
</p></dd><dt><span class="term"><code class="option">-a</code></span></dt><dd><p>
326
Perform (audio) sample precision selection, that is, it is possible for only parts of
327
buffers to be passed or dropped. This is done by default
328
in the <code class="literal">cut</code> method above, but not for the other methods.
329
</p></dd><dt><span class="term"><code class="option">--dam</code></span></dt><dd><p>
330
Indicate, or rather, confirm that <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> elements are being used
331
in <span class="emphasis"><em>raw</em></span> pipelines.
332
Otherwise, “<span class="quote">surrogate dam</span>” elements will be searched for and used instead.
333
These are identified as elements whose name is of the form
334
<code class="literal">dam<em class="replaceable"><code><digits></code></em></code>.
335
</p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>framerate</code></em></code>, </span><span class="term"><code class="option">--framerate <em class="replaceable"><code>framerate</code></em></code></span></dt><dd><p>
336
The framerate that is used for framenumber to time conversion is normally
337
auto-detected (soon enough) within the pipeline. If this were not to succeed,
338
then <em class="replaceable"><code>framerate</code></em>,
339
specified as <em class="replaceable"><code>NUM[<span class="optional">/DENOM</span>]</code></em>,
340
is used as a fallback instead of the otherwise default 25/1.
341
</p></dd><dt><span class="term"><code class="option">-b</code>, </span><span class="term"><code class="option">--block-overrun</code></span></dt><dd><p>
342
This makes <span class="command"><strong>entrans</strong></span> prevent automatic adjustments to queues
343
(in a <span class="emphasis"><em>decodebin</em></span>), thereby keeping them at fixed size.
345
Despite all the automagic, the pipeline may stall in exotic cases
346
(e.g. some strange behaving element/muxer, …). A good first thing to try
347
then is to configure queues at a larger-than-default setting (see for example
348
following section) and to use this option to ensure they really remain
349
configured as intended without any other influence.
350
</p></dd></dl></div><p>
351
</p></div><div class="refsect2" lang="en" xml:lang="en"><a id="pipe-config-options"></a><h3>Pipeline configuration</h3><p>
352
Although element properties are typically set in the pipeline descriptions,
353
the following options can be useful for dynamically created elements (see for
354
instance the dvd example in <a class="xref" href="entrans.html#examples" title="Examples">“Examples”</a>) or when it is desired to configure a property
355
syntactically separated from the pipeline on the command line.
357
</p><div class="variablelist"><dl><dt><span class="term"><code class="option">--set-prop
358
<em class="replaceable"><code>
359
element:prop:value[<span class="optional">:time</span>]
361
</code></span></dt><dd><p>
362
Sets property <em class="replaceable"><code>prop</code></em> of
363
<em class="replaceable"><code>element</code></em> to <em class="replaceable"><code>value</code></em>,
364
where <em class="replaceable"><code>element</code></em> can either be an element-type, or the
365
name or full path-string of a specific element.
366
If <em class="replaceable"><code>prop</code></em> is a <code class="literal">GST_CONTROLLABLE</code>
367
property (use <span class="citerefentry"><span class="refentrytitle"><span class="command"><strong>gst-inspect</strong></span></span>(1)</span> to determine this),
368
then a (pipeline media) <em class="replaceable"><code>time</code></em> at which
369
<em class="replaceable"><code>prop</code></em>
370
should be set to this particular <em class="replaceable"><code>value</code></em>
371
(using the controller framework) can be given as well.
373
In general, a value given for a property within the pipeline description
374
will override any value provided this way. In case of <span class="emphasis"><em>queue</em></span>s,
375
however, both <span class="emphasis"><em>decodebin</em></span> and <span class="command"><strong>entrans</strong></span> will override some
376
properties' values in order to minimize the possibility of blocking.
377
Though it is not recommended, <code class="option">set-prop</code> can be used
378
to forcibly overwrite such aforementioned defaults.
380
The rank of an element (as a plugin feature), which (a.o.) determines whether or
381
not it is considered for auto-plugging (in dynamic mode) is considered
382
as a pseudo-property <code class="literal">pf_rank</code> and can therefore be set
384
</p></dd><dt><span class="term"><code class="option">--vb <em class="replaceable"><code>vkbitrate</code></em></code>, </span><span class="term"><code class="option">--ab <em class="replaceable"><code>akbitrate</code></em></code></span></dt><dd><p>
385
Sets the <code class="literal">bitrate</code> property of any video or audio element to
386
<em class="replaceable"><code>vkbitrate</code></em> [<span class="optional"> * 1000</span>] or
387
<em class="replaceable"><code>akbitrate</code></em> [<span class="optional"> * 1000</span>] respectively,
388
depending on whether the property expects to be provided with (k)bitrate.
389
</p></dd><dt><span class="term"><code class="option">--vq <em class="replaceable"><code>vquality</code></em></code>, </span><span class="term"><code class="option">--aq <em class="replaceable"><code>aquality</code></em></code></span></dt><dd><p>
390
Sets either the <code class="literal">quality</code> or <code class="literal">quantizer</code>
391
property of any video or audio element to <em class="replaceable"><code>vquality</code></em> or
392
<em class="replaceable"><code>aquality</code></em> respectively.
394
</p></dd><dt><span class="term"><code class="option">--pass <em class="replaceable"><code>pass</code></em></code></span></dt><dd><p>
395
Sets the <code class="literal">pass</code> property of any video element to
396
<em class="replaceable"><code>pass</code></em>, which
397
must be <code class="literal">1</code> or <code class="literal">2</code>.
398
</p></dd><dt><span class="term">
399
<code class="option">-t <em class="replaceable"><code>tag:value</code></em>
403
<span class="command"><strong>entrans</strong></span> locates a <code class="interfacename">TagSetter</code> in
404
the pipeline and sets each given <em class="replaceable"><code>tag</code></em> to
405
<em class="replaceable"><code>value</code></em>.
407
A list of possible tags can be found in
408
<a class="ulink" href="http://www.gstreamer.net/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstTagList.html" target="_top">GStreamer core documentation</a>.
409
</p></dd></dl></div><p>
410
</p></div><div class="refsect2" lang="en" xml:lang="en"><a id="reporting-options"></a><h3>Reporting options</h3><p>
411
By default, <span class="command"><strong>entrans</strong></span> reports the following items at startup:
412
</p><div class="itemizedlist"><ul compact="compact"><li><p>
413
an overview of elements found in the pipeline,
414
along with the current values of properties that differ from their
415
usual (default) setting;
416
tags announced by an element are considered as a pseudo-property
417
<code class="literal">tag</code> of the element
419
a set of distinct caps that have been found flowing through the pipeline,
421
the (video) queues found in the pipeline (with their neighbours),
422
and their maximum capacity settings (size, buffers, time)
423
</p></li></ul></div><p>
424
After that, it provides the following in regular intervals, if already available
426
</p><div class="itemizedlist"><ul compact="compact"><li><p>
427
(time) position in input stream,
429
movie time: position in output stream, and the total expected output movie time
431
processing speed: ratio of elapsed (input) stream time to elapsed CPU time
433
ETA: expected time to completion of processing;
434
this calculation <span class="emphasis"><em>always</em></span> uses elapsed system clock time,
435
regardless of options below,
437
amount of buffers presently contained in the queues reported at startup,
439
if a specific output file can be identified, (combined) bitrate so far.
440
</p></li></ul></div><p>
442
The following options can influence some of this behaviour:
443
</p><div class="variablelist"><dl><dt><span class="term"><code class="option">-d <em class="replaceable"><code>delay</code></em></code>, </span><span class="term"><code class="option">--delay <em class="replaceable"><code>delay</code></em></code></span></dt><dd><p>
444
Sets the interval between progress updates to <em class="replaceable"><code>delay</code></em>
445
seconds. The default delay is 2 seconds.
446
</p></dd><dt><span class="term"><code class="option">--timeout <em class="replaceable"><code>timeout</code></em></code></span></dt><dd><p>
447
As an <span class="command"><strong>entrans</strong></span> run spins up, it transitions through a number of stages, which
448
should normally follow each other in pretty rapid succession.
449
<em class="replaceable"><code>timeout</code></em>, by default 4, is the maximum interval
450
(in seconds) that will be allowed between such stages. If the interval is exceeded,
451
<span class="command"><strong>entrans</strong></span> may simply abort altogether or try to recover the situation
452
(depending on the stage), the success of which depends on the cause
453
(e.g. a misbehaving element, or a badly constructed pipeline, …).
454
Evidently, a high <em class="replaceable"><code>timeout</code></em> value essentially renders
455
this check mute. Setting it to 0 completely disables this check as well
456
as some other mechanisms employed to support it, and is not normally advisable.
457
</p></dd><dt><span class="term"><code class="option">--progress-fps</code></span></dt><dd><p>
458
Makes regular reports also provide processing speed in fps, which is calculated
459
using either auto-detected framerate or provided by <code class="option">-f</code>.
460
</p></dd><dt><span class="term"><code class="option">--progress-real</code></span></dt><dd><p>
461
Calculate processing speed based on elapsed system clock time (instead of CPU-time).
462
</p></dd></dl></div><p>
464
In the following, <em class="replaceable"><code>proppattern</code></em>
465
is a regular expression that will be matched a combination of
466
an <em class="replaceable"><code>element</code></em> and (optionally) one its properties
467
<em class="replaceable"><code>prop</code></em>. More precisely, this combination
468
matches if the regular expression matches any of the following:
469
</p><div class="itemizedlist"><ul compact="compact"><li><p>
470
<em class="replaceable"><code>element's factory name</code></em>.<em class="replaceable"><code>prop</code></em>
472
<em class="replaceable"><code>element's name</code></em>.<em class="replaceable"><code>prop</code></em>
474
<em class="replaceable"><code>element's path name</code></em>.<em class="replaceable"><code>prop</code></em>
475
</p></li></ul></div><p>
476
In each case, the last part is omitted if there is no
477
<em class="replaceable"><code>prop</code></em> in the context in question.
479
Similarly, <em class="replaceable"><code>msgpattern</code></em> is matched against
480
expressions as above, but with <em class="replaceable"><code>prop</code></em> replaced by
481
<em class="replaceable"><code>message type name</code></em>.<em class="replaceable"><code>message structure name</code></em>
482
Again, in each case, the last part is omitted if there is no structure for the
484
</p><div class="variablelist"><dl><dt><span class="term"><code class="option">-m</code></span></dt><dd><p>
485
Output messages posted on the pipeline's bus
486
</p></dd><dt><span class="term"><code class="option">-v</code></span></dt><dd><p>
487
Provide output on property changes of the pipeline's elements.
488
This output can be filtered using <code class="option">-x</code>
489
</p></dd><dt><span class="term"><code class="option">--short-caps</code></span></dt><dd><p>
490
Do not perform complete caps to string conversion, instead replace e.g. buffers
491
with their (string) type representation.
492
This can make for more comfortable display of e.g. Vorbis and Theora related caps.
493
</p></dd><dt><span class="term">
494
<code class="option">--ignore-msg <em class="replaceable"><code>msgpattern[<span class="optional">,…</span>]</code></em>
496
, </span><span class="term">
497
<code class="option">--display-msg <em class="replaceable"><code>msgpattern[<span class="optional">,…</span>]</code></em>
500
[multi-valued] If message reporting is enabled by <code class="option">-m</code>,
501
only report on those that match <code class="option">--display-msg</code>
502
or do not match <code class="option">--ignore-msg</code>
503
</p></dd><dt><span class="term">
504
<code class="option">-x <em class="replaceable"><code>proppattern[<span class="optional">,…</span>]</code></em>
506
, </span><span class="term">
507
<code class="option">--exclude <em class="replaceable"><code>proppattern[<span class="optional">,…</span>]</code></em>
509
, </span><span class="term">
510
<code class="option">--include <em class="replaceable"><code>proppattern[<span class="optional">,…</span>]</code></em>
513
[multi-valued] If property change reporting is enabled by <code class="option">-v</code>,
514
only report those on properties that match <code class="option">--include</code>
515
or do not match <code class="option">--exclude</code>
516
</p></dd><dt><span class="term">
517
<code class="option">--display-prop <em class="replaceable"><code>proppattern[<span class="optional">,…</span>]</code></em>
519
, </span><span class="term">
520
<code class="option">--ignore-prop <em class="replaceable"><code>proppattern[<span class="optional">,…</span>]</code></em>
523
[multi-valued] An element's property (value) is reported at start-up if and only if
524
it matches an expression given in <code class="option">--display-prop</code>
525
or its value differs from the usual and it does not match
526
<code class="option">--ignore-prop</code>.
527
Also, in any case, an element's presence in the pipeline is at least
528
mentioned by default, unless the element (by itself) matches
529
<code class="option">--ignore-prop</code>
530
</p></dd></dl></div></div><div class="refsect2" lang="en" xml:lang="en"><a id="config-options"></a><h3>Configuration options</h3><p>
531
Each <span class="command"><strong>entrans</strong></span> option —be it one affecting <span class="command"><strong>entrans</strong></span>'
532
run-time behaviour or affecting pipeline element (properties)—
533
can also be provided on a more permanent basis using a configuration
536
Such a file consists of sections, led by
537
a “<span class="quote"><code class="literal">[section]</code></span>” header and
538
followed by “<span class="quote"><code class="literal">name: value</code></span>” entries,
539
“<span class="quote"><code class="literal">name=value</code></span>” is also accepted.
540
Note that leading whitespace is removed from values.
541
Lines beginning with “<span class="quote"><code class="literal">#</code></span>” or
542
“<span class="quote"><code class="literal">;</code></span>” are ignored and may be used to
545
In the special section “<span class="quote"><code class="literal">[options]</code></span>”,
546
each entry “<span class="quote"><code class="literal">name: value</code></span>”
547
is equivalent to providing <code class="option">--<em class="replaceable"><code>name</code></em>
548
<em class="replaceable"><code>value</code></em></code> on the command-line,
549
where <em class="replaceable"><code>name</code></em> must be an option's longname.
551
The name of any other section is interpreted as an element-type
552
or an element, with each entry providing a value for a property.
553
Otherwise put, each “<span class="quote"><code class="literal">prop: value</code></span>”
555
“<span class="quote"><code class="literal">[<em class="replaceable"><code>element</code></em>]</code></span>”
556
is equivalent to mentioning it in <code class="option">--set-prop</code> as
557
<em class="replaceable"><code>element:prop:value</code></em>
559
By default, the configuration file is called <code class="filename">.gst-entrans</code>
560
and is searched for in the current directory and in the user's home directory
563
Any setting provided on the command line for a single-valued option
564
(e.g. a boolean option) overrides a similar value given in a configuration file,
565
whereas values provided for multi-valued ones append to those already provided.
566
</p><div class="variablelist"><dl><dt><span class="term"><code class="option">--config <em class="replaceable"><code>file</code></em></code></span></dt><dd><p>
567
Use <em class="replaceable"><code>file</code></em> <span class="emphasis"><em>instead</em></span> of any
568
default configuration file.
569
</p></dd><dt><span class="term"><code class="option">--profile <em class="replaceable"><code>file</code></em></code></span></dt><dd><p>
570
Load <em class="replaceable"><code>file</code></em> <span class="emphasis"><em>after</em></span> other
571
configuration files, either default ones or given by <code class="option">--config</code>.
572
This option derives its name from its use in loading certain export or
573
encoder profiles (e.g. MPEG1, MPEG2, etc),
574
which are mainly a collection of presets for certain properties that can
575
be kept in corresponding profile configuration files.
576
</p></dd></dl></div></div><div class="refsect2" lang="en" xml:lang="en"><a id="misc-options"></a><h3>Miscellaneous options</h3><div class="variablelist"><dl><dt><span class="term"><code class="option">--save
577
<em class="replaceable"><code>message:file[:append][<span class="optional">,…</span>]
579
</code></span></dt><dd><p>
581
Makes <span class="command"><strong>entrans</strong></span> save a custom element <em class="replaceable"><code>message</code></em> to
582
<em class="replaceable"><code>file</code></em>,
583
that is, the string representation of the message's structure is saved
584
(followed by a <span class="token">linefeed</span>).
585
If <em class="replaceable"><code>append</code></em> is true (e.g. <code class="literal">1</code>, <code class="literal">t</code>,
586
<code class="literal">T</code>), then all messages are appended to <em class="replaceable"><code>file</code></em>,
587
otherwise the default is to truncate <em class="replaceable"><code>file</code></em> whenever
588
<em class="replaceable"><code>message</code></em> is received, thereby saving only the
589
most recently received <em class="replaceable"><code>message</code></em>.
591
it might be noted here there was a change in version 0.10.15 in a structure's
592
string representation with respect to usage of a terminating <span class="token">;</span>.
594
<em class="replaceable"><code>file</code></em> will be subject to having <code class="literal">${n}$</code>
595
replaced by the name of the element sending <em class="replaceable"><code>message</code></em>.
596
</p></dd></dl></div></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="examples"></a><h2>Examples</h2><p>
597
More examples of pipelines can also be found in <span class="citerefentry"><span class="refentrytitle"><span class="command"><strong>gst-launch</strong></span></span>(1)</span>;
598
the ones below are primarily meant to illustrate some of
599
<span class="command"><strong>entrans</strong></span>' features.
601
In each case, everything could also be written on one line, without the backslash
602
character. In some cases, some particular quoting is needed to prevent
603
(mis)interpretation by the shell.
604
</p><div class="example"><a id="id527789"></a><p class="title"><b>Example 2.1. Basic transcoding</b></p><div class="example-contents"><p>
605
</p><pre class="programlisting">
606
entrans.py -i dvd://2 -o dvd.ogm --short-caps -- \
607
--video ! theoraenc --audio audioconvert ! vorbisenc
609
Transcodes complete title 2 from a DVD into a mixed Ogg containing all video
610
and audio tracks (but no subtitles) using default settings, while preventing
611
some extensive caps display.
612
</p></div></div><br class="example-break" /><div class="example"><a id="id527807"></a><p class="title"><b>Example 2.2. Selected stream transcoding</b></p><div class="example-contents"><p>
613
</p><pre class="programlisting">
614
entrans.py --set-prop dvdreadsrc:device:/mnt -i dvd://2 -o dvd.mkv \
615
--set-prop dvdsubdec:pf_rank:128 --on 6,12 --an 1,2 --vq 4 --ab 256 -- \
616
--video ffenc_mpeg4 --audio audioconvert ! lame \
617
--other ffmpegcolorspace ! ffenc_mpeg4 ! matroskamux ! filesink location='sub-${on}.mkv'
619
Transcodes video and selected audio tracks from a DVD image mounted at /mnt
620
into a Matroska file, using the indicated fixed quantization and bitrate for
621
video and audio respectively. Some selected subtitle tracks are also encoded
622
as separate video streams into other Matroska files. Note that the rank of
623
the <span class="emphasis"><em>dvdsubdec</em></span> must be increased for a subtitle stream to be
624
considered for decoding and subsequently made available.
625
</p></div></div><br class="example-break" /><div class="example"><a id="id527833"></a><p class="title"><b>Example 2.3. Extensive progress update transcoding</b></p><div class="example-contents"><p>
626
</p><pre class="programlisting">
627
entrans.py -i example-in.avi -o example-out.mkv -- \
628
--video tee name=tee ! queue ! theoraenc \
629
tee. ! queue ! timeoverlay ! xvimagesink sync=false qos=false \
630
--audio audioconvert ! lame
632
Transcodes into Matroska using Theora and MP3 codecs, while providing for
633
(excessive) live preview progress info.
634
</p></div></div><br class="example-break" /><div class="example"><a id="id527851"></a><p class="title"><b>Example 2.4. Partial stream transcoding</b></p><div class="example-contents"><p>
635
</p><pre class="programlisting">
636
entrans.py -i dvd://2 -o dvd.mkv -c chapter:5- --short-caps -- \
637
--video ! identity single-segment=true ! ffenc_mpeg4 \
638
--audio audioconvert ! identity single-segment=true ! vorbisenc
640
Transcodes all video and audio tracks from a DVD title 2 (chapter 5 to the end)
641
into Matroska using MPEG4 and Vorbis codecs (while catering for properly
642
timestamped input for the container which records these faithfully for posterity).
643
</p></div></div><br class="example-break" /><div class="example"><a id="ex-pass-through"></a><p class="title"><b>Example 2.5. Pass-through transcoding</b></p><div class="example-contents"><p>
644
</p><pre class="programlisting">
645
entrans.py -s seek-key -c 60-180 --dam -- --raw \
646
filesrc location=example-in.avi ! avidemux name=demux \
647
avimux name=mux ! filesink location=example-out.avi \
648
demux.video_00 ! queue ! dam ! queue ! mux.video_0 \
649
demux.audio_00 ! queue ! dam ! queue ! mad ! audioconvert ! lame ! mux.audio_0
651
Transcodes a particular section from an AVI file into another AVI file without
652
re-encoding video (but does re-encode audio, which is
653
recommended). The output will range from (approximately) 60 seconds into the
654
input up to 180 seconds; actually there will be a (key)seek to the nearest
655
keyframe just before the 60 seconds point to ensure the integrity of later
656
decoding of the output.
657
In addition, <span class="command"><strong>entrans</strong></span> will report changes on any object's properties, except
658
for any (pad's) caps.
660
The pipeline above uses raw mode, and as such must abide
661
by some rules and recommendations in pipeline building (see <a class="xref" href="entrans.html#muxing-pipelines" title="Muxing Pipelines">“Muxing Pipelines”</a>),
662
which leads in particular to the above abundance in <span class="emphasis"><em>queue</em></span>s.
663
With some extra configuration, pass-through could also be performed in
664
dynamic mode as follows (assuming that <code class="literal">video/mpeg</code> properly
665
describes the encoded video content):
666
</p><pre class="programlisting">
667
entrans.py -s seek-key -c 60-180 --decoder decodebin2 \
668
--set-prop 'decodebin2:caps:video/mpeg;audio/x-raw-int;audio/x-raw-float' \
669
-i example-in.avi -o example-out.avi -- \
670
--video capsfilter caps=video/mpeg \
671
--audio audioconvert ! lame
673
</p></div></div><br class="example-break" /><div class="example"><a id="id527928"></a><p class="title"><b>Example 2.6. Live recording</b></p><div class="example-contents"><p>
674
</p><div class="informalexample"><pre class="programlisting">
675
entrans.py -s cut-time -c 0-60 -v -x '.*caps' --dam -- --raw \
676
v4l2src queue-size=16 ! video/x-raw-yuv,framerate=25/1,width=384,height=576 ! \
677
stamp sync-margin=2 silent=false progress=0 ! queue ! \
678
dam ! ffenc_mpeg4 name=venc \
679
alsasrc buffer-time=1000000 ! audio/x-raw-int,rate=48000,channels=1 ! queue ! \
680
dam ! audioconvert ! queue ! lame name=aenc \
681
avimux name=mux ! filesink location=rec.avi aenc. ! mux. venc. ! mux.
683
Records 1 minute of video and audio from a video4linux device and features
684
additional synchronization and reporting on object property changes (if any),
685
which includes reports on frame drops or duplications, although
686
(pad's) caps changes are excluded for convenience.
687
</p></div></div><br class="example-break" /><div class="example"><a id="id527953"></a><p class="title"><b>Example 2.7. 2-pass transcoding</b></p><div class="example-contents"><p>
688
</p><pre class="programlisting">
689
entrans.py -i example-in.avi -o /dev/null --muxer avimux --vb 1200 --pass 1 \
690
--save astat:astat.log -- --video ffenc_mpeg4 \
691
--audio audioconvert ! astat ! fakesink
692
SCALE="$(cat astat.log | sed 's/astat, scale=(double)//' | sed 's/;//')"
693
entrans.py -i example-in.avi -o example-out.avi --vb 1200 --pass 2 \
694
--tag 'comment:2-pass demonstration' -- \
695
--video ffenc_mpeg4 --audio audioconvert ! volume volume=$SCALE ! lame
697
Performs 2-pass transcoding from one AVI into another. The first pass also
698
determines and saves the maximum volume scaling that can safely be applied
699
without having to resort to clipping. It does not bother performing audio encoding
700
or producing an output file. Although the particular (encoder compatible) muxer
701
is hardly relevant here, one is nevertheless indicated explicitly
702
as a “<span class="quote">reasonable</span>”choice cannot be determined
703
from <code class="literal">/dev/null</code>. After some scripting to retrieve the
704
saved value from a file, the second pass performs volume scaling and encoding.
705
It also sets a comment (tag) in the resulting file to note its lofty goal.
706
</p></div></div><br class="example-break" /><div class="example"><a id="id527986"></a><p class="title"><b>Example 2.8. Configuration file</b></p><div class="example-contents"><p>
707
</p><pre class="programlisting">
709
ignore-prop=.*src.*,.*sink.*,dam.*,queue.*,identity.*,.*decodebin.*
710
display-prop=.*\.tag,.*\.bitrate$,.*bframes,.*quantizer,.*\.pass,.*\.queue-size
720
A basic, though adequate configuration file that filters out some
721
(usually less interesting) information on some “<span class="quote">technical</span>”
722
technical elements, while making sure on the other hand that some other
723
settings get displayed in any case. In addition, an element's properties
724
can be given defaults (other than the hardcoded ones), and the rank
725
of <span class="emphasis"><em>dvdsubdec</em></span> is increased so that subtitles streams will
727
</p></div></div><br class="example-break" /><div class="example"><a id="id528015"></a><p class="title"><b>Example 2.9. Profile configuration</b></p><div class="example-contents"><p>
728
Some examples of (encoding) profiles that can be passed to
729
<code class="option">--profile</code> (each profile is in a separate file).
730
Note that profiles also impose
731
constraints on e.g. width and height which are not automagically
732
enforced; one must still take care of this by means of e.g. proper scaling.
733
Similarly, the elements that are to perform the required encoding
734
must be properly (manually) specified, though their configuration
735
is then taken care of by the examples below.
736
</p><pre class="programlisting">
739
# 44.1kHz, 16b, 2ch, mp2
752
rc-buffer-aggressivity = 99
757
</p><pre class="programlisting">
761
# 44.1kHz, 16b, 2ch, mp2
765
# >= 64, <= 384
772
# ntsc: gop-size = 18
775
rc-buffer-size = 1792
776
rc-buffer-aggressivity = 99
782
</p><pre class="programlisting">
786
# 32|44.1|48kHz, 16b, 2ch, mp2
790
# >= 64, <= 384
794
# 1000 <= bitrate <= 9000
798
# ntsc: gop-size = 18
803
rc-buffer-size = 1792
804
rc-buffer-aggressivity = 99
807
</p><pre class="programlisting">
810
# 353|704|720 x 240|288|480|576
811
# 48kHz, 16b, 2ch, mp2|ac3
815
# >= 64, <= 384
819
# 1000 <= bitrate <= 9800
823
# ntsc: gop-size = 18
826
rc-buffer-size = 1792
827
rc-buffer-aggressivity = 99
832
</p></div></div><br class="example-break" /></div><div class="refsect1" lang="en" xml:lang="en"><a id="requirements"></a><h2>Requirements</h2><p>
833
Evidently, there must be a basic <a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> framework installation,
834
the extent of which and available plugins determine the processing scope that
836
Beyond this, it is highly recommended for the <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> element to be available,
837
which is part of the plugins supplied along with <span class="command"><strong>entrans</strong></span>.
838
More (technical) details and motivation can be found in the documentation for
839
<a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a>, but suffice it to say that without <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> the following notes apply:
840
</p><div class="itemizedlist"><ul><li><p>
841
For <code class="option">--seek</code>, only the methods
842
<code class="literal">seek</code> and <code class="literal">seek-key</code> are available.
843
However, for reasons explained in <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> documentation and in
844
<a class="xref" href="entrans.html#muxing-pipelines" title="Muxing Pipelines">“Muxing Pipelines”</a>, even these methods can not be considered reliable,
845
either functional or technical.
846
As such, only full (uninterrupted) pipeline transcoding is really available.
848
As a technical note, this unreliability could be alleviated by
849
having the functionality to drop out-of-segment-bound buffers not only in sinks
850
or in some elements, but as a specific ability in
851
e.g. <span class="emphasis"><em>identity</em></span>.
853
The graceful (signal initiated) termination usually
854
also relies on <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a>, and is quite sturdy in this case.
855
However, and fortunately, there is also an alternative fall-back implementation
856
that will take care of this in the vast majority of circumstances.
857
</p></li></ul></div><p>
859
Note that in case of dynamic pipelines, the availability of the <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> element
860
in the system is auto-detected, and the proper pipeline-construction action is
861
taken accordingly. In raw mode, however, it must be explictly confirmed (by
862
<code class="option">--dam</code>) that <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a>s are properly used, otherwise none will
863
be assumed present and only restricted operation is then available, as indicated
864
above. Proper usage of <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> is subject to comments in <a class="xref" href="entrans.html#muxing-pipelines" title="Muxing Pipelines">“Muxing Pipelines”</a>,
865
but basically comes down to putting a <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> as upstream as possible in each
866
independent stream, e.g. preceding some queue. Alternatively, such a queue could
867
be used as “<span class="quote">surrogate dam</span>” by naming it
868
<code class="literal">dam<em class="replaceable"><code><digits></code></em></code>.
869
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id528275"></a><h2>GNonLin Comparison</h2><p>
870
On the one hand, one might compare in the sense that both GNonLin and <span class="command"><strong>entrans</strong></span>
871
aim to create media files while allowing for non-linear editing/cutting.
872
On the other hand, <span class="command"><strong>entrans</strong></span> is quite complementary and can actually be combined
873
with GNonLin, for example
874
</p><div class="informalexample"><pre class="programlisting">
875
entrans.py -- --raw gnlcomposition. '(' name=comp gnlfilesource \
876
location=test.avi start=0 duration=20000000000 media-start=0 \
877
media-duration=20000000000 caps=video/x-raw-yuv ')' \
878
comp.src ! ffenc_mpeg4 ! queue ! avimux ! filesink location=test-gnonlin.avi
881
That being the case, why this alternative and yet another program, rather than
882
being content with e.g. GNonLin (and <span class="citerefentry"><span class="refentrytitle"><span class="command"><strong>gst-launch</strong></span></span>(1)</span>) ?
884
First and foremost, as a matter of style. The above example pipeline looks and
885
feels rather contrived (and that's only the video part!), and is not much of a
886
<span class="emphasis"><em>pipeline</em></span> in that e.g. <span class="emphasis"><em>gnlcomposition</em></span> is
887
really (deliberately) not so much a pipeline than it is more of a bag (serving
888
its intended purpose well). On the other hand, Un*x pipelines have a long
889
standing beauty (and a.o. adaptability and flexibility), and a (traditional)
890
<a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> pipeline continues in that tradition. In that sense, <span class="command"><strong>entrans</strong></span>'
891
(and <span class="citerefentry"><span class="refentrytitle"><span class="command"><strong>gst-launch</strong></span></span>(1)</span>) approach is an “<span class="quote">ode to pipeline</span>” and its
892
inherent simplicity and clarity of intent.
893
In particular, typical <span class="command"><strong>entrans</strong></span> pipelines are only slightly different than
894
playback pipelines, and the cutting/seeking mechanism is pretty identical.
895
In that way, an <span class="command"><strong>entrans</strong></span> media file creation is very close to a
896
(non-linear) playback session (and closer than a GNonLin equivalent would be).
898
Secondly, there are some technical reasons. Particular care has been given
899
in <span class="command"><strong>entrans</strong></span> to the non-linear cutting functionality to make sure it operates
900
with great precision in a variety of circumstances. In this area;
901
</p><div class="itemizedlist"><ul><li><p>
902
GNonLin, in particular <span class="emphasis"><em>gnlcomposition</em></span>, may (and has been
903
known to) experience some frame-dropping near end-of-stream due to its
904
(asynchronous) technique of EOS-event generation
906
GNonLin only relies on segment seek, as does <span class="command"><strong>entrans</strong></span> usually, which
907
is fine when dealing with elements that support what and how they are supposed
908
to. However (and unfortunately), elements are not always so perfect (for
909
example, <span class="emphasis"><em>dvdreadsrc</em></span> does not support segment seek).
910
In such cases, <span class="command"><strong>entrans</strong></span> has some plain-and-simple alternative methods that can
911
still get the (cutting) job done.
913
So, the idea and intention basically is; if you can play it, you can <span class="command"><strong>entrans</strong></span>
914
it (with a similar pipeline, and precision in various circumstances).
915
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="muxing-pipelines"></a><h2>Muxing Pipelines</h2><p>
916
As mentioned earlier, one might run into some pitfalls when constructing
917
a (raw) pipeline, most of which are taken care of by <span class="command"><strong>entrans</strong></span> when runnning in
919
</p><p><b>Building. </b>
920
To begin with, the pipeline must be properly built and linked,
921
in particular to the muxer element, which typically only has request pads.
922
For linking and subsequent negotiation to succeed, a stream must manage
923
to get the request pad it really needs and is compatible with. That means that
924
the element connecting to the muxer (or trying so) should provide enough
925
(static) information to identify the corresponding muxer pad (template).
926
As this information is typically derived from the connecting element's
927
pad templates, it is not quite comfortable to try connecting a generic
928
element (e.g. <span class="emphasis"><em>queue</em></span>). If this were needed, or there is some
929
or the other problem connecting to the muxer, then it may be helpful to use
930
a capsfilter (aka as a filtered connection) or to specifically
931
indicate the desired muxer pad (by a name corresponding to the intended
932
template, as in example <a class="xref" href="entrans.html#ex-pass-through" title="Example 2.5. Pass-through transcoding">Example 2.5, “Pass-through transcoding”</a>),
933
see also <span class="citerefentry"><span class="refentrytitle"><span class="command"><strong>gst-launch</strong></span></span>(1)</span> for specific syntax in either case.
934
</p><p><b>Muxer and Queue. </b>
935
In the particular case of a transcoding pipeline (having some media-file
936
as source), some other care is needed to make sure it does not stall, i.e.
937
simply block without any notification (or an application having
938
a chance to do something about it). Specifically, a muxer will often block a
939
thread on its incoming pad until it has enough data across all of its pads for
940
it to make a decision as to what to mux in next.
941
Evidently, if a single (demuxer) thread were having to provide data to several
942
pads, then stalling would almost surely occur. As such, each of these
943
pads/streams should have its own thread. In case of live sources, this is
944
usually already the case, e.g. separate video and audio capturing threads.
945
However, when transcoding, and therefore demuxing an input file, a
946
<span class="emphasis"><em>queue</em></span> should be inserted into each outgoing stream to act as
947
a thread boundary and supply a required separate thread.
948
In addition, this multi-threading will evidently also spread processing across
949
several CPUs (if available) and improve performance. In this respect, it
950
can also be beneficial to use more than 1 <span class="emphasis"><em>queue</em></span>/thread per
951
stream; one that performs filter processing (if any) and one that performs
954
Note that similar stalling can also occur in some variations of these
955
circumstances. For instance, <span class="emphasis"><em>tee</em></span> could have the role of
956
demuxer in the above story, and/or a collection of several sinks in a
957
pipeline could act as a muxer in the above story, since they will each also
958
block a thread in PAUSED state (when the pipeline is trying to make it to
959
that state). Another such situation can arise (temporarily) when pads are
960
blocked as part of the seek-mechanism. In any case, the remedy is the same;
961
use <span class="emphasis"><em>queue</em></span>s to prevent one thread from having to go around in
962
too many places, and ending up stuck in one of them.
963
</p><p><b>Muxer and Time(stamps). </b>
964
Even if the above is taken into account, the time-sensitivity of a typical
965
muxer may lead to (at first sight mysterious) stalling (in transcoding
966
pipelines). That is, a muxer will usually examine the timestamps of the incoming
967
data, select the oldest of these to be put into the outgoing stream and then
968
wait for new data to arrive on this selected input stream (i.e. keep other
969
streams/threads wait'ing).
970
It follows easily that if there is a gap, “<span class="quote">imbalance</span>”,
971
imperfection, irregularity (or however described) in timestamps between various
972
incoming streams, a muxer will then consistently/continuously
973
expect/want more data on 1 particular pad (for some
974
amount proportional to the irregularity).
975
For some time, this need could be satisfied by the <span class="emphasis"><em>queue</em></span>s
976
that are present in this stream. At some point, however, these may not hold
977
enough data and will need further input from the upstream demuxer element.
978
However, for this demuxer to provide data for 1 of its (outgoing) streams, it
979
will also need to output data for the other streams, and this ends up
980
into the other streams' <span class="emphasis"><em>queue</em></span>s. Unfortunately, in
981
this situation those queues cannot send out any data, as the muxer is
982
holding their threads (blocked). Hence, they will (soon) fillup and then in
983
turn block the demuxer thread trying to insert data, until there is again space
984
available. Consequently, a deadlock circle ensues; muxer waiting for new
985
data from queue, waiting for data from demuxer, waiting for space to put this
986
into another stream queue, waiting to unload data into the muxer.
987
Note that this deadlock phenomenom will not occur with live (recording) pipelines,
988
as the various threads are then not joined to a single demuxer (thread),
989
though it is then likely to manifest itself it by loss of (live) input data.
991
There a number of possible causes for the irregularities mentioned above.
992
</p><div class="itemizedlist"><ul><li><p>
993
Rarely, but not impossibly so, the problem may be inherent in the very input
994
medium itself. Or there could be a problem with a (experimental) demuxer
995
that might produce incorrect timestamps.
997
If a (segment) seek is performed in a pipeline <span class="emphasis"><em>without</em></span>
998
using <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a>, it is quite likely that some stream(s) may perform proper
999
filtering of out-of-segment-bound data, and that other(s) may not. This would
1000
then cause a typical imbalance between the various streams.
1002
If timestamps are being resequenced in some incoming streams (e.g. by
1003
<a class="ulink" href="http://www.gstreamer.net/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-identity.html" target="_top"><span class="emphasis"><em>identity</em></span></a>), but not in the other ones, there is an obvious imbalance.
1005
Though more exotic, even if <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> is being used, one must take care to perform
1006
this filtering <span class="emphasis"><em>before</em></span> (the by now
1007
clearly essential) <span class="emphasis"><em>queue</em></span> in the respective stream,
1008
particularly when several distinct sections are to be cut out of the input.
1009
After all, if <span class="emphasis"><em>queue</em></span> were placed before <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a>, then the
1010
latter does not have a chance to drop unneeded buffers soon enough.
1011
As such, if a muxer tries to get the first piece of data on a
1012
particular pad following the gap between the sections, these
1013
<span class="emphasis"><em>queue</em></span>s would fillup and be effectively as if they were not
1015
</p></li></ul></div><p>
1016
</p><p><b>Dynamic mode services. </b>
1017
Dynamic mode takes care of (most of) the above as follows:
1018
</p><div class="itemizedlist"><ul><li><p>
1019
Pipeline building is performed almost completely automagically.
1020
Of course, this does not mean it can fit a square into a circle, so some
1021
consideration for compatibility and negotiation is still in order.
1023
<span class="emphasis"><em>queue</em></span>s are inserted where needed and/or useful,
1024
either by <span class="emphasis"><em>decodebin</em></span> or by <span class="command"><strong>entrans</strong></span>
1026
Whenever available (recommended), <a class="ulink" href="../../gst-entrans-plugins/html/gst-entrans-plugins-dam.html" target="_top"><span class="emphasis"><em>dam</em></span></a> is used and inserted in proper locations.
1027
</p></li></ul></div><p>
1028
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id528790"></a><h2>See Also</h2><p>
1029
<a class="ulink" href="http://www.gstreamer.net/" target="_top"><a class="ulink" href="http://www.gstreamer.net/" target="_top"><span class="application">GStreamer</span></a> homepage</a>,
1030
<span class="citerefentry"><span class="refentrytitle"><span class="command"><strong>gst-launch</strong></span></span>(1)</span>,
1031
<a class="ulink" href="http://gentrans.sourceforge.net/" target="_top">entrans plugins</a>
1032
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id528832"></a><h2>Author</h2><p>
1033
Mark Nauwelaerts <code class="email"><<a class="email" href="mailto:mnauw@users.sourceforge.net">mnauw@users.sourceforge.net</a>></code>
1034
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="package.html"><< Previous</a> </td><td width="20%" align="center"><a accesskey="u" href="package.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top">Chapter 2. Package Documentation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Table of Contents</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div><div class="footer-homepage"><table width="100%"><tr><td width="40%" align="left">Last created:
1035
2010-03-03 22:13:23+01:00</td><td width="20%" align="center"><a href="http://gentrans.sourceforge.net/" title="GEntrans: Home page">GEntrans home page</a></td><td width="40%" align="right"></td></tr></table></div></body></html>