****************************************************************************
*                         AVI2YUV version 0.97                             *
*                                                                          *
****************************************************************************


Contents:
=========

 1) Overview
 2) Copyright
 3) Requirements
 4) Platforms
 5) Compilation of avi2yuv
 6) Options of avi2yuv
 7) Usage of avi2yuv
 8) Compilation of mpeg2encode
 9) Video encoding with mpeg_encode
10) Video encoding with mpeg2encode
11) Audio encoding
12) multiplexing to system layer
13) Some hints
14) Author


***********************************************************************
To state this at the top of the README:
avi2yuv will only run on Intel processors (or 32 bit processors with
LSB byte order). So it will not work on SUN or DEC Alpha processors
without modification.
***********************************************************************



1) Overview:
============

avi2yuv is a program to convert AVIs into the YUV format for input of the
Berkeley mpeg_encoder. Alternatively you can use mpeg2encode by the
MPEG Software Simulation Group or save the frames as single files (YUV or
BMP).

The following AVI compression methods are supported:

MJPG   created by the cards listened in section 4) (e.g. FAST FPS60)
DIB    uncompressed 16, 24 or 32 bit
YVU9   Indeo RAW
Y41P   Hauppauge WinTV format

The following output formats are supported:

YUV    into single files (one per frame)
YUV    to stdout for direct input to mpeg_encode
BMP    into single truecolor files (one per frame)

The following audio output formats are supported:

PCM    raw audio data
WAV    audio data with WAVE header


2) Copyright:
=============

AVI2YUV.C

Copyright (c) 1996/99 by Bernhard Schwall (b.schwall@gmx.de)

Based on SHOWRIFF.C
(c)94 UP-Vision Computergrafik for c't 11/1994

Some parts of the program are taken for libjpeg version 6.
"this software is based in part on the work of the independant JPEG Group"

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation;

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.



3) Requirements:
================

Sourcecode and compiled version of the Independant JPEG Group's JPEG
  software, also know as libjpeg, version 6a.
  Sourcecode can be found at 
    ftp://ftp.uu.net/graphics/jpeg
    ftp://ftp.informatik.uni-bonn.de/pub/graphics/jpeg/jpegsrc.v6a.tar.gz

Compiled version of the Berkeley MPEG-1 Video Software Encoder version 1.5b.
  Sourcecode can be found at 
    ftp://mm-ftp.cs.berkeley.edu
    ftp://ftp.informatik.uni-bonn.de/pub/graphics/mpeg/encode/
          mpeg_encode-1.5b-src.tar.gz
    ftp://sunsite.unc.edu/pub/Linux/apps/graphics/convert

Sourcecode of mpeg2encode.
  It can be found at
    ftp://ftp.netcom.com/pub/cfogg/mpeg2/mpeg2convert-1.1a.tar.gz
    ftp://sunsite.unc.edu/pub/Linux/apps/graphics/convert

An MPEG audio encoder if you want to encode the audio, too.
  One can be found at 
    ftp://ftp.crs4.it/mpeg/programs/mpegaudio.tar.Z
  If you know any good PD/freeware encoder please let me know.

A MPEG multiplexer to create the MPEG system layer out of the video and 
  audio stream. The sourcecode can be found at 
     ftp://ftp.informatik.tu-muenchen.de/pub/comp/graphics/mpeg/mplex/
           mplex-1.1.tar.gz
     ftp://ftp.crs4.it/mpeg/programs/mplex*

If you want to concatenate mpeg to one big mpeg you could use
     mpegUtil.tar.Z

You should also have a look at
  http://www.prism.uvsq.fr/public/wos/multimedia/medias.html
  http://www.mpeg.org/index.html
  http://www.bok.net/~tristan/MPEG.html
  http://www.creative.net/~tristan/MPEG.html (mirror of www.bok.net)
for MPEG related software and documentations.

The latest version of avi2yuv can be found at
  ftp://sunsite.unc.edu/pub/Linux/apps/graphics/convert



