What zapcvt can do for you...

This program serves as a format converter, a file splitter and a video-cut application. Except for format conversions your will not need to call it directly. The kzapdvr program will use it to split the recorded MPEG data into files of 2GByte (if you select this option) and zapcut can be used, as described below, to cut your recorded videos.

The short usage information for zapcvt is:

zapcvt is a PVA and PES format conversion, join and split utility. It can
read from stdin and write to stdout.  The output can also be piped thru a
viewer like mplayer - which might be useful for pva files.

usage: zapcvt [-m | -p | -n] [-s mbytes] [-o output] [-v] [files...]
            conversion, concatenation and split operations
       zapcvt -d [-v] [-c config] [files...]
            display pva or mpg files using the zapdvb defaults
       zapcvt [-h | -v [files...] ]
            display information and quit
       zapcvt -m -o output.mpg *.pva
            example: concatenate and convert pva files to a single mpg
       zapcvt -p -s 2048 -o basename
            example: convert stdin to pva files and split in 2GB parts
options:
       -d        : execute the viewer program defined by zapdvb
       -m        : convert output to MPEG if required
       -n        : do not convert on output
       -p        : convert output to PVA if required
       -r        : recalculate timestamps and rewrite headers

       -h        : show this text and quit
       -v        : print information about input and processing

       -g time   : goto position specified by time
       -u time   : stop output at specified time

       -c config : viewer config file (default: '$HOME$/.zapcvt')
       -o output : output file name   (default: stdout)
       -s MBytes : split output file into fragments of max MBytes size

If -o is used without a file name extension, pva or mpg are automatically
appended. If the -s output is used, the filename extension is prefixed by
a three digit sequence number (example: myFile000.pva).

Using zapcvt to convert from and to PVA

PVA is a format that was defined to be a simple wrapper around the output of a specific integrated circuit. It is not redundant, not better than PES and not very useful at all. But it is used by some tools (like PVACut). A standard format of MPEG video data is PES (Packetized Elementary Streams). PES is redundant (e.g. not so much affected by missing or corrupted bits) and widely used. Nice players for this format are MPlayer and Xine.

The following example shows how to convert from PES to PVA:

zapcvt -p -v -o result.pva input.mpg

The "-p" option causes the conversion and "-v" turns progress reporting on. Instead of using "-o" to specify an output file and giving an input file on the command line, you can use stdin and stdout:

cat input1.mpg input2.mpg | zapcvt -p -v > result.pva

Using zapcvt directly to Edit Videos

The important point are the "-g" and the "-u" options to specify a "goto" and an "until" position. Both arguments are followed by a number that specifies a file position in %. Here a few examples:

zapcvt raw.mpg -u 66.666 -o twoThirds.mpg
zapcvt raw.mpg -g 25 -u 75 -o halfOfIt.mpg
zapcvt raw.mpg -v -g5 -u15 -g20 -u40 -g50 -p -o somePeaces.pva

You should know that using "-g" or "-u" implies the "-r" option, so the time-line of the video is recalculated (starting at 0) and some information from the PES headers is dropped.

Other features of zapcvt

Sometimes it becomes necessary to split a large file into smaller pieces. Although the GNU split program could be used, this is usually not a good idea because that one is not aware of the PES (or PVA) syntax. You better use zapcvt in such cases:

zapcvt -s 2048 -o outfile.mpg infile.mpg

The "-o" option is required here, as zapcvt must know how to name the generated output files. In the example it will create files named "outfile001.mpg" and so on. The "-s" option is followed by an argument that indicates the maximum size of the fragments in MBytes (so the example creates 2GByte fragments). Other examples:

cat input*.pva | zapcvt -s 512 -m -o outfile
# -or-
cat input*.mpg | zapcvt -v -s 512 -p -o outfile

In these examples the "-p" option tells zapcvt to create files named like "outfile001.pva" or "-m" to create files named like "outfile001.mpg".

zapcvt can rewrite PES files to recalculate the time-line or simply to remove unneeded information from PES headers:

zapcvt -r -v -o outfile.mpg infile.mpg

The "-r" option can be used together with other operations but is ignored when the input format is PVA. "-r" is implied when "-g" or "-u" are used to edit a video (see below).

Editing Videos with zapcut

This shell-script opens MPlayer and should be run from inside a shell. Maximise the window to make sure that you can read the output! The script takes a filename as its first argument. The following args are pairs of start and stop positions (in percent of the input file size).

In a typical edit session you call the script multiple times to locate those parts of the video that are to be removed. In the following example you start at 3%, narrow down the precise position where your movie starts and advance to a part that is to be removed at 20%:

#your initial estimate about the start pos:
zapcut raw.mpg 3
# now have another try at 2.8
zapcut raw.mpg 2.8
# ok, you think 2.85 is fine, search the 1st block to remove...
zapcut raw.mpg 2.85 20
# pressing the "page-up" key and watching the output you found it ..
zapcut raw.mpg 2.85 20.93
# find the end of this block and search the next block to remove ...
zapcut raw.mpg 2.85 20.93  28
zapcut raw.mpg 2.85 20.93  28.12
zapcut raw.mpg 2.85 20.93  28.12 42
zapcut raw.mpg 2.85 20.93  28.12 42.32
zapcut raw.mpg 2.85 20.93  28.12 42.32  74
zapcut raw.mpg 2.85 20.93  28.12 42.32  74.12
zapcut raw.mpg 2.85 20.93  28.12 42.32  74.12 95.3

With some practice you will become quite fast editing a movie. This part of the procedure typically takes 5 minutes or less. Tip: for a typical movie one percent of the file-size is one minute of play-time. When you are ready with this you might want to create an output file on your local computer:

zapcut raw.mpg 2.85 20.93  28.12 42.32  74.12 95.3 - outfile

This creates the file "outfile.mpg" in your local directory. You could also invoke scp to copy the output to a remote computer:

zapcut raw.mpg 3.25 84.2 - jpf@alpha:/Movies/outfile.mpg