Lair Of The Multimedia Guru

2006-06-09

Deinterlacing filters

Below you will find a comparission of various deinterlacing filters, the interlaced source was created with mplayer using the phase=t and tinterlace=1 filters from the well known foreman video

all pictures where exported with mplayer -vo pnm and ppmtojpg --optimize --quality 90 why not -vo jpeg? well i didnt had -vo jpeg compiled in and -vo jpeg only accepts rgb input, so there wouldnt have been any advantage in using it …

Most deinterlacing filters only output one frame for every 2 fields that combined with the fact that some always choose the even, some always the odd and some always the first no matter if thats even or odd made this comparission less funny then i hoped originally, due to this little issue several filters (pp=ci and kerndeint IIRC) had to be feeded with vertically fliped video and tomsmocomp even needed -vf phase=b to output a frame based on the correct field and yes i of coarse did specify the top vs. bottom field first flag correctly as long as the filter had such an option …

Original non interlaced image
interlaced image mplayer -vf phase=t,tinterlace=1
mplayer -vf pp=lb (linear blend)
mplayer -vf pp=l5 (5tap lowpass filter)
transcode -J smartyuv
mplayer -vf pp=fd
mplayer -vf pp=md (median deinterlacer)
mplayer -vf pp=li (linear interpolate)
mplayer -vf pp=ci (cubic interpolate)
transcode -J dilyuvmmx
mplayer -vf kerndeint (Donald Graft’s adaptive kernel deinterlacer)
transcode -J smartdeinter (VirtualDub’s smart deinterlacer)
transcode -J tomsmocomp (Tom’s Motion Compensation deinterlacing filter)
mplayer -vf yadif=1:1
mplayer -vf yadif=3:1
mplayer -vf yadif=1:1,mcdeint=2:1:10
mplayer -vf yadif=3:1,mcdeint=2:1:10
Filed under: Uncategorized — Michael @ 16:48

