Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 Encoder GUIs

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th January 2014, 09:33   #1  |  Link
somy
Registered User
 
Join Date: Dec 2009
Posts: 177
Handbrake decomb filters and frame rate

In handbrake it is possible to do deinterlacing with either decomb or deinterlacing filters. As I read in HandBrake's WIKI, decomb filter seems to be a better option because it works for both interlaced and progressive videos. The WIKI page describes how decomb filter works as follows:
•When a frame shows a significant amount of combing, decomb runs a tweaked version of HandBrake's "Slower" deinterlacing filter. That's yadif, a spatially (within one frame) and temporally (between several frames) aware deinterlacer. The tweak is that it uses a looks at more pixels when generating the spatial predictions.
•When a frame is only very slightly combed, decomb runs a blending deinterlacer called a lowpass-5 filter. This preserves more detail from the image than yadif, and in particular prevents noticeable deinterlacing artifacts on progressive video.

My question is, if I use decomb or deinterlacing filter in HandBrake, what frame rate I should choose? The same as source 25i or I should double it to 50 FPS? YADIF has mode 1 which doubles frame rate, does handbrake use that mode when I choose 50 FPS?
Thank you for your input in advance!
somy is offline   Reply With Quote
Old 17th January 2014, 13:06   #2  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,806
50 fps
Atak_Snajpera is offline   Reply With Quote
Old 17th January 2014, 13:17   #3  |  Link
somy
Registered User
 
Join Date: Dec 2009
Posts: 177
Quote:
Originally Posted by Atak_Snajpera View Post
50 fps
Hi, thank you for the reply.
If I choose 50 FPS, will handbrake use YADIF mode 1 for deinterlacing automatically or it simply doubles the FPS after deinterlacing? I searched in the forum, but I found some old post saying that HandBrake is not able/good at double the frame rate for deinterlacing, for example the thread below:
http://forum.doom9.org/archive/index.php/t-162972.html
somy is offline   Reply With Quote
Old 17th January 2014, 14:03   #4  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
To de-interlace to "full frame rate" with Handbrake I'm pretty sure you need to select Bob as the de-interlacing method (Bob=Yadif, mode 1) and an appropriate constant output frame rate (50fps/59.94fps). Same as source will output 23.976/25p.... I think.... but I don't use Handbrake myself so I could be remembering wrong. The Decomb filter also has a Bob option, so I assume it'd work the same way.
If you select a de-interlacing/decomb method other than Bob with a 50fps frame rate, you'll probably effectively end up with 25fps video, only every frame will be repeated to give you 50fps. If you use the variable frame rate option.... I've no idea what'll happen.