4) Platforms:
=============

avi2yuv is known to work with the following hardware and software:

Intel based hardware with 32 bit compiler (LSB byte order is expected)

Videocards:
FAST FPS60
FAST Movie Machine II with MJPEG extention (should work)
FAST AV Master
MIRO DC10/DC20/DC30
Matrox Rainbow Runner Studio
AVIs created with the FAST FPS60 and edited with Adobe Premiere LE 4.0.
Uncompressed 16, 24 and 32 bit AVIs created with Adobe Premiere LE 4.0.
YVU9 AVIs created with Adobe Premiere LE 4.0.
Y41P AVIs recorded with a Bt848 card (e.g. Hauppauge WinTV PCI)

Software:
Linux 1.2.13 or 2.0.33
Berkeley MPEG encoder Version 1.5b
mpeg2encode Version 1.1a
Version 3.9t of musicin
MPLEX 1.1

mpeg2encode does also work under DOS if compiled with DJGPP (tested with
version 2.5.7). It should also work with every 32 bit compiler (e.g. emx
under OS/2).

avi2yuv will only work with mpeg_encode if the pipe is 8 bit clean (depends
on the compiler and the OS). It should work under DOS if compiled with DJGPP
but you'll need a lot of disk space as the output of avi2yuv will be
temporarely saved to disk as DOS isn't a multitasking OS (not tested).



5) Compilation of avi2yuv:
==========================

1) Edit the Makefile
  INSTDIR should point to the directory where you wish to install avi2yuv
  INCDIR  must point to the directory the jpeg-6a sources are.
  LIBS    must point to the directory your libjpeg.a library is.
          Alternativ you can use the shared library but be aware that avi2yuv
          runs slightly faster with the statically linked libjpeg.
2) Type 'make' and the program should be build.
3) You can type 'make install' to install the program on your system.



6) Options of avi2yuv:
======================

  avi2yuv [options] file.avi

  where options can be:
  -aNNN        Start with decoding at frame NNN (first frame has number 1).

  -cbCCC       Crop the bottom CCC pixel of the video
  -clCCC       Crop the left CCC pixel of the video
  -crCCC       Crop the right CCC pixel of the video
  -ctCCC       Crop the top CCC pixel of the video
               The cropping is done before the video is scaled.

  -eMMM        End with decoding at frame MMM
               -a and -e do effect the saving of the wave file, too.

  -fFPS        Set the frame rate of the output stream to FPS. Usefull if you
               have recorded the AVI with 12 FPS and want to create a 25 FPS
               MPEG (the MPEG standard doesn't allow lower frame rates than
               25. Well, 23.976 is defined but very unusual). The new FPS must
               be higher than the FPS of the AVI. This frame rate is also
               used if saving sound (See chapter 13 for details).

  -i+          When saving only field A or B of an interlaced video using
               -nX the frame numbers are doubled so field A gets even
               numbers and field B gets odd numbers.
               i+  field B follows field A (04=A, 05=B for frame 2)
               i-  field A follows field B (03=B, 04=A for frame 2)

  -nX          X specifies the frame to be saved. If the size of the AVI is
               larger than 384x288 (e.g. 768x576) you can specify which
               field of the video to save to single frames. See chapter 13
               for a detailed description. Possible options are:
               a  save field A, ignore field B
               A  save field A, double every line, ignore filed B
               b  save field B, ignore field A
               B  save field B, double every line, ignore filed A
               f  interlace both fields
               m  mix both files, top is files A, bottom is filed B

  -spic%i.yuv  Save the frames to pic%i.yuv (in YUV format) instead of writing
               them to stdout. The name must be a 'printf' formatted string
               with one integer argument.
               e.g. pic%i.yuv will save as pic1.yuv, pic2.yuv ....
                    pic%03i.yuv will save as pic001.yuv, pic002.yuv ...
  -spic%i.bmp  Save the frames to pic%i.bmp (in BMP format)

               Note: the file extension is required and selects the output
               format. It must be in lower case.

  -v           Print the format of the AVI. This will give you an overview of
               the format of the AVI file.

  -t           Test the correctness of the frames of an MJPEG AVI. It does
               two things: first it parses the AVI and reports dropped
               frames. Second it tests for correct JPEG header in MJPEG
               AVIs. The Matrox RainbowRunner driver sometimes creates
               incorrect frames which aren't JPEGs. These frames are
               reported as "corrupt frames" and can be replaced with a video
               editor (avi2yuv will do this automatically if decoding the
               frames for mpeg_encode or mpeg2encode). If you have an
               incomplete AVI this will report the true number of frames
               in the AVI (this even works for unsupported compression
               types).

  -wsound.pcm  Output the sound (if the AVI has sound) to the file sound.pcm.
               This is the raw sound data without any header intended for
               use with musicin.
               See the hints (chapter 13) for more info of the sound. The
               option workes with '-v', too.
  -wsound.wav  Output the sound (if the AVI has sound) to the file sound.wav
               in WAVE format.
               See the hints (chapter 13) for more info of the sound. The
               option workes with '-v', too.

  -xAAA        Scale the video to width AAA.
  -yBBB        Scale the video to height BBB.

               If you try to scale up the video will be centered in the
               middle of the mpeg. The aspect ratio of the original AVI is
               remains in the MPEG so there could be some black stripes if
               the output size doesn't have the same aspect ratio as the AVI.

  -z           The scaled video will have the size given by -x and -y
               regardless of the aspect ratio the original video has.

  file.avi     The AVI file. This must be in MJPG, RGB, YVU9 or Y41P format.



