You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
513 lines
15 KiB
513 lines
15 KiB
4 years ago
|
<html>
|
||
|
<head>
|
||
|
<title> Linux Video Stream Processing Tool - Examples</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||
|
<meta name="keywords" content="DVD, digital video, DV, encoder, divx,
|
||
|
DivX;-), lame, source, posix, avifile, opendivx, codec, linux, AC3,
|
||
|
program stream, video, audio, transcode, decoder, stream, YV12">
|
||
|
</head>
|
||
|
|
||
|
<body bgcolor=#CDB5CD>
|
||
|
|
||
|
|
||
|
<a name=top></a>
|
||
|
<table cellspacing="10" cellpadding="0" border="0" width="100%">
|
||
|
<tr>
|
||
|
<td align=left valign="top" width=30% bgcolor="#a0a0a0">
|
||
|
<table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
|
||
|
<td align="left" bgcolor="#e9e9e9"> <FONT
|
||
|
FACE="Lucida,Helvetica"> <font>Miscellaneous</font>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
|
||
|
<td>
|
||
|
|
||
|
<ul>
|
||
|
<li> <a href="#para"> <FONT FACE="Lucida,Helvetica">
|
||
|
Overview on the
|
||
|
resizing/clipping options</font></a> <br>
|
||
|
</uL>
|
||
|
|
||
|
<ul>
|
||
|
<li> <a href="#maudio"> <FONT FACE="Lucida,Helvetica">
|
||
|
AVI-files with multiple audio tracks</font></a><br>
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
|
||
|
<ul>
|
||
|
<li> <a href="#pass"> <FONT FACE="Lucida,Helvetica">
|
||
|
pass-through modes </font></a>
|
||
|
|
||
|
<ul>
|
||
|
<li><a href="#pass_1"> <FONT FACE="Lucida,Helvetica">
|
||
|
replacing audio</font></a>
|
||
|
<li><a href="#pass_2"> <FONT FACE="Lucida,Helvetica">
|
||
|
creating music clips</font></a>
|
||
|
<li><a href="#pass_3"> <FONT FACE="Lucida,Helvetica">
|
||
|
audio recompression</font></a>
|
||
|
<li><a href="#pass_4"> <FONT FACE="Lucida,Helvetica">
|
||
|
fixing truncated AVI files</font></a>
|
||
|
</ul>
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<li> <a href="#audio"> <FONT FACE="Lucida,Helvetica">
|
||
|
audio only conversion</font></a>
|
||
|
<br>
|
||
|
<ul>
|
||
|
<li><a href="#aud_1"> <FONT FACE="Lucida,Helvetica">
|
||
|
audio track -> MP3</font></a>
|
||
|
<li><a href="#aud_2"> <FONT FACE="Lucida,Helvetica">
|
||
|
audio track -> PCM</font></a>
|
||
|
<li><a href="#aud_3"> <FONT FACE="Lucida,Helvetica">
|
||
|
ASF audio -> MP3</font></a>
|
||
|
</ul>
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</table>
|
||
|
|
||
|
|
||
|
<a name=para></a>
|
||
|
<table cellspacing="10" cellpadding="0" border="0" width="100%">
|
||
|
<tr>
|
||
|
<td align=left valign="top" width=30% bgcolor="#a0a0a0">
|
||
|
<table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
|
||
|
<td align="left" bgcolor="#e9e9e9">
|
||
|
|
||
|
<font>
|
||
|
resizing/clipping options
|
||
|
</font>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
|
||
|
<br> by Steffen Klupsch <steffen@vlsi.informatik.tu-darmstadt.de>
|
||
|
|
||
|
<P>
|
||
|
Boundary Conditions (valid for transcode-0.5.0 and later):
|
||
|
<UL>
|
||
|
<LI> maximum image size is 1024x768
|
||
|
<LI> The video frame operations ordering is fixed:
|
||
|
"-j -I -X -B -Z -Y -r -z -l -k -K -G -C"
|
||
|
(executed from left to right)
|
||
|
<LI> Shrinking the image with '-B' is not possible
|
||
|
if the image width/height is not a multiple of 32.
|
||
|
<LI> Expanding the image with '-X' is not possible
|
||
|
if the image width/height is not a multiple of 32.
|
||
|
<LI> The final frame width/height should be a multiple of 8.
|
||
|
(to avoid encoding problems with some divx codecs)
|
||
|
|
||
|
<OL>
|
||
|
<LI> Reducing the video height/width by 2,4,8
|
||
|
Option '-r factor' can be used to shrink the video image by a
|
||
|
constant factor, this factor can be 2,4 or 8.
|
||
|
|
||
|
<LI> Clipping and changing the aspect ratio
|
||
|
transcode uses 3 steps to produce the input image for the
|
||
|
export modules
|
||
|
<OL>
|
||
|
<LI> Clipping of the input image.
|
||
|
<LI> Changing the aspect ratio of the 1) output.
|
||
|
<LI> Clipping of the 2) output.
|
||
|
|
||
|
</OL>
|
||
|
</OL>
|
||
|
</UL>
|
||
|
<P>
|
||
|
Used Options:
|
||
|
<OL>
|
||
|
<LI> The first clipping is defined by the option <br>
|
||
|
'-j top[,left[,bottom[,right]]]' <br>
|
||
|
if you don't specify all parameters, they will be assumed to be
|
||
|
symmetric to the others.
|
||
|
<P>
|
||
|
-j 80 is expanded to -j 80,0,80,0 (top,left,bottom,right)<br>
|
||
|
-j 80,8 is expanded to -j 80,8,80,8<br>
|
||
|
-j 80,8,10 is expanded to -j 80,8,10,8<br><br>
|
||
|
<LI> Changing the aspect ration can be done in 3 ways:
|
||
|
<UL>
|
||
|
<LI> (fast) shrinking the image with option '-B n[,m]'
|
||
|
<LI> (fast) expanding the image with option '-X n,[m]'
|
||
|
<LI> (high quality) resizing with option '-Z wxh'
|
||
|
</UL><br>
|
||
|
<LI> The 2nd clipping is defined by the option
|
||
|
<br>
|
||
|
'-Y top[,left[,bottom[,right]]]'<br>
|
||
|
if you don't specify all parameters, they will be assumed to be
|
||
|
symmetric to the others.
|
||
|
|
||
|
</OL>
|
||
|
<P>
|
||
|
Examples on Usage:
|
||
|
|
||
|
<OL>
|
||
|
<LI> Input data '16:9' 'widescreen' DVD data,
|
||
|
output data should have 4:3 aspect ratio without black border.
|
||
|
<br>
|
||
|
Analyze the input data, we assume a black border at the top and
|
||
|
bottom of 66 pixel in a 720x576 pixel frame.
|
||
|
<p>
|
||
|
<OL>
|
||
|
<LI> Using the fast resizing option -B,
|
||
|
shrinking the height to reach a correct aspect ratio:
|
||
|
'-j 32,0 -B 4,0 -Y 24,0'
|
||
|
Final image size: 720x336 Pixel
|
||
|
|
||
|
<LI> Using the fast resizing options -X and -B,
|
||
|
removing 1% at the left&right border, expanding the image width
|
||
|
to PAL resolution, and shrinking the height to reach a
|
||
|
correct aspect ratio:<br>
|
||
|
'-j 32,8 -X 0,2 -B 3,0 -Y 24,0'<br>
|
||
|
Final image size: 768x368 Pixel
|
||
|
|
||
|
<LI> Using the fast -X resizing, expanding the image width,
|
||
|
but removing 3% of the image at the left and the right border:<br>
|
||
|
'-j 64,24 -X 0,7'<br>
|
||
|
Final image size: 896x448 Pixel
|
||
|
|
||
|
<LI> Using the slower -Z resizing, expanding the image width to PAL
|
||
|
resolution:<br>
|
||
|
'-j 68,0 -Z 768x360'<br>
|
||
|
Final image size: 768x360 Pixel
|
||
|
|
||
|
<LI> Using the slower -Z resizing, 800 Pixel image width:<br>
|
||
|
'-j 66,0 -Z 800x368'<br>
|
||
|
Final image size: 800x368 Pixel
|
||
|
|
||
|
<LI> Using the slower -Z resizing, expanding the image width:<br>
|
||
|
'-j 64,0 -Z 960x448'<br>
|
||
|
Final image size: 960x448 Pixel
|
||
|
|
||
|
</OL>
|
||
|
<p>
|
||
|
<LI> Input data '16:9' DVD data without black borders,
|
||
|
output data should have 4:3 aspect ratio.
|
||
|
<p>
|
||
|
<OL>
|
||
|
<LI> Using the fast resizing option -B, <br>
|
||
|
shrinking the height to reach correct aspect ratio:
|
||
|
'-B 4,0'<br>
|
||
|
Final image size: 720x448 Pixel
|
||
|
|
||
|
<LI> Using the fast -X resizing, expanding the image width,
|
||
|
but removing 3% of the image at the left and the right border:<br>
|
||
|
'-j 0,24 -X 0,7'<br>
|
||
|
Final image size: 896x576 Pixel
|
||
|
|
||
|
<LI> Using the slower -Z resizing, expanding the image width
|
||
|
to PAL resolution:<br>
|
||
|
'-Z 768x472'<br>
|
||
|
Final image size: 768x472 Pixel
|
||
|
|
||
|
<LI> Using the slower -Z resizing, 800 Pixel image width:<br>
|
||
|
'-Z 800x480'<br>
|
||
|
Final image size: 800x480 Pixel
|
||
|
|
||
|
<LI> Using the slower -Z resizing, expanding the image width:<br>
|
||
|
'-Z 960x576'<br>
|
||
|
Final image size: 960x576 Pixel
|
||
|
|
||
|
</OL>
|
||
|
</OL>
|
||
|
<P>
|
||
|
|
||
|
</table>
|
||
|
</table>
|
||
|
|
||
|
|
||
|
<a name=pass></a>
|
||
|
<table cellspacing="10" cellpadding="0" border="0" width="100%">
|
||
|
<tr>
|
||
|
<td align=left valign="top" width=30% bgcolor="#a0a0a0">
|
||
|
<table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
|
||
|
<td align="left" bgcolor="#e9e9e9">
|
||
|
|
||
|
<font>pass-through modes</font>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
This section is devoted to the pass-through modes
|
||
|
available, which maybe useful for some, not so common
|
||
|
situations as outlined below.
|
||
|
|
||
|
<a name=pass_1><h3>replacing audio</h3></a>
|
||
|
<a name=pass_2><h3>creating video clips</h3></a>
|
||
|
Suppose you have mastered a couple of DV clips,
|
||
|
concatenated to a well defined playtime "clip1.avi" that
|
||
|
accidently
|
||
|
correspond to the length of your favorite music clip "clip2.mp3"
|
||
|
in MP3 format. We want to keep the quality of the video
|
||
|
and simply replace the PCM audio track. This is done by
|
||
|
the following command:
|
||
|
<p>
|
||
|
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
transcode</td>
|
||
|
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-i clip.avi -p clip.mp3</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr><td></td>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-P 1 </td>
|
||
|
</tr>
|
||
|
|
||
|
<td></td><td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-o new_clip.avi -y raw</td></tr>
|
||
|
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
Note: The MP3 stream must be identified by <i>tcprobe</i>.
|
||
|
If this fails, we need to supply the import module options
|
||
|
"-x dv,mp3" to make sure, the audio is decoded properly.
|
||
|
The "-y raw" export module simply writes the video chunks
|
||
|
as is together with the re-encoded audio. MP3 pass-through,
|
||
|
similar
|
||
|
to AC3 pass-through with options "-A -N 0x2000" is not yet available.
|
||
|
|
||
|
<a name=pass_3><h3>audio recompression</h3></a>
|
||
|
|
||
|
The following situation is not uncommon. Suppose your single
|
||
|
AVI-file "movie128.avi" is about 2x700MB+15MB, i.e., too large to fit
|
||
|
on 2 CD's. Fortunately, the audio is MP3 with a bitrate of
|
||
|
128kbps, which is the default.
|
||
|
We recompress the audio to 96kbps to reduce the filesize
|
||
|
below 2x700MB. Let's also double the volume of the sound,
|
||
|
if possible, or use the recommended value given by <i>tcscan</i>.
|
||
|
|
||
|
<p>
|
||
|
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
transcode</td>
|
||
|
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-i movie128.avi</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr><td></td>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-P 1 -b 96 -s 2.0</td>
|
||
|
</tr>
|
||
|
|
||
|
<td></td><td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-o movie96.avi -y raw</td></tr>
|
||
|
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
This is reasonable fast since video is only passed through
|
||
|
and the audio quality is still ok.
|
||
|
After you are done, use avisplit to split the file
|
||
|
into 2 chunks.
|
||
|
<a name=pass_4><h3>fixing truncated AVI files</h3></a>
|
||
|
|
||
|
The AVI file header is updated (written to disk), whenever video/audio
|
||
|
parameter are set. If transcode or hardware crashes, the truncated file
|
||
|
is in most cases playable for advanced players.
|
||
|
Repairing the AVI-file index is also possible via pass-through option "-P3".
|
||
|
<p>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align=left valign=center bgcolor="#ccffcc">
|
||
|
transcode -i crashed.avi -o new.avi -P3 -u X</td>
|
||
|
</td>
|
||
|
</table>
|
||
|
|
||
|
<br>Option "-u X" with X>>10 enhances pass-through speed.
|
||
|
|
||
|
|
||
|
</table>
|
||
|
</table>
|
||
|
|
||
|
|
||
|
<a name=audio></a>
|
||
|
<table cellspacing="10" cellpadding="0" border="0" width="100%">
|
||
|
<tr>
|
||
|
<td align=left valign="top" width=30% bgcolor="#a0a0a0">
|
||
|
<table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
|
||
|
<td align="left" bgcolor="#e9e9e9">
|
||
|
|
||
|
<font>audio only conversion</font>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
|
||
|
Audio only conversion is also possible with
|
||
|
<i>transcode</i>.
|
||
|
Certainly, there are tons of tools out there, doing the
|
||
|
same job, so I will concentrate on useful examples, mainly
|
||
|
DVD ripping and encoding on the fly, using options "-p"
|
||
|
for input and "-m" for output.
|
||
|
|
||
|
<a name=aud_1><h3>audio track -> MP3</h3></a>
|
||
|
|
||
|
Some DVDs have a separate AC3 (Dobly Digital) film soundtrack, which
|
||
|
you might want to convert to MP3. Music DVDs have
|
||
|
tracks with uncompressed audio
|
||
|
which is LPCM format (linear PCM), you want to archive. In this
|
||
|
particular case, you might need to add "-d" for audio byte swapping.
|
||
|
You need to check with tcprobe which audio track is the
|
||
|
right one.
|
||
|
We do it in 1 step for
|
||
|
track 2 and write to the file "track.mp3":
|
||
|
|
||
|
<p>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
transcode</td>
|
||
|
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-p /dev/dvd/ -T 1,-1 -a 2 </td>
|
||
|
</tr>
|
||
|
|
||
|
<td></td><td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-y raw -m track.mp3 </td></tr>
|
||
|
|
||
|
</table>
|
||
|
<p>
|
||
|
|
||
|
<a name=aud_2><h3>audio track -> PCM</h3></a>
|
||
|
|
||
|
If you prefer uncompressed PCM data for further processing, add
|
||
|
"-N 0x1" in the command above:
|
||
|
|
||
|
<p>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
transcode</td>
|
||
|
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-p /dev/dvd/ -T 1,-1 -a 2</td>
|
||
|
</tr>
|
||
|
|
||
|
<td></td><td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-y raw -m track.pcm -N 0x1</td></tr>
|
||
|
|
||
|
</table>
|
||
|
<p>
|
||
|
|
||
|
|
||
|
<a name=aud_3><h3>ASF audio -> MP3</h3></a>
|
||
|
|
||
|
I had this ASF (advanced stream format) Genesis audio file
|
||
|
lying around and tried the <i>avifile</i> import module. Since
|
||
|
no auto-probing is available for ASF streams in the current
|
||
|
version, you must play around with the sample rate. CD quality
|
||
|
is 44100 Hz samplerate:
|
||
|
|
||
|
<p>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
transcode</td>
|
||
|
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-p carpet_crawler_1999.asf -x null,af6</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr><td></td>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-e 44100 -E 44100 -b 112</td>
|
||
|
</tr>
|
||
|
|
||
|
<td></td><td align=left valign="top" bgcolor="#ccffcc">
|
||
|
-y null,raw -m carpet_crawler_1999.mp3</td></tr>
|
||
|
|
||
|
</table>
|
||
|
<p>
|
||
|
|
||
|
</table>
|
||
|
</table>
|
||
|
|
||
|
<a name=maudio></a>
|
||
|
<table cellspacing="10" cellpadding="0" border="0" width="100%">
|
||
|
<tr>
|
||
|
<td align=left valign="top" width=30% bgcolor="#a0a0a0">
|
||
|
<table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
|
||
|
<td align="left" bgcolor="#e9e9e9">
|
||
|
|
||
|
<font>AVI-files with multiple audio tracks</font>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>
|
||
|
<a name=xvcd><h3>HowTo:</h3></a>
|
||
|
|
||
|
Before you start, try to find the best bitrate for video
|
||
|
encoding
|
||
|
with multiple audio tracks by using <i>tcprobe</i> with
|
||
|
option "-b n*128", for example, if you want n MP3 audio
|
||
|
tracks with 128kbps bitrate each.<br>
|
||
|
A first session produces the file movie.avi with a single audio
|
||
|
track "-a 0". Now, we use a similar command to extract a second
|
||
|
audio
|
||
|
track from the source. Suppose, we used the example modules
|
||
|
"vmod,amod"
|
||
|
for video and audio extraction.<p>
|
||
|
|
||
|
|
||
|
The second session goes as follows. This session will be much
|
||
|
faster, since no video is de/encoded.<p>
|
||
|
|
||
|
<Ul>
|
||
|
<li>
|
||
|
(1) transcode the second audio track "-a 1" into an AVI
|
||
|
container file named add-on.avi This looks like:
|
||
|
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
transcode -i (...) -x null,amod -g 0x0 -y raw -a 1
|
||
|
-o add-on.avi -u 50 </tr>
|
||
|
</table>
|
||
|
<p>
|
||
|
|
||
|
The resulting file is only a temporary file but enables
|
||
|
proper processing with <i>avimerge</i>. The export
|
||
|
module "-y raw" is fine, since it writes proper (0 bytes)
|
||
|
video frames.
|
||
|
Set video import module to "null". If all goes well,
|
||
|
both files should be identical with respect to the number
|
||
|
of frames. Choose the proper audio track with "-a". Try also to
|
||
|
increase the internal buffers "-u" for speedup.<p>
|
||
|
|
||
|
<li>(2) merge this track into movie.avi
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align=left valign="top" bgcolor="#ccffcc">
|
||
|
avimerge -i movie.avi -o dualaudiomovie.avi -p add-on.avi
|
||
|
</tr>
|
||
|
</table>
|
||
|
<p>
|
||
|
|
||
|
<li> (3) Repeat steps (1-2) for even more audio tracks, if you
|
||
|
wish.
|
||
|
For best results, I recommend doing this procedure with a single
|
||
|
AVI movie file. All <i>avi*</i> post-processing tools now support
|
||
|
multiple audio tracks.<p>
|
||
|
--- <br>
|
||
|
Note: <i>transcode</i> supports reading from multiple-audio tracks
|
||
|
but only writes (exports) to single audio/video AVI-files.
|
||
|
</table>
|
||
|
</table>
|
||
|
|
||
|
|
||
|
|
||
|
<!-- hhmts start -->
|
||
|
Last modified: Thu May 16 12:59:16 CEST 2002
|
||
|
<!-- hhmts end -->
|
||
|
|
||
|
</body> </html>
|