53 Comments »

  1. Still images just don’t do justice. You have to see a deinterlacer in motion, and see the jagged edges moving around to really appreciate how bad most of them really look.

    Comment by RC — 2006-06-11 @ 09:21

  2. Speaking of mcdeint, there are maybe avcodec_close/free missing in the uninit part.

    Comment by mean — 2006-06-18 @ 18:27

  3. not anymore, just added avcodec_close()

    Comment by Michael — 2006-06-19 @ 10:17

  4. Interesting results for yadif. What litterature have you checked on edge-directed interpolation that led you to this?

    Speaking of the implementation, I notice that there are such statements as:
    1) if((y ^ parity) & 1)
    2) uint8_t *prev2= (tff ^ parity) ? prev : cur ;
    3) uint8_t *next2= (tff ^ parity) ? cur : next;
    inside of the loops. While I believe that nowadays CPU’s branch prediction will optimize it, couldn’t it be made “cleaner”? (“patch welcome” is the reply I expect from you)

    Comment by Sigdrak — 2006-06-19 @ 17:01

  5. Nevermind the optimization stuff, you’ve probably tested it, and register pressure probably is more important.

    Comment by Sigdrak — 2006-06-19 @ 17:03

  6. ive not read any edge-directed interpolation related litrature lately (<1 year or so) longer ago i did read some, now i dont remember where exactly ive read about this first or how similar it was to what yadif does now exactly, but iam fairly sure it was one or more paper(s) about deinterlacing not general interpolation and it was certainly available freely online as i dont read other papers normally, i guess citeseer should find some interresting papers if you are searching for some …
    note, tomsmocomp also seems to contain some directional interpolation code, though ive only noticed that after i wrote yadif …
    and the code for mixing temporal and spatial predictors was entirely my own idea

    about optimizations, yadif and mcdeint are not really optimized and patches are always welcome, for example iam sure they could benefit alot from mmx
    filter() could also be changed to a inline function and called with “constant” tff and parity so that the compiler can optimize the related checks away while the source code would stay clean …

    Comment by Michael — 2006-06-19 @ 23:55

  7. where is mplayer -vf lavcdeint? or is it not worth comparing?

    by any chance have you had a look at dscaler deinterlace filters?

    http://dscaler.org/

    when will you make libavfilter? or libavmunge (as LAVF is taken by libavformat). then combine all filters from all projects (vlc, xine, mplayer, transcode, etc) and people can stop reinventing the wheel and get to optimizing and creating more amazing filters!

    Comment by compn — 2006-06-20 @ 04:36

  8. -vf lavcdeint is the same as -vf pp=fd

    about dscaler, is there a way i can use it under linux easily? (i mean no qemu or such) if no i wont bother with it, if yes maybe ill test its deinterlacers too …

    iam too lazy/unmotivated to work on libavfilter currently, patches are welcome though :) but its highly nontrivial if you want to allow all the speed related tricks like direct rendering and slices together with arbitrary filter graphs, and no 1 in = 1 out design

    Comment by Michael — 2006-06-20 @ 09:08

  9. i think dscaler is windows only. but there is lots of hype for it.

    Comment by compn — 2006-06-20 @ 14:22

  10. Can anybody tell me how mcdeint works in detial? AFAIK the video has to be processed by yadif=3 first before it is processed by mcdeint. But yadif=3 already produces a deinterlaced video with doubled framerate. So for what reason we need to append mcdeint? What exactly does mcdeint do with the already deinterlaced video and who can it improve the quality at this point?

    Thanks for any information. Infos about mcdeint are rare…

    Comment by MuldeR — 2006-06-21 @ 13:08

  11. mcdeint performs motion estimation and compensation so as to fill in the “missing” lines
    to be able to estimate motion well it needs some image to work with, ive also tried to just use the available odd/even lines of the current field but that did not work as well, even simple framerate doubling deinterlacers improved the result after mcdeint

    for the motion estimation and compensation mcdeint uses the overlapped block based motion estimation/compensation code from the snow codec, so improvments to snow would automatically lead to improved mcdeint
    with mcdeint=0 things are restricted to a simple non overlapped estimation / overlapped compensation of 16×16 blocks at 1/4 pel resolution
    mcdeint=1 adds 8×8 block support and a larger diamond size for the predictive zonal search
    mcdeint=2 adds iterative overlapped block based motion estimation
    and mcdeint=3 adds multiple reference frames

    Comment by Michael — 2006-06-21 @ 19:16

  12. Thanks for reply!

    Okay, you say mcdeint fills in the “missing” lines. But if I use yadif=3 only, I already get full frames with no lines missing. Where does mcdeint fill in? Or does it just overwrite the odds/even lines?

    Futhermore that yadif=3,mcdeint doubles the number of frames. So I have to correct the framerate by hand and in the end I get a doubled framerate. Isn’t there a way to use mcdeint in a way it keeps the origianl Framerate, like TomsMoComp does? Maybe some option? Whit I tried is this: yadif=3,mcdeint,framestep=2. It seems to work fine for MEncoder, but I think it wastes too much CPU power (beacuse we skip half of the frames calculated be mcdeint). However the results look interesting! Only problem so far: It doesn’t work with MPlayer at all, because as soon as I append framestep=2 the video starts to jump forth and back…

    Comment by MuldeR — 2006-06-21 @ 20:18

  13. yes, it overwrites them

    mcdeint uses the previous deinterlaced frame(s) as reference for the motion estimation and compensation, so its not possible to skip their calculation, we wouldnt have a previous deinterlaced frame otherwise …

    mplayer -vf yadif,…,framestep=2 should be working now

    Comment by Michael — 2006-06-21 @ 21:55

  14. okay.

    Just finished a longer encoding with “mencoder -vf yadif=3,mcdeint=1,framestep=2” and results look good.
    Too sat that it runs so slow on my machine…

    By “…should be working now” you mean it was fixed recently?

    Comment by MuldeR — 2006-06-21 @ 23:23

  15. Just tried the latest MPlayer build (2006-06-25) and it was *not* fixed :-(

    Comment by MuldeR — 2006-06-25 @ 16:52

  16. try mplayer-svn r18781, that is the one i was refering too, which was latest at the time of my comment

    Comment by Michael — 2006-06-25 @ 20:27

  17. The build I use is r18812. So if the problem was fixed in r18781, it should be fixed in my build damn sure. Unfortunately it is not…

    Comment by MuldeR — 2006-06-25 @ 22:36

  18. MuldeR, for interlaced content, the _original_ framerate _is_ the “doubled” number, i.e. 50 or 60 or 60000/1001. It’s just that each frame is missing half its lines. Pairing the fields and interleaving them into one picture at half the framerate is an artifact of the way it’s stored on the computer, and is misleading regarding the nature of the original video.

    Comment by Rich — 2006-08-02 @ 08:00

  19. Is the yadif & mcdeint combo at all usable with mencoder, if one needs to perform also inverse telecine (lets say from NTSC framerate to film framerate [23.976 fps]) in the same filter chain? I’ve tried something like -vf yadif=3:1,mcdeint=2:1:10,framestep=2,filmdint=dint_thres=256,… -fps 30000/1001 -ofps 24000/1001, but the result has always been a video with some frames doubled in fast movie scenes [filmdint here works only as pulldown reversal filter, since it performs no deinterlacing thanks to dint_thres=256]. And I’m really clueless as to what value the -fps should really ought be set in such cases like this one. Haven’t tried pullup, divtc and others yet, but I’m not too overconfident the result would really differ…
    Ideas?

    Comment by JR — 2006-09-05 @ 12:26

  20. I’ve tried yadif=3:1,mcdeint=2:1:10,framestep=2 and I still get jittery motion for some reason. (some frames go backwards in time) This is using mplayer with mencoder rc1. I’ve also tried using -vf pullup,softskip,pp=lb and not only is that about 10-15x faster processing then the above, IMHO it works better than the yadif,mcdeint dance anyway. (Although if I could figure out how to stop the jitter with yadif,mcdent,framestep I would give it another chance.

    Does anybody know a filter or combination of filters for mencoder that are equivalent to TomsMoComp?

    Thanks for any suggestions.

    Comment by Justin — 2006-12-14 @ 15:45

  21. > I’ve tried yadif=3:1,mcdeint=2:1:10,framestep=2 and I still get jittery motion for some
    > reason. (some frames go backwards in time) This is using mplayer with mencoder rc1. I’ve also
    > tried using -vf pullup,softskip,pp=lb and not only is that about 10-15x faster processing
    > then the above, IMHO it works better than the yadif,mcdeint dance anyway. (Although if I

    If a inverse telecine filter like -vf pullup removes the “interlacing” artifacts then the respective video is not interlaced but telecined so deinterlacing isnt possible or sensible

    If -vf yadif=3:1 doesnt work with an interlaced video then try -vf yadif=3:0 or -vf yadif=3

    […]

    > Does anybody know a filter or combination of filters for mencoder that are equivalent to
    > TomsMoComp?

    no, mencoder does not support TomsMoComp, you could try transcode

    Michael

    Comment by Michael — 2006-12-14 @ 17:39

  22. Michael,

    Thanks for the quick reply. I’ve been working with capture card dumps in NTSC-M 29.97 fps. It seems to be a 50-50 chance that the footage is either teleclined or interleaved. Has this been the experience with anybody else here? So what I’ve been doing first is testing a small sample of the stream with iVTC -vf,pullup,softskip, etc. and if it’s still jittery, then I try the yadif=3:1,mcdeint=2:1:10,framestep=2,filmdint=dint_thres=256, thing and it works much better. In both cases I output to 24000/1001 fps since I’m trying to save encoding space and 99% of the videos I’ve seen out there all are 23.97fps anyway. Is this the correct approach to make?

    Comment by Justin — 2006-12-15 @ 13:50

  23. it would be cool to be able to get from a 30frames/60fields video a 60frame deinterlaced video using yadif=3:1,mcdeint=2:1:20. But static objects in the video show very distracting vertical jitter (the whole background jumps up and down). Is there an mplayer option to move every second frame 1 pixel down, this should remove the jitter and result in a nice 60fps video (at least I hope).

    Comment by Georges — 2007-04-27 @ 01:14

  24. where can I find tomsmocomp writtern in C code?Thanks

    Comment by zhang — 2007-05-17 @ 03:56

  25. @ Georges
    The problem you’re having is that you have the field order reversed in your processing, which is what is giving your video jitter. I would recommend trying yadif=1:0,mcdeint=2:0:10 and see where that gets you. DV uses bottom field first rather than top field first (0 instead of 1).

    Comment by Justin — 2007-05-30 @ 21:25

  26. Yadif is very good and fast!
    So some time ago I ported yadif as a plugin to Avisynth
    http://forum.doom9.org/showthread.php?t=124284

    Comment by Fizick — 2007-08-29 @ 19:07

  27. I am happy with http://www.guthspot.se/video/#deinterlacesmooth.

    Smoothdeinterlacer allows a color display in VD to “see” the effect of parameters : this is nice but it takes some time to find good parameter.

    Yadif seems more simple to use, but does it perform well compared to smoothdeinterlace ?

    A nice tutorial related to deinterlace : http://www.100fps.com/

    Comment by David — 2007-09-25 @ 14:56

  28. Hi Michael,

    I see that you used the ‘phase’ and ‘tinterlace’ filters for this. I’m actually interested in learning how they work. I know that interlacing progressive content is really a bad idea, but I’m just interested in this procedure… it’s not that I interlace my encodes here or something, I just play around with filters and trailers

    I have a question. When one uses phase=t,tinterlace=1 on a progressive 25 fps content, do I have to also set the output frame rate to double during the encoding process? I mean when you use these filters, do i have to add -ofps 50 to the mencoder parameters to obtain in the end 50 fps interlaced content? From what i understand, interlacing halves the frame rate, so if i interlace a 25 fps content, it will become 12.5 fps interlaced content…. but how do i make it 25 fps interlaced? Do i have to use a 50 fps progressive content for this, then interlace it which will bring back its frame rate to 25 fps ?

    I hope you reply to this as I don’t seem to get it :)

    Comment by segfault — 2008-01-05 @ 10:06

  29. I convert my video from DVD PAL 25fps to some PC-compatible format. For doing this I use yadif=1:0,mcdeint=2:0:20 plus -fps 50 -ofps 50 and the result is perfect (movement is smooth). But when I try to get 25 fps movie I get jittery motion… I failed to figure why exactly. Each frame looks good (movie does not jump back and forward) but visually it looks like it does jumps or shakes/flickers. :( I don’t see this effect on 50 fps movie… If 50 fps movie is smooth I think it is possible to get smooth 25 fps movie. Isn’t it? It does not matter whether I convert the movie to 25 fps during deinterlacing or in separate process – I get the same result. What can I try to make my movie more smooth? Thanks.

    P.S. I realize that 25 fps movie cannot be technically such smooth as 50 fps one. But the 25 fps movie I get is just jittery and it is more jittery than any other 25 fps movie. Actually it looks like 15-20 fps movie. I checked – only every second frame (of 50 fps movie) is dropped (so it is not frames dropping issue).

    Comment by s-andy — 2008-03-31 @ 12:13

  30. > I convert my video from DVD PAL 25fps to some PC-compatible format. […] I get jittery motion…

    Maybe its not interlaced but telecined somehow.

    Comment by Michael — 2008-03-31 @ 13:24

  31. Is there an mcdeint filter for avisynth? Without it, the yadif avisynth port is pretty useless.

    Comment by MC — 2008-04-03 @ 22:26

  32. […] VirtualDub (Windows ~ free open source) MPEG Streamclip (Windows, Mac ~ free) mencoder (Linux ~ free open source) FFmpeg (Linux ~ free open source) VLC (Windows, Mac, Linux ~ free open […]

    Pingback by Miro - Internet TV Blog » Blog Archive » Make Your Video Less Ugly: Deinterlace — 2008-08-20 @ 17:30

  33. […] Deinterlacing filter examples by Michael Niedermayer (FFmpeg maintainer) Post a comment | Trackback URI […]

    Pingback by The difference between interlacing and interlacing < WALLS OF TL;DR — 2008-09-09 @ 15:05

  34. […] geht das ganz ordentlich, wenn man etwas aufwendigere Filterkombinationen einsetzt: http://guru.multimedia.cx/deinterlacing-filters/ Gruß, […]

    Pingback by Tool für Nachbearbeitung von TV-Aufzeichnungen | hilpers — 2009-01-17 @ 18:48

  35. […] geht das ganz ordentlich, wenn man etwas aufwendigere Filterkombinationen einsetzt: http://guru.multimedia.cx/deinterlacing-filters/ Gruß, […]

    Pingback by Tool für Nachbearbeitung von TV-Aufzeichnungen | hilpers — 2009-01-17 @ 18:48

  36. […] indirizzato sulla giusta strada poichè dopo aver provato qualche filtro tratto da questa pagina: http://guru.multimedia.cx/deinterlacing-filters/ ho adottato [-vf pp=li] ed ora il risultato è buono. Ciao Antonio […]

    Pingback by Registrazione Film da Digitale Terrestre (difetto) | hilpers — 2009-01-21 @ 15:46

  37. […] > Przetestowalem i nic to nie daje. Poszperalem jednak troche i po komentarzach na stronie http://guru.multimedia.cx/deinterlacing-filters/ postanowilem wykorzystac framestep=2 no i niby wszystko ok. Dodam ze jak kodowalem wczesniejsza […]

    Pingback by Mencoder i problem z synchronizacja dzwieku | hilpers — 2009-01-23 @ 04:25

  38. Thanks! This was extremely useful…. damn mplayer with the man page being too long to read

    Comment by windoze — 2009-02-27 @ 02:39

  39. Hi their,
    I want to remove De-interlace problem in single still, how can I proceed, please guide me.

    thanks and Regards
    Amit

    Comment by Amit g kulkarni — 2009-08-07 @ 07:59

  40. Has another determined the effects of de-interlacing on file size: especially Field Extension Deinterlacing and Motion Compensation? I have seen situations where file size increases by more than half.

    Comment by bruce clark — 2009-11-07 @ 01:25

  41. will be possible to use yadif=1/3 with ffmpeg during x264 encoding ?

    Comment by Goga — 2010-07-07 @ 08:00

  42. […] e’ venuto fuori un file da 869 Mega – che va benone; c’è anche da imparare a de-interlacciare. […]

    Pingback by SIMOTRONE WEB PAGE » Blog Archive » Da dvd a avi — 2010-07-29 @ 07:01

  43. Mplayer + mencoder isn’t cure at all… mencoder used by me only for pullup, for other stuff i prefer use avs ;)

    Comment by スカー — 2010-11-14 @ 20:11

  44. It is better to shoot progressive rather than interlaced. Then you do not have to worry about deinterlacing. I have been shooting 24p for many years and it is not because I want to get the film look. I shoot 24p because I want to get the immediate savings in file size. When I am outputting to the web and DVD, this smaller file size helps. At 24 frames per second, motion blur can be an issue but there are other considerations. For example, hummingbirds are subjects where motion blur must be considered. On YouTube channel SDmovieDotCom you can see a hummingbird I shot in 24p and I managed to slow down the subject by using a fast shutter speed.

    Comment by Business video — 2011-01-05 @ 02:12

  45. 31.Is there an mcdeint filter for avisynth? Without it, the yadif avisynth port is pretty useless.

    Comment by gelinlik — 2011-04-25 @ 23:23

  46. Smoothdeinterlacer allows a color display in VD to “see” the effect of parameters : this is nice but it takes some time to find good parameter.

    Comment by dergi — 2011-04-25 @ 23:25

  47. […] Lair Of The Multimedia Guru, Deinterlacing filters comparisation of de-interlacers […]

    Pingback by Video-Re-Encoding Step by Step | Jean's Page — 2011-05-01 @ 17:10

  48. the yadif avisynth port is pretty useless.

    Comment by billige fodboldstovler nike — 2013-05-22 @ 09:49

  49. Yadif is very popular right now, due in part to this blog post.

    However, I think this comparison shows yadif in a very favorable light, and does not show its weak points, and thus yadif comes out looking better than it necessarily is.

    I did a comparison from a later frame in the _same video_ where it pans across to the building.

    http://imgur.com/a/Xkns4#0

    Notice the ugly artifacts in the trees for yadif. PP=FD and the original are shown for comparison. Notice too how yadif bleaches out all the detail in the bricks and “invents” horizontal lines in various places like the tree on the right.

    Comment by F J Walter — 2014-07-30 @ 04:37

  50. @ F J Walter: Were these artifacts present with ‘yadif=3:1,mcdeint=2:1:10’, or with just ‘yadif’ on its own?

    Comment by Ian Barlow — 2015-01-21 @ 17:21

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress