1 TITLE: Converting Audio/Video-files using transcode
3 AUTHOR: Alex Kloss <l.x.@gmx.de>
6 Short Guide how to set up the program transcode, not to forget
7 necessary or simply "must-have"-usable libraries.
10 This short hint to install transcode (after some libs). Thanks
11 to the help of the irc channel #lfs. You'll get a program you
12 can use to rip DVDs, convert, mpeg2 or avi (from your digital
13 camera using libdv) to avi/divx.
14 Since I have neither a digital videocamera nor a firewire card,
15 somebody else will have to write the dv(avi)->avi(divx)
19 transcode (you may want to try the pre-version;
20 http://www.theorie.physik.uni-goettingen.de/~ostreich/transcode/)
22 ADDITIONAL PREREQUISITES:
23 ogg/vorbis: http://www.xiph.org
24 curl: http://curl.sourceforge.net
25 lame: http://www.mp3dev.org/lame/
26 ffmpeg: http://ffmpeg.souceforge.net
27 libfame: http://fame.sourceforge.net
28 xvid: http://www.xvid.org
29 MPlayer: http://www.mplayerhq.hu/download
30 avifile: http://avifile.sourceforge.net
31 libdv: http://libdv.sourceforge.net
32 Image Magick: http://www.imagemagick.org
33 LZO: http://www.oberhumer.com/opensource/lzo/
34 openquicktime: http://openquicktime.sourceforge.net
35 (currently not supported)
38 libao, libogg, libvorbis, curl, vorbis-tools
39 ============================================
41 ./configure --prefix=/usr &&
45 for each will do the job.
48 openquicktime, libfame
49 ======================
51 ./configure --prefix=/usr/X11R6 &&
56 for each of them should be enough. OpenQuicktime is currently
57 not supported, we're awaiting it at Version 0.7.x.
63 Please check out the Mplayer hint of the same author. Check out
64 ffmpeg's libavcodec from CVS and compile MPlayer with the
65 "--enable-shared-pp" switch. Compile Xvid as stated in the
66 hint. If you've used another prefix to MPlayer than the
67 preselected (/usr/local), transcode will not find either the
68 ffmpeg libavcodecs as the postprocessing lib from MPlayer.
71 export CFLAGS+=-I<prefix>/include &&
72 export LDFLAGS+=-L<prefix>/lib
74 before you start compiling transcode.
80 ./configure --prefix=/usr/X11R6/ \
81 --enable-vorbis --with-sdl-prefix=/usr/X11R6/ \
82 --enable-ffmpeg --enable-vorbis --enable-x86opt \
87 You can of course choose another prefix. If you don't have SDL
88 installed, let the --with-sdl-prefix-Switch out.
94 This section is not available. If one of you has got the
95 hardware, we could test it. Otherwise there'd be no need for
96 this section anyway, so I can leave it alone :).
100 =====================
102 ./configure --prefix=<wanted prefix> &&
106 for each of them will do.
112 ./configure --prefix=<wanted prefix> &&
116 For special options, read "./configure --help", but the
117 configure script usually finds anything.
120 APPENDIX I - UTILITY USAGE:
121 transcode contains the following utilties:
123 transcode: encoding user interface. Handles the plugins and
126 tccat: concatenate input files (see input plugin section).
128 tcdecode: decode input files (to raw video or pcm audio).
130 tcdemux: demultiplex A/V stream files (files bearing multiple
131 audio or video streams, eg. VOB-files).
133 tcextract: extract single streams eg. from VOB-files.
135 tcframe: processes single video frames for different color
136 encodings (RGB <-> YUV; see section Computer Video).
138 tcprobe (newest version): indicates input data format.
140 tcscan: measures input data.
142 avicodec: indicates or changes Codec flag in avifile.
144 avidump: dumpt audio or video stream of an given avifile to
145 stdout (for avi conversion or extraction of audio streams).
147 avimerge: merges avifiles of the same format.
149 avisplit: splits avifiles.
151 avisync: shift audio in avifiles for better syncronising.
154 APPENDIX II - USAGE EXAMPLES
157 At first we need to find out how much louder the sound should
158 be, therefore we scan the ac3 stream of our dvd to adept the
159 suggested volume rescale factor for later usage:
161 tccat -T 1,1,1 -i /dev/dvd -t dvd -d 0 -L | \
162 tcextract -t vob -x ac3 | tcdecode -x ac3 | tcscan -x pcm -d 1
163 ________________________________________________________________
167 tccat...: giving the dvd vob stream to stdout.
169 tcextract...: extract the ac3 audio datas from the vob stream.
171 tcdecode...: convert the ac3 stream to PCM audio data.
173 tcscan...: find out about the PCM data.
174 ________________________________________________________________
176 After 10-30 minutes (depends on the lenght of the DVD), you
177 should get something like:
179 (dvd_reader.c) DVD playback time: 01:49:47.19 @ 25.00 fps
180 5.1 Mode 48.0 KHz 384 kbps Complete Main Audio Service
181 [tcscan] audio frames=164438.40, estimated clip length=7024.39 seconds
182 [tcscan] (min/max) amplitude=(-0.360/0.354), suggested volume rescale=2.884
184 If you want to calculate the bitrate for encoding yourself,
185 depending on how big you want the movie to be afterwards,
186 it can be dead helpful to have an idea of what "bitrate" is:
188 bitrate is the amount of data per seconds. The amount of data
189 depends on the resolution of video and audio (Video=Graphic
190 resolution [640x480], framerate [25 fps]; Audio=Scan frequency
191 [48000Hz], bits per scan [16bit] and both of course the
192 compression rate and therefor, because of lossy compression, the
194 If you want to compress a dvd to fit on a 700MB CD/R, you need
195 the following calculation:
197 Let's assume a movie file size of 680MB, to have the file
198 certainly fit on the CD/R (and leave space for movix2).
200 1 MB = 1024 kB, 1 kB= 8 kBit, so 1MB = 1024*8 kbit = 8192 kBit.
201 680MB=696320kbyte=5570560kbit (the bitrate is usually measured
202 in kbps, which means kilobit per second, not kilobyte!)
204 In this example, we take a DVD that is about 1h 50min (most
205 DVDs are), which adds up to 110 min or 6600 sec.
207 5570560 kbit / 6600 sec = 844 kbps.
209 Now we have the bitrate for both audio and video. If we want a
210 reasonable audio quality, we should use 128 kbps MP3. So we
213 844 kbps - 128 kbps = 716 kbps.
215 This is the video bitrate we're about to use.
217 Some films got black borders at the top and bottom. Use your
218 favourite DVD player and a program like kruler to find them out.
219 City of Angels, for example, has at the top 80 and at the bottom
222 Now we invoke transcode with the following parametres:
224 transcode -i /dev/dvd -x dvd -a 1 -T 1,-1,1 -Y 80,0,64,0 \
225 -s 2.884 -b 128 -w 716 -E 44100 -y divx4 -o test.avi
226 ________________________________________________________________
231 is used to invoke the other utilities at once.
234 input file/device is /dev/dvd (could be /dev/cdrom, /dev/hdc,
235 depending on your system).
238 using the dvd input plugin (see Plugin section)
241 extract the audio channel 1 (0=english, 1 could be german or else,
242 depending on your dvd)
245 extract the DVD title 1, all subtitles, angle 1.
248 cutting borders top (80), left (0), bottom (64), right (0).
251 rescale audio data by the factor 2.884 (so it wouldn't be so
252 silent as on the dvd).
255 MP3 audio bitrate (kilobits per second) set to 128.
258 DivX video bitrate (dito) set to 716.
261 Audio frequency converted to 44100KHz (which is standard on most
262 systems and therefore much faster to play), conforms CD Quality.
265 Using the latest divx4 encoder (see plugin section)
269 ________________________________________________________________
271 2. Cutting AVI files.
273 You can use transcode as well to cut avi files. Use your
274 favourite avi player (I like mplayer best) to find out, at
275 which frames you want to cut and which pieces you want to merge.
277 You could only use I-Frames here, every other frames only
278 contains informations about how the picure differs, not the
281 Use avisplit and avimerge to cut and merge the film. Invoke both
282 commands to get help.
285 Other useful examples can be found on the author's page.
288 APPENDIX III - PLUGIN SECTION:
289 transcode uses raw video data and PCM audio data internally, but
290 it features multiple plugins for input/filtering/output:
292 import_ac3: importing ac3 (normally used in VOB files on DVDs for
293 multichannel audio like 5.1 dts).
295 import_af6: importing avifiles using the avifile library
296 (version 6.0 required; as long as there are only CVS-versions,
297 you should try to get the most recent one).
299 import_avi: importing avifiles using the old avifile library.
301 import_dv: importing from .dv files (like from dvgrab).
303 import_dvd: importing directly from DVD.
305 import_mp3: Guess. Right! MP3 audio data.
307 import_mpeg2: MPEG2 both audio/video data.
309 import_null: just reads data from the null device, to import
310 black screen and silence.
312 import_nuv: Imports Nuppelvideo, a crippled mjpeg format for
315 import_raw: raw data, like from xawtv.
317 import_vob: VOBs are multiplexed mpeg audio/video stream.
319 import_yuv4mpeg: haven't found out what this one does...
321 filter_32detect: 3:2 pulldown detection filter.
323 filter_dilyuvmmx: yuy2 deinterlace filter.
325 filter_null: just a template for you writing your own filters.
327 filter_yuy2toyv12: YUY2 to YV12 conversion (mostly for dv
331 APPENDIX IV - COMPUTER VIDEO
332 Computer video has become more and more popular, since normal
333 PCs can cope with the necessary bandwidth. To see the problems
334 of Computer video, one has to work into the video basics.
336 For further understanding, you need to know that computer video
337 depends on the normal video techniques. The first video device
338 to be popular was simple b/w TV. So you had a stream of
339 brightness data, interrupted by the light ray in the cathode
340 tube to return to 1. the beginning of the next line and 2. to
341 the beginning of the next frame.
343 Not that long afterwards, color television was available. Now
344 you had after the brightness peak some data about the color of
345 the dot. The most reminiscent color coding scheme is YUV, where
346 Y is luminescence (color brightness), U and V are for
347 chrominescence (how much the color differs from blue (U) or red
348 (V)). As the human eye has a higher resolution on the
349 luminescence than on the chrominescence, for lossy packing the
350 resolution of the chrominescence is only stored in half the
351 resolution, so you'll get 4 bit Y, and each 2 bit U/V. (YUV2).
353 A modern computer monitor works after another color scheme,
354 called RGB scheme, in which each of the colors Red, Green and
355 Blue are stored in their own luminescence. To show normal Video
356 data on your PC screen, you'll have to convert it somehow. This
357 could happen 1. during Capturing (most TV capture cards convert
358 YUV to RGB automatically), 2. during Encoding (If you encode to
359 normal MPEG2, you'll get YUV2 data) or 3. during decoding (If
360 you watch MPEG2 videos, your player does this conversion). For
361 the best result, the conversion should be done when you've got
362 loads of CPU time available anyway, during Encoding.
364 The second problem of normal video because of the resolution to
365 be too high, the picture is sent interlaced, meaning you only
366 send every second line in every frame, so that you'll always get
367 a frame with line 1,3,5,... and the next one with 2,4,6,...
368 Since a computer cannot easily distinguish, you could get
369 pictures with comb-like artefacts, not really looking nice.
370 The MPEG2 format also allows interlaced data. You could use
371 filters to de-interlace or simply decrease the resolution.
373 The third and worst problem is the amount of data. 1 second of
374 raw audio/video data should be about 20MB. Due to a slow bus
375 system (yes, the PCI bus isn't state of the art anymore), no
376 normal PC can cope with that. The first solution is to compress
377 the data before capturing it. The second is to reduce the
380 Another problem resulting from that big bunch of data is how to
381 store that stuff. In the last years, hard disks were getting
382 cheaper and bigger every month, but it's still not sensible to
383 store the whole stuff uncompressed. The first reasonable format
384 for compressed movie was MPEG1 (MPEG=Motion Picture Encoding
385 Group), which allowed to compress almost by the factor 4. The
386 same developers made the MPEG2 format, which also featured the
387 popular MPEG2 layer 3 sound format, known today as MP3,
388 and allowed a compression rate up to the factor 20.
389 The next step, MPEG4, was interrupted by the hacking of
390 Microsofts Reference Algorythm by the coder Gej, formerly called
391 DivX ;-). Allowing compression rates up to the factor 100 and
392 more, it's very popular for swapping movies over the Internet.
393 Due to legality reasons of DivX ;-), other programmers started
394 working on equal or better codecs, like OpenDivX, DivX4 and
398 Hope this was helpful.
399 Thanks to the help of the #lfs channel.
400 Alex Kloss (LX on #lfs on irc.linuxfromscratch.org)