I'm no expert when it comes to de-interlacing but I think the best idea is to de-interlace if the video is interlaced and disable it completely when it isn't. For PAL at least (someone correct me if I'm wrong) it's usually one or the other, so I either de-interlace or I don't.
Alternative you use a filter like Decomb and hope it makes the correct choice most of the time. I can't tell you how well it works as I've not encoded with it much. I did try a few little test encodes a while back and thought it did a good job but I wouldn't take that as gospel. Maybe a Handbrake user will come along....

If you're really fussy about de-interlacing and not married to the idea of using Handbrake, you can't go past QTGMC. It's not hard to use once you get it working, and if there's progressive sections it shouldn't adversely effect them. In fact it also has a progressive mode which I use regularly. I use MeGUI for encoding and manually replace Yadif with QTGMC in scripts it creates.
Have a look at the samples here and here.
hello_hello is offline   Reply With Quote
Old 17th January 2014, 14:13   #5  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by somy View Post
If I choose 50 FPS, will handbrake use YADIF mode 1 for deinterlacing automatically or it simply doubles the FPS after deinterlacing? I searched in the forum, but I found some old post saying that HandBrake is not able/good at double the frame rate for deinterlacing, for example the thread below:
http://forum.doom9.org/archive/index.php/t-162972.html
As far as I know, Bob de-interlacing was only added to Handbrake fairly recently (sometime last year), so while that thread was probably correct then, it's wrong now.
It appears Handbrake still won't resize DVD's "up" when resizing to square pixels, which I prefer to do (ie 1024x576 for PAL). I'm pretty sure VidCoder does.

I'll admit I probably assumed Bob = "Yadif mode 1" when I tested it because I couldn't see a difference between Handbrake's "Bob" and MeGUI's "Yadif (with Bob)", which is definitely "Yadif, mode 1".
Unfortunately, Handbrake's log file seems not to be overly specific about it's de-interlacing. When using Bob and a 50fps output frame rate:

Deinterlace (ffmpeg or yadif/mcdeint) (15)

It doesn't mean a lot to me.

Last edited by hello_hello; 17th January 2014 at 14:28.
hello_hello is offline   Reply With Quote
Old 17th January 2014, 14:44   #6  |  Link
somy
Registered User
 
Join Date: Dec 2009
Posts: 177
Quote:
Originally Posted by hello_hello View Post
As far as I know, Bob de-interlacing was only added to Handbrake fairly recently (sometime last year), so while that thread was probably correct then, it's wrong now.
It appears Handbrake still won't resize DVD's "up" when resizing to square pixels, which I prefer to do (ie 1024x576 for PAL). I'm pretty sure VidCoder does.

I'll admit I probably assumed Bob = "Yadif mode 1" when I tested it because I couldn't see a difference between Handbrake's "Bob" and MeGUI's "Yadif (with Bob)", which is definitely "Yadif, mode 1".
Unfortunately, Handbrake's log file seems not to be overly specific about it's de-interlacing. When using Bob and a 50fps output frame rate:

Deinterlace (ffmpeg or yadif/mcdeint) (15)

It doesn't mean a lot to me.
Thank you very much for the very helpful reply.
In practice do I gain any PQ improvement with YADIF deinterlacing for doubling FPS to 50 (mode 1) instead of keeping the original 25 FPS (mode 0)? If not, I would probably just keep the original 25 FPS for now.
I also have a hard time to understand why MeGUI is better than HandBrake, aren't they based on the same X264 encoder?

Last edited by somy; 17th January 2014 at 14:52.
somy is offline   Reply With Quote
Old 17th January 2014, 15:41   #7  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,806
in fact original fps is 50 not 25. it is just stored in 25i aka 50i. you should deinterlace to 50 if you want keep original smooth motion.
Atak_Snajpera is offline   Reply With Quote
Old 17th January 2014, 18:20   #8  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by somy View Post
I also have a hard time to understand why MeGUI is better than HandBrake, aren't they based on the same X264 encoder?
Yes, both use x264 for H.264 encoding. If you only compare encoding without any preprocessing, MeGUI is not better than HandBrake as long as both have the same x264 version and same settings. But MeGUI uses AviSynth for filtering, so it's possible to deinterlace with QTGMC. Try it yourself and compare the result to HandBrake's decomb.
nm is offline   Reply With Quote
Old 17th January 2014, 18:45   #9  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Quote:
Originally Posted by somy View Post
Thank you very much for the very helpful reply.
In practice do I gain any PQ improvement with YADIF deinterlacing for doubling FPS to 50 (mode 1) instead of keeping the original 25 FPS (mode 0)? If not, I would probably just keep the original 25 FPS for now.
Definitely. Did you look at the samples I linked to, because to me the difference is obvious. There's a sample of both Yadif and QTGMC at 25fps and 50fps in the zip file.
50fps generally looks a lot smoother in terms of motion. When I compared 25fps to 50fps using ffdshow's de-interlacing filter on playback (Yadif), 50fps looked pretty much the same as if the video card/TV did the de-interlacing. 25fps was noticeably less smooth, or more "jittery", however you'd describe it, so in that respect if the goal is to have an encode which looks as close as possible to the original video, de-interlacing to 50fps when encoding would be fairly mandatory.

Quote:
Originally Posted by somy View Post
I also have a hard time to understand why MeGUI is better than HandBrake, aren't they based on the same X264 encoder?
I wasn't trying to say it's better, although I prefer it myself, only to point out that for quality de-interlacing I don't think anything else matches QTGMC, which would require an encoder capable of opening Avisynth scripts. It wouldn't need to be MeGUI, but MeGUI is a program which lets you modify the scripts it creates fairly easily.
I pretty much struggle to let myself use anything other than QTGMC for de-interlacing these days, although admittedly it's fairly slow. It's one of the few filters I've used.... maybe the only one.... where it's output is pretty much guaranteed to look better than the source video (it's de-interlacing also removes noise and stabilises the picture). Yadif at 50 fps is still pretty good though.

Last edited by hello_hello; 17th January 2014 at 21:25.
hello_hello is offline   Reply With Quote
Old 17th January 2014, 21:57   #10  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
This has already been alluded to but I want to stress it. I always want people to create the highest quality videos they can, especially from unique sources.

To help convince you to always use double rate deinterlacing:
True interlaced video (like that from a camcorder) has 50 discrete points in time. Interlaced video has stored the frame as fields which are made up of every other line of the full frame of video. When recording the camcorder does not capture a frame and then store every other line as separate fields, instead it captures the first field with one exposure and then the second field with a second exposure. This means that a camcorder really captures 50 frames per second with 1/2 the vertical resolution. A great deinterlacer like QTGMC will try to use static information from the previous and next fields to add detail when "resizing" each field to full resolution. In the places where it decides motion has happened between fields it uses a classic resize algorithm. If doing "half rate" deinterlacing QTGMC or Yadif would then drop every other frame, losing half the temporal resolution.

I hope this hasn't made you more confused instead of less.
A better explanation of interlacing
Asmodian is offline   Reply With Quote
Old 18th January 2014, 12:36   #11  |  Link
somy
Registered User
 
Join Date: Dec 2009
Posts: 177
Quote:
Originally Posted by hello_hello View Post
50fps generally looks a lot smoother in terms of motion. When I compared 25fps to 50fps using ffdshow's de-interlacing filter on playback (Yadif), 50fps looked pretty much the same as if the video card/TV did the de-interlacing. 25fps was noticeably less smooth, or more "jittery", however you'd describe it, so in that respect if the goal is to have an encode which looks as close as possible to the original video, de-interlacing to 50fps when encoding would be fairly mandatory.
Quote:
Originally Posted by Asmodian View Post
True interlaced video (like that from a camcorder) has 50 discrete points in time. Interlaced video has stored the frame as fields which are made up of every other line of the full frame of video. When recording the camcorder does not capture a frame and then store every other line as separate fields, instead it captures the first field with one exposure and then the second field with a second exposure. This means that a camcorder really captures 50 frames per second with 1/2 the vertical resolution. A great deinterlacer like QTGMC will try to use static information from the previous and next fields to add detail when "resizing" each field to full resolution. In the places where it decides motion has happened between fields it uses a classic resize algorithm. If doing "half rate" deinterlacing QTGMC or Yadif would then drop every other frame, losing half the temporal resolution.
Hi hello_hello and Asmodian,
Thank you very much for the explanation. I'm convinced to double FPS for deinterlacing, however I couldn't figure out how to do it properly in HandBrake. I have the following options:
1) Transcode 25i to 25i and let video player to do de-interlacing, for example LAV video decoder can do YADIF double frame rate de-interlacing. The problem is, HandBrake doesn't recognize the source video is interlaced and therefore mark the output video to be 25P and the video player consider it's progressive and therefore doesn't apply deinterlacing at all.
2) Transcode to 50P with deinterlacing filter in HandBrake. I have difficulty to understand how HandBrake handle double frame rate (which is the reason I opened this thread). If I manually type 50 FPS in the X264 encoder conf, does HandBrake use YADIF mode 1 automatically (there is no way to configure it any where) or does it use YADIF mode 0 and copy each every frame (which loses the benefit of 50 FPS IMO)
3) Transcode to 50P with decomb filter in HandBrake. This is the most complicated situation and deinterlacing only applied for some of the frames. Does it make any difference if I choose 50 FPS constant framerate or 50 FPS variable framerate? I would assume the correct behavior is to copy the frames that do not need deinterlacing and use YADIF mode 1 for the frames that requires deinterlacing. However I doubt that is how HandBrake works.
somy is offline   Reply With Quote
Old 18th January 2014, 17:02   #12  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
There's an x264 setting for interlaced encoding. MeGUI tells me there's two options. --bff, and --tff (bottom field first, top field first, I assume). I'm pretty sure all you need to do is add the appropriate one to the command line and you're encoding in interlaced mode. How you add them to the command line using Handbrake I'm not sure, and hopefully the x264 version Handbrake uses supports interlaced encoding. I don't think I've encoded a video as interlaced in my life, so the last couple of sentences pretty much contain everything I know about the subject.

