[FFmpeg-devel] [RFC] Interlaced material, pix_fmt change, auto-inserted scaler

Mark Himsley mark at mdsh.com
Mon Jul 25 19:12:25 CEST 2011


Sorry for a very long rational for a very short patch.

Cutting to the chase: What do you think of the attached patch?


Basically: I have been getting some strange colour artefacts when I 
convert from yuv420p to yuv422p on interlaced material.

Here is a demonstration clip:
http://commondatastorage.googleapis.com/himslm01/976_0003_01.AVI

The clip is an original DV25 clip created in a camera. The important 
part is the first 200 frames where there is a whip-pan across a bright 
green light switch.

If I convert that clip to a 422 format, I've chosen DV50 for ease of 
this demonstration but I have also created IMX30 MPEG 2 video and it 
shows the same issue I'm trying to describe:

ffmpeg -loglevel debug -i 976_0003_01.AVI -vcodec dvvideo -pix_fmt 
yuv422p -acodec pcm_s16le 976_0003_01.DV50.avi

(full output of that command is below)

If I look at the 422 output at field rate (for instance in a video 
editor) then I can see that something is wrong with the chroma.

I think I can also demonstrate that using FFmpeg by using the yadif 
video filter on the original 420 and the new 422 copy:

ffmpeg -loglevel debug -i 976_0003_01.DV50.avi -vframes 200 -vf yadif=1 
-r 50 -f image2 422%04d.png

frame 122 is a good one to compare,

png taken from original footage:
http://commondatastorage.googleapis.com/himslm01/orig0122.png

png taken from conversion to 422:
http://commondatastorage.googleapis.com/himslm01/4220122.png

You can see the big difference.


But I noticed that if I specifically add an interlaced aware scale in 
the video filter, the chroma is correct.

ffmpeg -loglevel debug -i 976_0003_01.AVI -vcodec dvvideo -pix_fmt 
yuv422p -acodec pcm_s16le -vf scale=0:0:interl=-1 976_0003_01.DV50-vf.avi


The attached patch makes scale default to being interlaced aware. Is 
that a bad thing?


If you feel this patch will be ok I'll send it again along with updated 
documentation with no training white space.



$ ~/src/ffmpeg/ffmpeg -loglevel debug -i 976_0003_01.AVI -vcodec dvvideo 
-pix_fmt yuv422p 976_0003_01.DV50.avi
ffmpeg version N-31249-g16a565d, Copyright (c) 2000-2011 the FFmpeg 
developers
   built on Jul  5 2011 15:12:25 with gcc 4.4.3
   configuration: --cpu=i686 --enable-static --extra-cflags='--static 
-I$PREFIX/include' --extra-libs='-static -L$PREFIX/lib' 
--prefix=/usr/local --enable-ffplay --enable-ffprobe --enable-ffserver 
--enable-gpl --enable-nonfree --enable-pthreads --enable-x11grab 
--enable-libdirac --enable-libfaac --enable-libgsm --enable-libmp3lame 
--enable-libopenjpeg --enable-libspeex --enable-libtheora 
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid 
--enable-libfreetype
   libavutil    51. 11. 0 / 51. 11. 0
   libavcodec   53.  7. 0 / 53.  7. 0
   libavformat  53.  5. 0 / 53.  5. 0
   libavdevice  53.  2. 0 / 53.  2. 0
   libavfilter   2. 24. 3 /  2. 24. 3
   libswscale    2.  0. 0 /  2.  0. 0
   libpostproc  51.  2. 0 / 51.  2. 0
[avi @ 0xb27ce20] Format avi probed with size=2048 and score=100
[AVI demuxer @ 0xb27d3a0] use odml:1
st:0 removing common factor 1000 from timebase
[avi @ 0xb27ce20] All info found
Input #0, avi, from '976_0003_01.AVI':
   Duration: 00:00:19.00, start: 0.000000, bitrate: 30356 kb/s
     Stream #0.0, 1, 1/25: Video: dvvideo, yuv420p, 720x576 [PAR 64:45 
DAR 16:9], 1/25, 25 tbr, 25 tbn, 25 tbc
     Stream #0.1, 2, 1/48000: Audio: pcm_s16le, 48000 Hz, 2 channels, 
s16, 1536 kb/s
[buffer @ 0xb2846a0] w:720 h:576 pixfmt:yuv420p tb:1/1000000 sar:64/45 
sws_param:
[buffersink @ 0xb278040] auto-inserting filter 'auto-inserted scaler 0' 
between the filter 'src' and the filter 'out'
[scale @ 0xb277c80] w:720 h:576 fmt:yuv420p -> w:720 h:576 fmt:yuv422p 
flags:0x4
Output #0, avi, to '976_0003_01.DV50.avi':
   Metadata:
     ISFT            : Lavf53.5.0
     Stream #0.0, 0, 1/25: Video: dvvideo, yuv422p, 720x576 [PAR 64:45 