7) Usage of avi2yuv:
====================

First you should run avi2yuv with the -v option (or with the -t option to
evaluzate the correctness of the AVI), e.g.
  avi2yuv -t /video/test.avi
This will give you an output similar to the following:

Format of file /video/test.avi (1599488 bytes):

Videostream info
Width            : 384
Height           : 288
TotalFrames      : 55
MicroSecPerFrame : 38632 (25.885 fp/s)
Video Handler    :
Planes           : 1
Bits per pixel   : 24
Compression      : MJPG
Audiostream info
Wave format      : PCM
Channels         : 1
SamplesPerSec    : 44100
BitsPerSample    : 16
- Empty frame 18
Info for mpeg_encode
Picture size X   : 384
Picture size Y   : 288
MicroSecPerFrame : 38632 (25.885 fp/s)
Frames scanned   : 55
Dropped frames   : 1
Corrupt frames   : 0

This is a 384x288 MJPG coded AVI with 55 frames. It has also mono sound
(Channels = 1) with 44KHz and 16 bit.
It has one dropped frame (frame 18) and no corrupt frame (this info only is
shown if avi2yuv was started with the option "-t").

If you don't get the Video Handler = MJPG, DIB (and Bits per pixel = 16, 24,
32), YVU9 or Y41P your AVI wouldn't be read correct by avi2yuv.

Be aware that normally you don't have to use the -fFPS option if you have
a MJPEG-AVI with sound and you get a framerate of 24-26.

If the aspect ratio of the AVI isn't the same as the aspect ratio of the
decoded frames (e.g. AVI has 384x288 and you decode with 352x288) the -v
option will also tell you the effective size of the video (e.g. 352x264). This
is the size without the blank lines. This is for your information only . For
mpeg_encode you must give the size of the decoded frames (e.g. 352x288).



8) Compilation of mpeg2encode:
==============================

You have to use a 32 bit compiler such as DJGPP under DOS.

