[FFmpeg-user] When and how to use yadif?

Yan Seiner yan at seiner.com
Sun Nov 25 16:49:23 CET 2012


Carl Eugen Hoyos wrote:
> Yan Seiner <yan <at> seiner.com> writes:
>
>   
>> I've tried various attemps at it but the documentation 
>> gives little help on how to use yadif properly.
>>     
>
> Could you explain what you tried / share the command lines 
> together with complete, uncut console output?
> That would allow us to possibly improve the documentation.
>   
Hi Carl:

I've tried various combinations of yadif=X,Y,Z and moving the -vf yadif 
around on the command line.

The problem is that I am doing this by trial and error, and that's not a 
very good way to do it.

I can provide more information but I'd like some guidance.  Where in the 
line below should the video filters be?  Does it matter?  I get slightly 
different output depending on where I insert the filter.  Once I know 
where to insert it, I can then try different combinations of yadif 
options.  It's also possible that the interlacing is an artifact of the 
speed; at a relative speed of 120 MPH (the two cars passing each other) 
that's 180 feet per second, or about 3 feet between frames at 60 FPS, so 
there may in fact be no way to remove the striping I see short of 
getting a progressive camera or using just one field and throwing away 
half the horizontal resolution.

Here's a few sample runs:
root at anchor:/tmp# ffmpeg -f rawvideo -pix_fmt yuyv422 -s 512x384 -i 
/tmp/videox.raw -f image2 -pix_fmt rgb24 /tmp/test%02d.png
ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 19 2012 09:50:17 with gcc 4.6.3 20120201 (prerelease)
  configuration: --enable-cross-compile 
--cross-prefix=mips-openwrt-linux-uclibc- --arch=mips --target-os=linux 
--prefix=/usr --enable-shared --enable-static --disable-debug 
--pkg-config=pkg-config --enable-gpl --enable-version3 --disable-asm 
--disable-doc --disable-dxva2 --enable-pthreads --disable-optimizations 
--enable-small --disable-stripping --enable-zlib --disable-outdevs
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[rawvideo @ 0xac6620] Estimating duration from bitrate, this may be 
inaccurate
Input #0, rawvideo, from '/tmp/videox.raw':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 512x384, 
25 tbr, 25 tbn, 25 tbc
[buffer @ 0xac6d70] w:512 h:384 pixfmt:yuyv422 tb:1/25 sar:0/1 
sws_param:flags=2
[buffersink @ 0xac37a0] No opaque field provided
[format @ 0xac3980] auto-inserting filter 'auto-inserted scaler 0' 
between the filter 'src' and the filter 'format'
[scale @ 0xac41c0] w:512 h:384 fmt:yuyv422 sar:0/1 -> w:512 h:384 
fmt:rgb24 sar:0/1 flags:0x4
Output #0, image2, to '/tmp/test%02d.png':
  Metadata:
    encoder         : Lavf54.6.100
    Stream #0:0: Video: png, rgb24, 512x384, q=2-31, 200 kb/s, 90k tbn, 
25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> png)
Press [q] to stop, [?] for help
Truncating packet of size 393216 to 1 0kB time=00:00:00.44 bitrate=   
0.0kbits/s   
frame=   12 fps=5.1 q=0.0 Lsize=       0kB time=00:00:00.48 bitrate=   
0.0kbits/s   
video:18kB audio:0kB global headers:0kB muxing overhead -100.000000%

=================================================

root at anchor:/tmp# ffmpeg -f rawvideo -vf yadif -pix_fmt yuyv422 -s 
512x384 -i /tmp/videox.raw -f image2 -pix_fmt rgb24 /tmp/test%02d.png
ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 19 2012 09:50:17 with gcc 4.6.3 20120201 (prerelease)
  configuration: --enable-cross-compile 
--cross-prefix=mips-openwrt-linux-uclibc- --arch=mips --target-os=linux 
--prefix=/usr --enable-shared --enable-static --disable-debug 
--pkg-config=pkg-config --enable-gpl --enable-version3 --disable-asm 
--disable-doc --disable-dxva2 --enable-pthreads --disable-optimizations 
--enable-small --disable-stripping --enable-zlib --disable-outdevs
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[rawvideo @ 0x516690] Estimating duration from bitrate, this may be 
inaccurate
Input #0, rawvideo, from '/tmp/videox.raw':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 512x384, 
25 tbr, 25 tbn, 25 tbc
[buffer @ 0x516e30] w:512 h:384 pixfmt:yuyv422 tb:1/25 sar:0/1 
sws_param:flags=2
[buffersink @ 0x5137a0] No opaque field provided
[format @ 0x513980] auto-inserting filter 'auto-inserted scaler 0' 
between the filter 'src' and the filter 'format'
[scale @ 0x514200] w:512 h:384 fmt:yuyv422 sar:0/1 -> w:512 h:384 
fmt:rgb24 sar:0/1 flags:0x4
Output #0, image2, to '/tmp/test%02d.png':
  Metadata:
    encoder         : Lavf54.6.100
    Stream #0:0: Video: png, rgb24, 512x384, q=2-31, 200 kb/s, 90k tbn, 