DAR 16:9], 1/25, q=2-31, 200 kb/s, 25 tbn, 25 tbc
     Stream #0.1, 0, 3/125: Audio: mp2, 48000 Hz, 2 channels, s16, 64 kb/s
Stream mapping:
   Stream #0.0 -> #0.0
   Stream #0.1 -> #0.1
Press [q] to stop, [?] for help
frame=  475 fps= 14 q=0.0 Lsize=  133782kB time=00:00:19.00 
bitrate=57681.0kbits/s
video:133594kB audio:148kB global headers:0kB muxing overhead 0.029508%
himslm01 at himslm01:~/Servers/dump.jupiter.dump/Mark Himsley/FIDO$ 
~/src/ffmpeg/ffmpeg -loglevel debug -i 976_0003_01.AVI -vcodec dvvideo 
-pix_fmt yuv422p -acodec pcm_s16le 976_0003_01.DV50.avi
ffmpeg version N-31249-g16a565d, Copyright (c) 2000-2011 the FFmpeg 
developers
   built on Jul  5 2011 15:12:25 with gcc 4.4.3
   configuration: --cpu=i686 --enable-static --extra-cflags='--static 
-I$PREFIX/include' --extra-libs='-static -L$PREFIX/lib' 
--prefix=/usr/local --enable-ffplay --enable-ffprobe --enable-ffserver 
--enable-gpl --enable-nonfree --enable-pthreads --enable-x11grab 
--enable-libdirac --enable-libfaac --enable-libgsm --enable-libmp3lame 
--enable-libopenjpeg --enable-libspeex --enable-libtheora 
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid 
--enable-libfreetype
   libavutil    51. 11. 0 / 51. 11. 0
   libavcodec   53.  7. 0 / 53.  7. 0
   libavformat  53.  5. 0 / 53.  5. 0
   libavdevice  53.  2. 0 / 53.  2. 0
   libavfilter   2. 24. 3 /  2. 24. 3
   libswscale    2.  0. 0 /  2.  0. 0
   libpostproc  51.  2. 0 / 51.  2. 0
[avi @ 0xac6ee20] Format avi probed with size=2048 and score=100
[AVI demuxer @ 0xac6f3a0] use odml:1
st:0 removing common factor 1000 from timebase
[avi @ 0xac6ee20] All info found
Input #0, avi, from '976_0003_01.AVI':
   Duration: 00:00:19.00, start: 0.000000, bitrate: 30356 kb/s
     Stream #0.0, 1, 1/25: Video: dvvideo, yuv420p, 720x576 [PAR 64:45 
DAR 16:9], 1/25, 25 tbr, 25 tbn, 25 tbc
     Stream #0.1, 2, 1/48000: Audio: pcm_s16le, 48000 Hz, 2 channels, 
s16, 1536 kb/s
File '976_0003_01.DV50.avi' already exists. Overwrite ? [y/N] y
[buffer @ 0xac76600] w:720 h:576 pixfmt:yuv420p tb:1/1000000 sar:64/45 
sws_param:
[buffersink @ 0xac6a040] auto-inserting filter 'auto-inserted scaler 0' 
between the filter 'src' and the filter 'out'
[scale @ 0xac69cc0] w:720 h:576 fmt:yuv420p -> w:720 h:576 fmt:yuv422p 
flags:0x4
Output #0, avi, to '976_0003_01.DV50.avi':
   Metadata:
     ISFT            : Lavf53.5.0
     Stream #0.0, 0, 1/25: Video: dvvideo, yuv422p, 720x576 [PAR 64:45 
DAR 16:9], 1/25, q=2-31, 200 kb/s, 25 tbn, 25 tbc
     Stream #0.1, 0, 1/48000: Audio: pcm_s16le, 48000 Hz, 2 channels, 
s16, 1536 kb/s
Stream mapping:
   Stream #0.0 -> #0.0
   Stream #0.1 -> #0.1
Press [q] to stop, [?] for help
frame=  475 fps= 15 q=0.0 Lsize=  137199kB time=00:00:19.00 
bitrate=59154.6kbits/s
video:133594kB audio:3562kB global headers:0kB muxing overhead 0.031456%

-- 
Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-scale-default-interlaced-aware.diff
Type: text/x-patch
Size: 694 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110725/b6eb1bdd/attachment.bin>


More information about the ffmpeg-devel mailing list