For definiteness let's assume the final video will have a 16:9 aspect ratio with bottom field first interlacing order. The case where the final video will have have 4:3 aspect ratio is simpler and not treated here. We consider three types of conversions.
16:9 top field first -> 16:9 bottom field first
4:3 top field first -> 16:9 bottom field first
4:3 bottom field first -> 16:9 bottom field first
The first of these conversions can be done with a simple shift of
the entire video frame down by one scan line.
The other two of these conversions involve cropping and rescaling
the video in the vertical direction.
To avoid temporal aliasing when rescaling in the vertical direction
one must first separate each interlaced frame into two fields.
We do this using a frame-rate doubling motion compensating deinterlacer.
This preserves the best resolution.
Then we rescale and reinterlace.
ffmpeg -i src.avi -f wav -y src.wav
ffmpeg -i src.avi -f yuv4mpegpipe -pix_fmt yuv411p -y /dev/stdout |
yuvcorrect -T PROGRESSIVE 2>/dev/null |
y4mscaler -v 0 -I active=720x479+0+0 \
-O active=720x479+0+1 -O size=720x480 |
yuvcorrect -T INTERLACED_BOTTOM_FIRST 2>/dev/null |
ffmpeg -f yuv4mpegpipe -i /dev/stdin -i src.wav \
-interlace 1 -ildct -ilme -top 0 \
-vcodec dvvideo -acodec pcm_s16le \
-y src-new.avi
This relatively cheap way of switching the interlace order will leave
a black line at the top of the image. This line will not be noticable
as it will disappear in the overscan of most televisions. If it
bothers you, there is another way to switch the interlace order that
swaps fields between adjacent frames. That method does not leave a
blank line at the top, but is more complicated in that it also requires
shifting the audio by half a frame. It will not be discussed here.
$ iorder=INTERLACED_TOP_FIRSTotherwise, if the input video is bottom field first set
$ iorder=INTERLACED_BOTTOM_FIRSTNow enter the following commands
$ ffmpeg -i src.avi -f wav -y src.wav
$ ffmpeg -i src.avi -f yuv4mpegpipe -pix_fmt yuv411p -y /dev/stdout |
yuvcorrect -T $iorder 2>/dev/null |
yuvdeinterlace -d |
yuvfps -s 30000:1001 -r 30000:1001 |
yuvcorrect -T PROGRESSIVE 2>/dev/null |
y4mscaler -v 0 -I sar=NTSC -O sar=NTSC_WIDE \
-O size=720x480 -I active=720x360+0+60 |
yuvfps -s 60000:1001 -r 60000:1001 |
y4minterlace -ib |
ffmpeg -f yuv4mpegpipe -i /dev/stdin -i src.wav \
-interlace 1 -ildct -ilme -top 0 \
-vcodec dvvideo -acodec pcm_s16le \
-y src-new.avi
We use the same sequence of commands for converting top field first
and bottom field first source files.
After deinterlacing the image is rescaled so that the original scan
lines are no longer strictly supported by one field or the other.
Therefore it makes no quality difference
whether the original source was top field first or bottom field first.