You shouldn't need to type the frame rate into the encoder command line, if that's what you were referring to. Just select 50fps under the video tab along with the constant frame rate option. And of course either Bob deinterlacing or decomb.

I'd just use the deinterlacing filter myself rather than decomb. That's probably how it's done most of the time, at least outside of the Handbrake world.
Deinterlacing or decomb, I'd also set the frame rate option to "constant". Chances are most video is entirely, or very close to entirely interlaced (or entirely progressive), so 50fps would be fine. When choosing 50fps for the output frame rate, "variable frame rate" is no longer an option. The choices are constant frame rate and peak frame rate.
The effect of the variable or peak frame rate setting isn't something I'm very familiar with given I don't use Handbrake myself, but maybe if the Decomb filter doesn't de-interlace frames they're treated as progressive, and the you'd have the frame rate switching between 25fps and 50fps accordingly..... I'm really guessing but I'd be going with constant frame rate to make sure it's a steady 50fps and I'd probably stick with de-interlacing at least until I'd run some test encodes and understand what the decomb filter is likely to do and how it might effect the frame rate.

When using the Decomb filter, Handbrake's log file tells you how much de-interlacing it's doing. From one of my little "test encodes" the other day:

decomb: deinterlaced 2274 | blended 582 | unfiltered 71 | total 2927