1) To enable the AVI support in mpeg2encode first uncompress the original
   source.
   Change into the directory 'mpeg2/src'.
   If you have version 1.2 of mpeg2encode first edit the file
   'mpeg2enc/Makefile':
     change line 36 from:
       CFLAGS = -O2 -Wall
     to:
       CFLAGS = -O2
   Now type
   patch -p0 < patch.mp2
   If you're working under DOS with DJGPP and patch says it can't create the
   backup file you've to recompile patch. The precompiled version 2.1 shipped
   with djgpp 2.5.8 (pat21bn.zip) didn't work for me.
   Goto step 2) if you don't have any problems.
   To recompile patch unpach the source (pat21sr.zip) and
   copy configh.dos config.h
   copy makefile.in makefile
   Edit the makefile and delete all @....@ entries, e.g
   orig:  LIBS = @LIBS@
   new:   LIBS =
   Edit the file config.h and undefine
   #undef NODIR
   This will enable the creation of the backupfiles as *.c~ instead of
   *.c.orig.
   Now type make and patch should be made. Finally run
   coff2exe patch and copy patch.exe to your bin-directory (e.g. djgpp\bin)
2) Now edit the Makefile of mpeg2encode and set the CFLAGS to the path of
   your jpeg-6a source code. Remember to use slashes under DOS if using 
   DJGPP.
3) Type make and mpeg2encode should be made.

To enhance execution time I've replaced all 'double' variables by 'float'
variables. This did enhance the execution time a lot on my system.



9) Video encoding with mpeg_encode:
===================================

Now you can use the Berkeley mpeg_encode to make an MPEG out of your AVI.
Use a parameter file with the following settings (you can change most of
the parameters for your personal fitting):

File: avi2yuv.param
---------- cut here ----------
# name of the output file
OUTPUT		test.mpg

PATTERN		IBBPBBPBBPBBPBB
# don't change the next line
BASE_FILE_FORMAT	YUV
# so you must start avi2yvu with '-x320 -y240'
YUV_SIZE	320x240
# don't change the next three lines
YUV_FORMAT	UCB
INPUT_CONVERT	*
INPUT_DIR	stdin
GOP_SIZE	15
SLICES_PER_FRAME	1
PIXEL		HALF
RANGE		15
PSEARCH_ALG	LOGARITHMIC
BSEARCH_ALG	SIMPLE
IQSCALE		8
PQSCALE		10
BQSCALE		25
REFERENCE_FRAME	ORIGINAL
BIT_RATE  1081200
BUFFER_SIZE 327680
# set FRAME_RATE to 30 if you're using NTSC
FRAME_RATE 25
---------- cut here ----------


For the meaning of the parameters read the documentation of mpeg_encode.

Now you can start the encoding with:
avi2yuv -x320 -y240 /video/test.avi | mpeg_encode avi2yuv.param
You shouldn't make you mpeg larger than 
  352x288 for PAL
  352x240 for NTSC
as that's the standard and the hardware playback boards can't handle files
larger than this (at least mine can't).
Also the resolution has to be devidable by 16! So use 160x128 or 240x176
instead of 160x120 or 240x180.

After some time you should have the file test.mpg which is the mpeg of your
AVI. With the settings above I got 0.5 fps decoded and converted on my 
AMD 486DX4/100. While this encoding 25% of the CPU power was used for
decoding the AVI with avi2yuv and 75% was used to encode the MPEG.

If you don't want to encode audio (or you haven't recorded audio) you're ready
now. Otherwise go on with the audio encoding.



10) Video encoding with mpeg2encode:
====================================

To create a MPEG1 stream with mpeg2encode first run avi2yuv with the '-v'
option. This will give you the number of frames you have to set in the config
file of mpeg2encode.

Use a parameter file with the following settings (you can change most of
the parameters for your personal fitting). This has slightly changed to the
file shipped with mpeg2encode so don't try to use the original one (it also
has changed to the version used in 0.9.4):