25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> png)
Press [q] to stop, [?] for help
Truncating packet of size 393216 to 1 0kB time=00:00:00.40 bitrate=   
0.0kbits/s   
frame=   12 fps=5.2 q=0.0 Lsize=       0kB time=00:00:00.48 bitrate=   
0.0kbits/s   
video:18kB audio:0kB global headers:0kB muxing overhead -100.000000%

=============================================

root at anchor:/tmp# ffmpeg -f rawvideo -pix_fmt yuyv422 -s 512x384 -vf 
yadif -i /tmp/videox.raw -f image2 -pix_fmt rgb24 /tmp/test%02d.png
ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 19 2012 09:50:17 with gcc 4.6.3 20120201 (prerelease)
  configuration: --enable-cross-compile 
--cross-prefix=mips-openwrt-linux-uclibc- --arch=mips --target-os=linux 
--prefix=/usr --enable-shared --enable-static --disable-debug 
--pkg-config=pkg-config --enable-gpl --enable-version3 --disable-asm 
--disable-doc --disable-dxva2 --enable-pthreads --disable-optimizations 
--enable-small --disable-stripping --enable-zlib --disable-outdevs
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[rawvideo @ 0xb54690] Estimating duration from bitrate, this may be 
inaccurate
Input #0, rawvideo, from '/tmp/videox.raw':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 512x384, 
25 tbr, 25 tbn, 25 tbc
[buffer @ 0xb54e30] w:512 h:384 pixfmt:yuyv422 tb:1/25 sar:0/1 
sws_param:flags=2
[buffersink @ 0xb517a0] No opaque field provided
[format @ 0xb51980] auto-inserting filter 'auto-inserted scaler 0' 
between the filter 'src' and the filter 'format'
[scale @ 0xb52200] w:512 h:384 fmt:yuyv422 sar:0/1 -> w:512 h:384 
fmt:rgb24 sar:0/1 flags:0x4
Output #0, image2, to '/tmp/test%02d.png':
  Metadata:
    encoder         : Lavf54.6.100
    Stream #0:0: Video: png, rgb24, 512x384, q=2-31, 200 kb/s, 90k tbn, 
25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> png)
Press [q] to stop, [?] for help
Truncating packet of size 393216 to 1 0kB time=00:00:00.44 bitrate=   
0.0kbits/s   
frame=   12 fps=2.9 q=0.0 Lsize=       0kB time=00:00:00.48 bitrate=   
0.0kbits/s   
video:18kB audio:0kB global headers:0kB muxing overhead -100.000000%

=================================================

root at anchor:/tmp# ffmpeg -f rawvideo -pix_fmt yuyv422 -s 512x384 -i 
/tmp/videox.raw -vf yadif -f image2 -pix_fmt rgb24 /tmp/test%02d.png
ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 19 2012 09:50:17 with gcc 4.6.3 20120201 (prerelease)
  configuration: --enable-cross-compile 