I don't know if the frame rate would have varied as a result of what decomb was doing without the output set to a constant frame rate. I'll have to try it some time soon.... out of curiosity.

Last edited by hello_hello; 18th January 2014 at 17:08.
hello_hello is offline   Reply With Quote
Old 23rd January 2014, 16:54   #13  |  Link
JohnAStebbins
Registered User
 
Join Date: Oct 2008
Posts: 114
Hi,

Bob in HandBrake is indeed yadif mode 1.

Regarding framerates, the default framerate mode in HandBrake is "variable frame rate" (VFR). The duration of each frame can vary. This is especially useful with the Bob Decomb filter. This filter will output some frames at 25fps (frames where no combing is detected) and some frames at 50fps (combed frames). In this scenario, if you do not use VFR and instead set your framerate to 50fps CFR, the 25fps sequences will have their framerate increased to 50fps by duplicating frames. This results in encoding of duplicate frames that wastes a little space. The amount of wasted space is pretty minimal since duplicate frames compress really well.

Basically, what I'm saying is framerate doesn't matter if you use HandBrake's default VFR setting. It automatically "does the right thing" to preserve fluid motion. The important factor is your choice of deinterlace filter. The Bob variation of decomb or deinterlace preserves motion best.

The only reason not to use VFR would be for device compatibility. Some broken devices don't parse h.264 VFR information properly.
JohnAStebbins is offline   Reply With Quote
Old 27th January 2014, 21:35   #14  |  Link
somy
Registered User
 
Join Date: Dec 2009
Posts: 177
Quote:
Originally Posted by JohnAStebbins View Post
Hi,

Bob in HandBrake is indeed yadif mode 1.

Regarding framerates, the default framerate mode in HandBrake is "variable frame rate" (VFR). The duration of each frame can vary. This is especially useful with the Bob Decomb filter. This filter will output some frames at 25fps (frames where no combing is detected) and some frames at 50fps (combed frames). In this scenario, if you do not use VFR and instead set your framerate to 50fps CFR, the 25fps sequences will have their framerate increased to 50fps by duplicating frames. This results in encoding of duplicate frames that wastes a little space. The amount of wasted space is pretty minimal since duplicate frames compress really well.

Basically, what I'm saying is framerate doesn't matter if you use HandBrake's default VFR setting. It automatically "does the right thing" to preserve fluid motion. The important factor is your choice of deinterlace filter. The Bob variation of decomb or deinterlace preserves motion best.

The only reason not to use VFR would be for device compatibility. Some broken devices don't parse h.264 VFR information properly.
Thank you for your reply!
I'm not very comfortable with VFR option - I'd rather keep frame rate constant. If I understand you correctly, in HandBrake if I set frame rate to 50 for 25i material and enable decomb, handbrake will 1)duplicate frames which don't need deinterlacing and 2) deinterlace by using YADIF mode 1 ((NB. mode 1 != dulplicating frames)) for frames require deinterlacing. If that is the case then I'm very happy

Last edited by somy; 27th January 2014 at 21:37.
somy is offline   Reply With Quote
Old 28th January 2014, 03:05   #15  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
I ran some more little test encodes and meant to post back.