File: MPEG.avi2yuv  (mpeg.avi under DOS)
---------- cut here ----------
recorded from video , 25 frames/sec
/video/test    /* name of source files */
-         /* name of reconstructed images ("-": don't store) */
-         /* name of intra quant matrix file     ("-": default matrix) */ 
-         /* name of non intra quant matrix file ("-": default matrix) */
/dev/null /* name of statistics file ("-": stdout ) */
3         /* input format: 0=*.Y,*.U,*.V, 1=*.yuv, 2=*.ppm, 3=*.avi */ 
0         /* number of frames, 0 == read all frames*/
1         /* number of first frame */
00:00:00:00 /* timecode of first frame */
12        /* N (# of frames in GOP) */
4         /* M (I/P frame distance) */
1         /* ISO/IEC 11172-2 stream */
0         /* 0:frame pictures, 1:field pictures */
320       /* horizontal_size */
240       /* vertical_size */
0 0 0 0   /* cropping left top right bottom */
0         /* 0:field A, 1:field B  for interlaced AVIs */
8         /* aspect_ratio_information 8=CCIR601 625 line, 9=CCIR601 525 line */
3         /* frame_rate_code 2=23.976, 3=25, 4=29.97, 5=30 frames/second */
1098000.0 /* bit_rate (bits/s)  1152000.0 1081200.0 */
20        /* vbv_buffer_size (in multiples of 16 kbit) */
0         /* low_delay  */
1         /* constrained_parameters_flag */
4         /* Profile ID: Simple = 5, Main = 4, SNR = 3, Spatial = 2, High = 1 */
8         /* Level ID:   Low = 10, Main = 8, High 1440 = 6, High = 4          */
1         /* progressive_sequence */
1         /* chroma_format: 1=4:2:0, 2=4:2:2, 3=4:4:4 */
1         /* video_format: 0=comp., 1=PAL, 2=NTSC, 3=SECAM, 4=MAC, 5=unspec. */
5         /* color_primaries */
5         /* transfer_characteristics */
5         /* matrix_coefficients */
320       /* display_horizontal_size */
240       /* display_vertical_size */
0         /* intra_dc_precision (0: 8 bit, 1: 9 bit, 2: 10 bit, 3: 11 bit */
0         /* top_field_first */
1 1 1     /* frame_pred_frame_dct (I P B) */
0 0 0     /* concealment_motion_vectors (I P B) */
0 0 0     /* q_scale_type  (I P B) */
0 0 0     /* intra_vlc_format (I P B)*/
0 0 0     /* alternate_scan (I P B) */
0         /* repeat_first_field */
1         /* progressive_frame */
0         /* P distance between complete intra slice refresh */
0         /* rate control: r (reaction parameter) */
0         /* rate control: avg_act (initial average activity) */
0         /* rate control: Xi (initial I frame global complexity measure) */
0         /* rate control: Xp (initial P frame global complexity measure) */
0         /* rate control: Xb (initial B frame global complexity measure) */
0         /* rate control: d0i (initial I frame virtual buffer fullness) */
0         /* rate control: d0p (initial P frame virtual buffer fullness) */
0         /* rate control: d0b (initial B frame virtual buffer fullness) */
2 2 11 11 /* P:  forw_hor_f_code forw_vert_f_code search_width/height */
1 1 3  3  /* B1: forw_hor_f_code forw_vert_f_code search_width/height */
1 1 7  7  /* B1: back_hor_f_code back_vert_f_code search_width/height */
1 1 7  7  /* B2: forw_hor_f_code forw_vert_f_code search_width/height */
1 1 3  3  /* B2: back_hor_f_code back_vert_f_code search_width/height */
---------- cut here ----------

For the meaning of the parameters read the documentation of mpeg2encode.

The following values should be set acording to your AVI and your desired
output MPEG:

'number of frames': 
    These are the number of frames encoded into the MPEG. This can be equal or
    less than the value given by avi2yuv. If it is set to 0 the MPEG will
    contain all frames of the AVI beginning with frame 'number of first
    frame'.
'number of first frame':
    Number of the first frame in the AVI to be encoded in the MPEG. The
    first frame of the AVI has number 1.