--cross-prefix=mips-openwrt-linux-uclibc- --arch=mips --target-os=linux 
--prefix=/usr --enable-shared --enable-static --disable-debug 
--pkg-config=pkg-config --enable-gpl --enable-version3 --disable-asm 
--disable-doc --disable-dxva2 --enable-pthreads --disable-optimizations 
--enable-small --disable-stripping --enable-zlib --disable-outdevs
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[rawvideo @ 0x5f8620] Estimating duration from bitrate, this may be 
inaccurate
Input #0, rawvideo, from '/tmp/videox.raw':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 512x384, 
25 tbr, 25 tbn, 25 tbc
[buffer @ 0x5f8dc0] w:512 h:384 pixfmt:yuyv422 tb:1/25 sar:0/1 
sws_param:flags=2
[buffersink @ 0x5f57a0] No opaque field provided
[yadif @ 0x5f6200] mode:0 parity:-1 auto_enable:0
[format @ 0x5f59c0] auto-inserting filter 'auto-inserted scaler 0' 
between the filter 'Parsed_yadif_0' and the filter 'format'
[yadif @ 0x5f6200] auto-inserting filter 'auto-inserted scaler 1' 
between the filter 'src' and the filter 'Parsed_yadif_0'
[scale @ 0x5f6e00] w:512 h:384 fmt:yuyv422 sar:0/1 -> w:512 h:384 
fmt:yuv422p sar:0/1 flags:0x4
[swscaler @ 0x61db30] No accelerated colorspace conversion found from 
yuv422p to rgb24.
[swscaler @ 0x6235a0] No accelerated colorspace conversion found from 
yuv422p to rgb24.
[swscaler @ 0x629010] No accelerated colorspace conversion found from 
yuv422p to rgb24.
[scale @ 0x5f61a0] w:512 h:384 fmt:yuv422p sar:0/1 -> w:512 h:384 
fmt:rgb24 sar:0/1 flags:0x4
Output #0, image2, to '/tmp/test%02d.png':
  Metadata:
    encoder         : Lavf54.6.100
    Stream #0:0: Video: png, rgb24, 512x384, q=2-31, 200 kb/s, 90k tbn, 
25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> png)
Press [q] to stop, [?] for help
Truncating packet of size 393216 to 1 0kB time=00:00:00.40 bitrate=   
0.0kbits/s   
frame=   12 fps=3.1 q=0.0 Lsize=       0kB time=00:00:00.48 bitrate=   
0.0kbits/s   
video:18kB audio:0kB global headers:0kB muxing overhead -100.000000%

=============================================

root at anchor:/tmp# ffmpeg -f rawvideo -pix_fmt yuyv422 -s 512x384 -i 
/tmp/videox.raw -f image2 -pix_fmt rgb24 -vf yadif /tmp/test%02d.png
ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 19 2012 09:50:17 with gcc 4.6.3 20120201 (prerelease)
  configuration: --enable-cross-compile 
--cross-prefix=mips-openwrt-linux-uclibc- --arch=mips --target-os=linux 
--prefix=/usr --enable-shared --enable-static --disable-debug 
--pkg-config=pkg-config --enable-gpl --enable-version3 --disable-asm 
--disable-doc --disable-dxva2 --enable-pthreads --disable-optimizations 
--enable-small --disable-stripping --enable-zlib --disable-outdevs
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
[rawvideo @ 0x5a2620] Estimating duration from bitrate, this may be 
inaccurate
Input #0, rawvideo, from '/tmp/videox.raw':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 512x384, 
25 tbr, 25 tbn, 25 tbc
[buffer @ 0x5a2d70] w:512 h:384 pixfmt:yuyv422 tb:1/25 sar:0/1 
sws_param:flags=2
[buffersink @ 0x5a20c0] No opaque field provided
[yadif @ 0x59a750] mode:0 parity:-1 auto_enable:0
[format @ 0x5a22a0] auto-inserting filter 'auto-inserted scaler 0' 
between the filter 'Parsed_yadif_0' and the filter 'format'
[yadif @ 0x59a750] auto-inserting filter 'auto-inserted scaler 1' 
between the filter 'src' and the filter 'Parsed_yadif_0'
[scale @ 0x59b000] w:512 h:384 fmt:yuyv422 sar:0/1 -> w:512 h:384 
fmt:yuv422p sar:0/1 flags:0x4
[swscaler @ 0x5c7b30] No accelerated colorspace conversion found from 
yuv422p to rgb24.
[swscaler @ 0x5cd5a0] No accelerated colorspace conversion found from 
yuv422p to rgb24.
[swscaler @ 0x5d3010] No accelerated colorspace conversion found from 
yuv422p to rgb24.
[scale @ 0x5a2380] w:512 h:384 fmt:yuv422p sar:0/1 -> w:512 h:384 
fmt:rgb24 sar:0/1 flags:0x4
Output #0, image2, to '/tmp/test%02d.png':
  Metadata:
    encoder         : Lavf54.6.100
    Stream #0:0: Video: png, rgb24, 512x384, q=2-31, 200 kb/s, 90k tbn, 
25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> png)
Press [q] to stop, [?] for help
Truncating packet of size 393216 to 1 0kB time=00:00:00.44 bitrate=   
0.0kbits/s   
frame=   12 fps=4.3 q=0.0 Lsize=       0kB time=00:00:00.48 bitrate=   
0.0kbits/s   
video:18kB audio:0kB global headers:0kB muxing overhead -100.000000%
root at anchor:/tmp#





More information about the ffmpeg-user mailing list