When selecting Bob for de-interlacing the output seems to be a constant 50fps whether you use "same as source" or "50" for the output frame rate. Even when the variable frame rate mode is selected. So I guess as long as the input frame rate is a constant 25fps, it just de-interlaces to 50fps.

When selecting Bob for the decomb filter, that's when the variable frame rate stuff happens, and the Handbrake log file tells you what it's doing. This was from my 30 second test encodes.

Variable frame rate:
[12:18:06] decomb: deinterlaced 1070 | blended 88 | unfiltered 78 | total 1236
[12:18:06] render: 1236 frames output, 0 dropped and 0 duped for CFR/PFR

Constant frame rate:
[12:19:49] decomb: deinterlaced 1070 | blended 88 | unfiltered 78 | total 1236
[12:19:49] render: 1314 frames output, 0 dropped and 78 duped for CFR/PFR

Interestingly, the constant frame rate encode resulted in a slightly smaller file size. 4.437MB for VFR. 4.423 for CFR.
I'm not sure how duplicating frames reduces the file size, but I repeated the above encodes and got the same result each time. Maybe it's something to do with the x264 encoder being frame rate aware (encode the same number of frames using two different frame rates and the same CRF value and you'll get two different bitrates).

Same little sample. Bob deinterlacing (not decomb)

[12:14:35] sync: got 658 frames, 1316 expected
[12:14:35] render: 1314 frames output, 0 dropped and 0 duped for CFR/PFR

For the record, the file size when de-interlacing was 4.296MB. Slightly smaller than decomb, so whether it means those 78 frames which weren't de-interlaced have more detail.... I don't know. I couldn't see any obvious differences between de-interlacing and de-comb.

I think I said in an earlier post you needed to select 50fps as the output frame rate for Bob de-interlacing to work. That appears to be wrong according to the test encodes I ran above. "Same as source" also produced a 50fps output.
hello_hello is offline   Reply With Quote
Old 28th January 2014, 17:15   #16  |  Link
JohnAStebbins
Registered User
 
Join Date: Oct 2008
Posts: 114
Quote:
Originally Posted by somy View Post
Thank you for your reply!
I'm not very comfortable with VFR option - I'd rather keep frame rate constant. If I understand you correctly, in HandBrake if I set frame rate to 50 for 25i material and enable decomb, handbrake will 1)duplicate frames which don't need deinterlacing and 2) deinterlace by using YADIF mode 1 ((NB. mode 1 != dulplicating frames)) for frames require deinterlacing. If that is the case then I'm very happy
You need to use the "bob" option of the decomb filter if you want this behavior.
JohnAStebbins is offline   Reply With Quote
Old 30th January 2014, 12:07   #17  |  Link
somy
Registered User
 
Join Date: Dec 2009
Posts: 177
Quote:
Originally Posted by JohnAStebbins View Post
You need to use the "bob" option of the decomb filter if you want this behavior.
OK, is bob the deinterlacing algorithm gives the worst picture quality by simple doubling frames?
somy is offline   Reply With Quote
Old 3rd February 2014, 19:16   #18  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: USA
Posts: 676
If I wanted to bob something I'd probably use TGMCmod, or QTGMC, at least then the bob output would be the best. But it'll be SLOW as hell to do the work, is the only drawback.
I don't see a point to quicker bobs if they result in lower picture quality (probably aliasing and stuff?)
osgZach is offline   Reply With Quote
Old 4th February 2014, 17:57   #19  |  Link
JohnAStebbins
Registered User
 
Join Date: Oct 2008
Posts: 114
Quote:
Originally Posted by somy View Post
OK, is bob the deinterlacing algorithm gives the worst picture quality by simple doubling frames?
I don't know what this question means? Are you saying you are getting worse picture quality when you use bob than when you don't use bob? I do not experience this.
JohnAStebbins is offline   Reply With Quote
Old 4th February 2014, 18:37   #20  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
I'm guessing he's confused by naming of the option. Some programs (such as VLC) have a filter named "Bob" that simply separates the fields and scales them up, which results in poor vertical resolution and a shimmering effect.

Here bob means that you get full temporal resolution (50 Hz) instead of half rate (25 Hz). Quality is determined by the selected algorithm.
nm is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 20:24.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.