'horizontal_size':
'vertical_size':
    This is the resolution of the MPEG. If 'horizontal_size' is set to 0 the
    MPEG has the same horizontal and vertical size as the AVI.
    If the MPEG- and AVI-size differs the AVI is automatically scaled up or
    down. If the AVI it's smaller the video will be centered in the middle of
    the MPEG. In both cases the aspect ratio will be the same as in the AVI.
    There is one special case if scaling down from 352x288 to a size with
    aspect ratio of 4:3 (e.g. 320x240). Then the aspect ratio is lost and the
    video is scaled to 4:3 aspect ratio. This is done as there are two
    standards for recording video: squared pixels (e.g. 320x240 or 384x288)
    and CCIR601 (352x288). So if your video card records with CCIR601 and you
    want to play back the MPEG with a software player you should scale it to
    320x240 as the PC normally uses square pixels.
cropping:  (L T R B)
    The AVI is cropped (pixels are cut off) at the left, top bottom and
    right by L, T, R and B pixels. The cropping is done before the frame
    is scaled. The scaling is done with the original aspect ratio of the
    AVI.
bit_rate:
    This is the video bit rate of the AVI. Higher bitrates give better
    quality, lower bitrates give smaller files.
    For 320x240 or 352x288 MPEG the standard is 1098000.0 (= 134 KB/s).
    For 240x180 MPEG 800000.0 should be enough.
    I'm using up to 1640000.0 for 352x288 and sport scene which will give
    a 200 KB/s MPEG with good quality for fast motion in the video.

You shouldn't make you mpeg larger than 
  352x288 for PAL
  352x240 for NTSC
as that's the standard and the hardware playback boards can't handle files
larger than this (at least mine can't).
Again be shure to use slashes for the pathname if you're under DOS and
compiled mpeg2encode with the DJGPP.

Now you can start the encoding with:
mpeg2encode MPEG.avi2yuv test.mpg

While encoding some statistics for the encoding is displayed. (frames per
second encoded and remaining time (estimation) for the encoding).

After some time you should have the file test.mpg which is the mpeg of your
AVI. With the settings above I got 0.22 fps decoded and converted on my 
AMD 486DX4/100. As you see this is only half the speed of mpeg_encode but it's
really worth waiting if you make bigger MPEGs (e.g. 320x240). Especially if
there is a lot of motion or fine structure in the video you should use
mpeg2encode if the resolution of the MPEG is bigger than 160x120.

Be aware that frame rate adjustment isn't available with mpeg2encode.

If you want to encode the whole AVI in it's original size you can set the
values for 'number of frames', 'horizontal_size' and 'vertical_size' to 0.

If you don't want to encode audio (or you haven't recorded audio) you're ready
now. Otherwise go on with the audio encoding.



11) Audio encoding:
===================

If you have an MPEG-audio encoder you can add the commandline option
'-wtest.pcm' to save the audio of the AVI (if there is audio). Use options
-a and -e to crop the audio at the beginning and the end if you've done so
with the video.
This can either be done while encoding the mpeg or you can rerun avi2yuv
with the '-v' option.
Caution: There is no test about a legal audio format if saving audio in pcm
or wave format.
Now you can start musicin and enter your filenames and parameters for the
audio encoding. E.g. you call the output file test.mp2.
Be aware that you must have 16 bit audio for using 'musicin' and that
avi2yuv can't convert 8 bit to 16 bit audio. So either record your audio
with 16 bit or use a separate converter. Also you must record the audio
without compression.
You'll get the best results if you record with 44100 KHz, 16 bit and
mono or stereo depending on your input source. You can set the MPEG-audio
bitrate to 112 KBit/sec for stereo to get good results (that's the bitrate
XingCD is using for the audio).

If you want to see how long the audio encoding will take you can apply
patch.audio to the sourcecode of mpegaudio.



12) Multiplexing to system layer:
=================================

Now you can start mplex to multiplex video and audio:
mplex test.mpg test.mp2 test_s.mpg

If you want to use mplex in a batch file you could apply patch.mplex11 to
the source of mplex 1.1. This will set some standard values and you aren't
promptet for these values anymore.

The resulting file test_s.mpg is the system layer stream you can view with
your favorit MPEG player.



