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 > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th March 2014, 23:08   #1  |  Link
FeB
Registered User
 
Join Date: Mar 2014
Posts: 11
How to deinterlace only manually selected segments of the source

Hi, it's my first post here.

I've been encoding music DVDs to mkv/m4v using HandBrake for few years, but since almost all music DVDs are interlaced and HandBrake's decomb/deinterlace Yadif filter doesn't give very good quality, I decided to use QTGMC (with MeGui).

I have a lot of music DVDs where the main title is fully interlaced except for the first few seconds where there is a computer-made logo introduction that is progressive and should not be deinterlaced. For example, MTV Unplugged DVDs.

What I want is to write a code where I manually select which segments of the title I want to fully deinterlace and which ones I don't want to deinterlace.

Since I want double frame rate, the segments on the input that I don't want to be deinterlaced need to have frames duplicated (untouched) in the output.

I will use as example a NTSC DVD of mine where the first 17 seconds have a computer-made logo and text in a full black background and this segment should not be deinterlaced. The rest of the title, beginning in time 00:00:17 (hh:mm:ss) should be fully deinterlaced.

17 seconds * 59.94 frame/second = 1019 frames

(since 1019 is odd, I will use 1020)

So, what I want is:

- The first 1020 frames (from frame number zero to frame number 1019) in the 59.94fps h.264 output (which correspond to the first 510 frames from the 29.97fps DVD input) will not be deinterlaced, each frame from DVD source within this segment will only be duplicated untouched
- Starting on frame 1020 (which is the 1021th frame) until the end of the title, I want everything fully deinterlaced with double frame rate

I wrote this code:

Quote:
initial_frame_to_deinterlace = 1020
ConditionalFilter(QTGMC(xxxxxxxx), TDeint(mode=1, full=false, cthresh=12, MI=256), "current_frame", ">", "initial_frame_to_deinterlace - 1", show=true)
("show=true" option in ConditionalFilter is only for testing)

It seems to work pretty good, but I'm not certain if TDeint is keeping frames untouched, only duplicating them. What do you think?

And I think using TDeint like this is a waste of CPU processing, because TDeint will have to check if each of the first 510 frames is interlaced (and of course using cthresh=12 and MI=256 in a computer-made logo which is progressive I guarantee that none of the first 510 frames will ever be detected as interlaced!). It's like using a cannon to kill a fly. Is there a simpler filter that I could use instead of TDeint, only to duplicate frames to double frame rate, keeping video/audio sync?

Last edited by FeB; 27th March 2014 at 13:45.
FeB is offline   Reply With Quote
Old 27th March 2014, 03:35   #2  |  Link
colours
Registered User
 
colours's Avatar
 
Join Date: Mar 2014
Posts: 312
You could use SelectEvery(1,0,0) or Interleave(last,last). On the other hand, you can also use Trim instead of ConditionalFilter, at least for this task, so maybe this'd be more appropriate:

Code:
initial_frame_to_deinterlace = 1020
Trim(0, initial_frame_to_deinterlace - 1).SelectEvery(1,0,0) ++ Trim(initial_frame_to_deinterlace, 0).QTGMC(xxxxxxxx)
colours is offline   Reply With Quote
Old 27th March 2014, 13:34   #3  |  Link
FeB
Registered User
 
Join Date: Mar 2014
Posts: 11
Quote:
Originally Posted by colours View Post
You could use SelectEvery(1,0,0) or Interleave(last,last). On the other hand, you can also use Trim instead of ConditionalFilter, at least for this task, so maybe this'd be more appropriate:

Code:
initial_frame_to_deinterlace = 1020
Trim(0, initial_frame_to_deinterlace - 1).SelectEvery(1,0,0) ++ Trim(initial_frame_to_deinterlace, 0).QTGMC(xxxxxxxx)
Thank you.
Well, I understood what Trim makes.

But didn't understand how SelectEvery(1,0,0) duplicate frames to double frame rate.
Don't SelectEvery just do what the name "SelectEvery" exactly says, which is just select frames without duplicating them?
I need frames duplicated.
FeB is offline   Reply With Quote
Old 27th March 2014, 14:38   #4  |  Link
colours
Registered User
 
colours's Avatar
 
Join Date: Mar 2014
Posts: 312
Quote:
Originally Posted by FeB View Post
Thank you.
Well, I understood what Trim makes.

But didn't understand how SelectEvery(1,0,0) duplicate frames to double frame rate.
Don't SelectEvery just do what the name "SelectEvery" exactly says, which is just select frames without duplicating them?
I need frames duplicated.
SelectEvery(1,0,0) would be selecting frame #0 twice for every group of 1 frame; in other words, every frame is duplicated in the output. Other equivalent ways of writing this is as SelectEvery(2,0,0,1,1) or SelectEvery(3,0,0,1,1,2,2) or SelectEvery(4,0,0,1,1,2,2,3,3), et cetera.

I guess using Interleave(clip,clip) would be more intuitively obvious, at the expense of a little bit more typing since the clip has to be specified twice.
colours is offline   Reply With Quote
Old 27th March 2014, 23:31   #5  |  Link
FeB
Registered User
 
Join Date: Mar 2014
Posts: 11
Quote:
Originally Posted by colours View Post
SelectEvery(1,0,0) would be selecting frame #0 twice for every group of 1 frame; in other words, every frame is duplicated in the output. Other equivalent ways of writing this is as SelectEvery(2,0,0,1,1) or SelectEvery(3,0,0,1,1,2,2) or SelectEvery(4,0,0,1,1,2,2,3,3), et cetera.
Thank you again.
Now I understand what SelectEvery(1,0,0) does.

I made some tests here:

- Using Trim with initial frame set to 1020 gave me 34 seconds, so with Trim I need to set initial frame to 510 (which is the frame number in the NTSC DVD 29.97fps source that correspond to 17 seconds). With ConditionalFilter I need to use 1020 (which is the frame number in the h.264 59.94fps output that correspond to 17 seconds)

- I think ConditionalFilter is better than using Trim ++ Trim because with ConditionalFilter I can make a quick test using the "show = true" option for confirmation if I set the correct value to the initial frame variable. Of course, this will take more additional time.

- TDeint(mode=1, full=false, cthresh=12, MI=256) was not only duplicating frames untouched. TDeint made "something I don't know what" in the first 510 frames of the input source. Using SelectEvery(1,0,0) gave me a pure 100% untouched output in the segment I don't want to be deinterlaced.

Until now, I only divided the source in two segments: one to not deinterlace and the other to fully deinterlace. The next step is divide the source in various segments. For this task I think I will use ConditionalFilter with ConditionalReader.
FeB 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 11:26.


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