I've kept this post up mainly for archival value.
After my last post, I played around with bunch of different settings, and discovered that plain old FFMPEG can do decent deinterlacing. One of the reasons I looked into this is that QTGMC (my AVISynth deinterlacing plugin of choice) is ridiculously slow and prone to crashing when processing HD footage.
The problem with FFMPEG is that its documentation is enormous, and while it sometimes includes clear examples to show you how to use certain features, other times it's simply assumed that you're technically savvy enough to know what they're talking about. For example, trying to figure out the best method for deinterlacing involved me doing Google searches for each of the various methods. Normally, something like that would give results pretty quickly, but most of the substantive discussions were from at least five to nine (!) years ago or related to programs that use FFMPEG as a back-end engine, rather than as a standalone app. Even after all that, it wasn't immediately obvious which method would be superior, so I decided to run a few tests.
Method 1: kerndeint - a relatively simple deinterlacing method that automatically halves the framerate and is roughly on par with the old After Effects / Premiere Pro deinterlacer.
Method 2: w3fdif - Developed by the BBC, this is much closer to what I was looking for. Unfortunately it was originally designed for interlaced standard definition PAL content, and as such somehow does not have a mechanism for selecting Top Field First field order. It did successfully deinterlace the footage, but ended up looking herky-jerky as a result of the field order mismatch.
Method 3: nnedi - The method that QTGMC was designed to incorporate/replace. In theory, it does many of the same things, but to say that trying to figure out the options was confusing is an understatement.
Method 4: bwdif - To quote the FFMPEG documentation: “Motion adaptive deinterlacing based on yadif with the use of w3fdif and cubic interpolation algorithms”. This turned out to be the perfect solution. The default settings automatically detect field order (if it's set in the file's metadata) and do not introduce weird image artifacts, but still give decent deinterlacing. Oh, and it runs significantly faster than AVISynth+QTGMC. Like, 6-8 times as fast.
Now, there are some downsides to bwdif. QTGMC can introduce some ghosting artifacts (including misaligned chroma artifacts), but it can also pull more detail out of the original image. This makes bwdif a sub-par solution for SD interlaced to HD progressive upconversion. FFMPEG also doesn't have the (relatively) easy-to-read syntax of an AVISynth script, and definitely lacks the versatility of the insane range of plugins available for the latter.
As always, here’s an example of the command-line options so you can run this process on your system. Note that you have to use -vf before naming the filter in quotes:
This is what I used to deinterlace a 60i HD file and re-encode it for YouTube. For ProRes encoding, see my previous post.
After my last post, I played around with bunch of different settings, and discovered that plain old FFMPEG can do decent deinterlacing. One of the reasons I looked into this is that QTGMC (my AVISynth deinterlacing plugin of choice) is ridiculously slow and prone to crashing when processing HD footage.
The problem with FFMPEG is that its documentation is enormous, and while it sometimes includes clear examples to show you how to use certain features, other times it's simply assumed that you're technically savvy enough to know what they're talking about. For example, trying to figure out the best method for deinterlacing involved me doing Google searches for each of the various methods. Normally, something like that would give results pretty quickly, but most of the substantive discussions were from at least five to nine (!) years ago or related to programs that use FFMPEG as a back-end engine, rather than as a standalone app. Even after all that, it wasn't immediately obvious which method would be superior, so I decided to run a few tests.
Method 1: kerndeint - a relatively simple deinterlacing method that automatically halves the framerate and is roughly on par with the old After Effects / Premiere Pro deinterlacer.
Method 2: w3fdif - Developed by the BBC, this is much closer to what I was looking for. Unfortunately it was originally designed for interlaced standard definition PAL content, and as such somehow does not have a mechanism for selecting Top Field First field order. It did successfully deinterlace the footage, but ended up looking herky-jerky as a result of the field order mismatch.
Method 3: nnedi - The method that QTGMC was designed to incorporate/replace. In theory, it does many of the same things, but to say that trying to figure out the options was confusing is an understatement.
Method 4: bwdif - To quote the FFMPEG documentation: “Motion adaptive deinterlacing based on yadif with the use of w3fdif and cubic interpolation algorithms”. This turned out to be the perfect solution. The default settings automatically detect field order (if it's set in the file's metadata) and do not introduce weird image artifacts, but still give decent deinterlacing. Oh, and it runs significantly faster than AVISynth+QTGMC. Like, 6-8 times as fast.
Now, there are some downsides to bwdif. QTGMC can introduce some ghosting artifacts (including misaligned chroma artifacts), but it can also pull more detail out of the original image. This makes bwdif a sub-par solution for SD interlaced to HD progressive upconversion. FFMPEG also doesn't have the (relatively) easy-to-read syntax of an AVISynth script, and definitely lacks the versatility of the insane range of plugins available for the latter.
As always, here’s an example of the command-line options so you can run this process on your system. Note that you have to use -vf before naming the filter in quotes:
ffmpeg -i "input_video.avi" -vf "bwdif" -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p -c:a aac -b:a 320k "output_video.mp4"
This is what I used to deinterlace a 60i HD file and re-encode it for YouTube. For ProRes encoding, see my previous post.
11 comments:
Fast and with excellent results, thanks for this. Regards, Roy.
Is a cri of 18 acceptable?
For most cases, it's a good compromise between file size and image quality. If you need higher quality, ProRes or DNxHR would be better. For lower filesize, I'd try using h.265.
"9.94 mcdeint
Apply motion-compensation deinterlacing.
It needs one field per frame as input and must thus be used together with yadif=1/3 or equivalent.
This filter accepts the following options:
mode
Set the deinterlacing mode.
It accepts one of the following values:
‘fast’
‘medium’
‘slow’
use iterative motion estimation
‘extra_slow’
like ‘slow’, but use multiple reference frames.
Default value is ‘fast’.
parity
Set the picture field parity assumed for the input video. It must be one of the following values:
‘0, tff’
assume top field first
‘1, bff’
assume bottom field first
Default value is ‘bff’.
qp
Set per-block quantization parameter (QP) used by the internal encoder.
Higher values should result in a smoother motion vector field but less optimal individual vectors. Default value is 1. "
?
Could you run Avisynth Info Tool on your system to make sure you have everything installed properly?
http://forum.doom9.org/showthread.php?t=176079&highlight=avisynth+info+tool
If that comes back okay, post your .avs script.
i was just asking did you try ffmpeg's mcdeint....
i was also involved in development of some avs deint filters, but that's another story...
i'm currently looking for "best bang for the buck" ffmpeg deinterlacer, but i guess that exists as much as for any other platform/program, ie not at all.
w3fdif did produce some decent results on 50i scrolling end credits, though....
"but to say that trying to figure out the options was confusing is an understatement." I agree. Here's how to get the best quality:
-vf "nnedi=nnedi3_weights.bin:deint=all:field=a:deint=all:nsize=s48x6:nns=n256:qual=slow:pscrn=none"
Requires the .bin file to be in the directory where you run ffmpeg from.
Example: ffmpeg in Z:\, video file in Z:\movies\file.mp4, command window in Z:\movies\, THEN you need the .bin to be in Z:\movies\nnedi3_weights.bin
bin file: https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin
Documentation: https://ffmpeg.org/ffmpeg-filters.html#nnedi
i4004: I hear you. I haven't found anything that really works as well as QTGMC, but I'd love for FFMPEG to incorporate something about as good so I don't have to install as much stuff. AVISynth is great, but kind of a hassle to install and keep updated.
The_ZoRo: I'll check that out and compare with QTGMC at some point. Thanks.
thankyou Andrew Swan for this bolg,using this i got a huge difference in my videos
We used Intertake software to deinterlace the HG10 60i encoding of 24p and it worked like a charm. Intertake is not free, but it was worth every penny after trying every other method and getting close but never as seamless as with what they have built.
If you can't get your deinterlace or transcode right, have a look at them.
@Bruce - Can't seem to find "Intertake" with a Google search. The closest thing I found was InterTek, a QA testing service which is mentioned in the documentation of the Creston conversion/streaming boxes and Grass Valley's Vertigo XG software.
Regardless, this blog post is ancient. Check out my most recent post about deinterlacing options here:
https://macilatthefront.blogspot.com/2021/05/which-deinterlacing-algorithm-is-best.html
If you have a link to the software you're talking about, feel free to post it or send me an email and I'll take a look.
Post a Comment