13) Some hints:
===============

You'll get the best results if you record the video with
384x288x25 (PAL) or
320x240x30 (NTSC)
or even less resolution if your video card is able to do so (the FPS60 isn't).
To create MPEG1 files don't record with higher resolutions. This will result
in recording both fields of the video. On frame (or picture) of the video is
defined as two fields which are broadcasted every 50th (PAL) or 60th (NTSC)
second. Two fields are combined to one frame while displaying the video.
(e.g. PAL has a resolution of 768x576 with 25 Hz which is broadcasted as
768x288 with 50 Hz).

If you want to extract single frames out of the video or want to produce
MPEG2 streames you can record both fields and extrace either field A, filed
B or a combinition of both frames by using the option '-n':
-na will only save field A of every frame thus ignoring field B completely.
-nA will only save field A but doubled every line so the aspect ratio
    of the picture will be correct.
-nb will only save field B of every frame thus ignoring field A completely.
-nB will only save field B but doubled every line so the aspect ratio
    of the picture will be correct.
-nf will interlace both fields and output one frame. This will result in
    ugly "stripes" is the video contains movement.
-nm will mix both fields in one frame by saving field A at the top of the
    frame and field B at the bottom of the frame. This option really isn't
    usefull for anything.

Combining -na and -nb with the -i option and calling avi2yuv twice it's
possible to save both frames 'interleaved'. This means field A is saved with
even numbers and field B with odd numbers. 

e.g.

avi2yuv -stest%02i.bmp -i+ -nA -a2 -e5 test.avi

produces files: test04.bmp test06.bmp test08.bmp test10.bmp

avi2yuv -stest%02i.bmp -i+ -nB -a2 -e5 test.avi

produces files: test05.bmp test07.bmp test09.bmp test11.bmp

By using -i- field B is stored befoe field A. As there is no way to
determine whiche field order is used in the AVI (this depends on the driver
of the videocard and meight change from version to version) you must
experience the correct settings.

There is one problem with the field handling. The AVI always stores the
frame resolution in it's header so the saved frame always has athe
resulution of the frame even if you only save on field. To fix this you
should crop the video if only saving one frame. E.g. "-na -cb288" for PAL.
Don't use this if using -nA or -nB option as this will scale the field to
its correct size.

Another problem could happen with some video cards (e.g. FPS60). The FPS60
claims to record 768x576 if recording both frames. In reality it only
records 384x576 which results in two "little" pictures side by side instead
of one picture when saving single fields. This only could be fixed with a
hack in avi2yuv which I think isn't usefull as you could directly record
with 384x288 which gives much better quality.

The sound should be recorded with 44.1KHz, 16 bit and mono or stereo depending
on the source.
If you use musicin for audio encoding the frequency must be one of 32000,
44100 or 48000 Hz and it must be recorded with 16 bit.
The sound is cropped if options -a and -e are used but there is one problem
with this. Some recording cards don't write the intended frame rate (the one
the user wanted to record with, e.g. 25 fps) in the avi header. Instead they
write the real frame rate (e.g. 24.9 fps) which depends on the dropped frames.
As there is no way to find out the intendet frame rate the sound cropping
isn't correct if your videocard writes the real frame rate in the avi header.
To avoid this use the option -f to give the real frame rate for the audio.

If you playback the MPEG with a software player such as vmpeg or XingPlay you
could get some problems with the video and audio sync if you don't have a fast
PC. This will result in non synchronous playback or corrupt sound. All this
wouldn't happen with a hardware mpeg decoder.



14) Author:
===========

Bernhard Schwall
Roermonder Str. 286
D-52072 Aachen
Germany
e-mail: b.schwall@gmx.de

If you find a bug or have any enhancements for my code please let me know.
Please let me also know if you had success running avi2yuv on a not mentioned
platform or with an AVI created with an unmentioned compression card.

The latest version of avi2yuv can be found at
  ftp://sunsite.unc.edu/pub/Linux/apps/graphics/convert
