Linux Video Stream Processing Tool - Examples
Keywords: DVD, digital video, DV, encoder, divx, DivX;-), lame, source, posix, avifile, opendivx, codec, linux, AC3, program stream, video, audio, transcode, decoder, stream, YV12

Digital Video
This chapter gives an introduction to Digital Video processing with transcode. Here is a list of features: AVI-files with Digital Video streams can be decoded with libdv (default) ffmpeg (-x ffmpeg) concatenating clips with directory mode and option "-i direname" before processing. a couple of fast or high-quality de-interlace filters available to enhance the quality. support for encoding to DV with libdv as raw stream or interleaved AVI-file. pass-through mode: raw DV -> AVI-file conversion. Unfortunately, while most linux player happily accept the AVI-DV files produced by transcode, the nonlinear DV video editor kino refuses to work with them. Digital Video DV AVI files DV streams pass-through mode de-interlacing guide anti-aliasing guide

Digital Video (DV) ---> MPEG-4
- Here is a 3 step guide to convert a DV tape to a compressed AVI MPEG-4 movie clip under linux using transcode. For a selection of a video codec implementation supported by transcode consult the modules info-page. You need Arne Schirmacher's nice tool dvgrab to transfer the DV tape to disk. Make sure, you use the "--format dv2" option and maybe "--autosplit" to split the tape into small pieces. Use AVI files, since libdv sound seems to be broken. Optionally, use tcprobe -i file.avi to find out important parameters: For example: `[tcprobe] RIFF data, AVI video [avilib] V: 25.000 fps, codec=dvsd, frames=633, width=720, height=576 [avilib] A: 48000 Hz, format=0x01, bits=16, channels=2, bitrate=1536 kbps, [avilib] 633 chunks, 4861528 bytes [tcprobe] summary for test-2002.10.04_14-47-25.avi, (*) = not default, 0 = not detected import frame size: -g 720x576 [720x576] frame rate: -f 25.000 [25.000] frc=3 audio track: -a 0 [0] -e 48000,16,2 [48000,16,2] -n 0x1 [0x2000] (*) bitrate=1536 kbps length: 633 frames, frame_time=40 msec` Fortunately, the auto-probing feature of transcode takes care of these details. To encode the clips, we have a number of options: writing a shell script, that feeds transcode with each file, using avimerge to create a single input file, using the directory mode with option "-i". This works only in connection with the import module import_dv.so. ### AVI-file Here, we use a single AVI-file file.avi with "dvsd" codec as an example:
  transcode | -i file.avi -x dv,avi
  | -I 1 -C 1 -z -k
|  | -o file-divxmp3.avi -y divx4

We use import_avi.so to extract the audio, which works flawless. Note that the audio is found in two places in the AVI-file. Firstly, interleaved in the DV video frame and secondly, the PCM audio track itself. This makes it possible to use the import module "dv" for audio extraction as long libdv is broken.
Note: some non-dvgrab produced AVI-files may have the audio ripped from the DV frames. In this case, you must use "-x dv,avi" or "-x dv,X", were X is one of (raw,mp3,ac3).
You can also reduce the picture to a quarter size "-r 2" to get rid of the interlace artifacts and don't need the de-interlace option "-I 1". This option is the fastes de-interlacing available, but is a simple interpolation. You might also want to try out the anti-aliasing feature with "-C 1" to process the whole frame but this is slow. The option "-z -k" flips the frame and make the necessary color space changes for the encoder.

### DV stream

Put all AVI-files or raw DV stream into a subdirectory, e.g., named "tape/".

transcode | -i tape/
| -I 3 -C 2 -z -k
|  | -o tape-divxmp3.avi -y divx4

The necessary import module is autodetected. tccat extracts the video stream of all AVI-files and concatenates them together to make the clips appear as a single DV stream for transcode. Here, the de-interlace option "-I 3", which drops one half-frame and interpolates by zooming to full frame size and, in principle, removes the interlace artifacts. We also try the anti-aliasing feature with "-C 2" to process the full frame afterwards, but this is slow.

- Well, that's it. Use avimerge to glue the matching clips together and burn the resulting file to CD.

  pass-through mode
  The pass-through mode is able to wrap raw Digital Video streams into AVI-files with the following command. Note, that the interleaved raw audio data can be transcoded to a separate audio track with the codec of your choice. However, this does not save space since Digital Video has identical frame size independent of the presence of audio. `transcode -i raw.dv -P 1 -o raw.avi -y raw` The opposite way is achieved by: `tcextract -i raw.avi -x raw > raw.dv`

  de-interlacing guide
  Underway. Tilmann Bitterberg did some testing of de-interlace filters available in transcode. You can view and read the result here.

  anti-aliasing guide
  Underway.

  Last modified: Fri Dec 6 16:25:56 Europe/Berlin 2002