Log in

View Full Version : Is this still a good approach to deinterlace mixed p/i source? tdeint + qtgmc + tmm


cagali
4th November 2015, 04:22
The source is a DVD, mixed p/i sections.

Tdeint filter is used in this way:

TDeint(mode=0, full=false, cthresh=9, chroma=false, MI=32, edeint=QTGMC(Preset="Very Fast", FPSDivisor=2), emask=TMM(mode=0), slow=2, debug=true)

The problem is that in order to get a better decomb detection,
different mi / cthresh values are needed for p and i sections.

I feel that if the decomb algorithm is better, this manual progress may not be needed.

Is there any new filters or approaches to process mixed p/i source?
Thank you very much.

Music Fan
5th November 2015, 17:51
You can use trim and apply some settings to the i parts and other settings to the p parts.

AzraelNewtype
5th November 2015, 21:42
I have a similar issue that I've been working on, which also has some sections that are essentially progressive but reek of badly deinterlaced. I'm going a step further than this, and actually bobbing the interlaced bits and making it VFR, but not doing that skips you a step. For your sanity, you'll need python installed for a helper script I'll link in a second. You'll also need a couple plugins, starting with tivtc, but since your current method uses two other tritical ones I'm sure you have it.

The workflow goes like this:

- Trim out your episode from the rest of the vob (it has to be TV, right?)
- Run an analysis pass or avs2yuv pass to NUL or whatever with the following line (and no attempts at deinterlacing whatsoever):
writefileif("combed.log", "IsCombedTIVTC", "current_frame")
- Comment that line out immediately after the run finishes. You don't want to forget.
- Download this script (http://pastebin.com/Q40h8PJC) and run:
py frames-to-spans.py combed.log
That should give you a new file named combed-range.log, which is a list of frame ranges that are interlaced, but it's not even close to perfect.
- So now you're going to open that file and check the start of every range. Are there combed frames in front of it? If so, change the starts. Once you definitely hit a progressive frame, stick a "1 " in front of the range. You'll be using this later.
- Then check the end of the range. Are there combed frames after it? If yes, step forward until you hit progressive, and then change the end. The range building function was built with some fuzz, so a random skip here or there shouldn't split them too badly, but sometimes multiple ranges should actually just be combined. The end->start numbers should make it obvious if this is going to be the case.
- This probably goes without saying, but if the start,end range you have doesn't appear to actually be interlaced, just delete it. False positives exist just as much as false negatives.
- Then, once you have gone through all those bits, and added a "1 " to all the lines, get the ClipClop filter, and this is now your command list.
- Now you assemble the semi-manual nonsense like so:

(Any pre-deint processing)
prog = last
deint = prog.QTGMC("whatever you want")
prog.ClipClop(deint, cmd="combed-range.log")
(Any post-deint processing)


This isn't perfect, so I've actually been doing an intermediate pass at that point with fast deinterlacing and no post-processing and watching the encode to eyeball any outright missed combs, but they're pretty rare. I'm also fixing extra defects with extra clips to clipclop, so it's good for my use case. It's up to you whether you need that. This certainly "works", and is less frustrating than either full manual or automagic-and-pray, but it's time consuming.

Happy seeking.

StainlessS
5th November 2015, 23:01
@AzraelNewtype
I have not looked at your python script to change frames into ranges, but FrameSel_CmdReWrite() would probably do the same.


FrameSel_CmdReWrite(Clip c,String ofn, int F1, ... , int FN, String "SCmd"="", String "Cmd"="", \
Bool "Reject"=False, Bool "Ordered"=True, Bool "Debug"=False, Bool "Range"=True, Bool "Space"=False, Bool "Prune"=False)

Args identical to FrameSel (up to Debug), with exception of the additional compulsory 2nd String arg which is
an output filename, and missing Ver and Show and Extract args.
See FrameSel() description for other arguments.

ofn, String, Compulsory.
Output file name. It is advised to use a different name to the Cmd file, although there is nothing to stop you
overwriting an original Cmd file if you like a little gamble.(Output file only written after fully read in and
all Ordering, Rejecting etc already processed. Only likely error would be during file writing eg eject floppy disk).

Range, bool, Default=True
False = Write individual frame numbers only, to output file.
True = (Default) Write comma separated Frame Ranges to output file (only where adjacent frames).

Space, bool, Default=False
False = (Default) Write comma separators in output file for ranges.
True = Write SPACE separators in output file instead of comma for ranges.

Prune, bool, Default=False
False = (Default) Write FrameSel style frames or ranges to output file.
True = Write Prune style frames or ranges to output file (with a clip index first eg '0,10,20' instead of '10,20').
Prune supports up to 256 input clips that is the reason it needs a clip index.
Prune Supports Audio (whereas FrameSel does not) and also allows you to audio fadein/out at splices.
This function can only output Prune command files, it cannot read Prune command files.

FrameSel_CmdReWrite, takes either Frame numbers as direct arguments, or in the SCmd string, or in the Cmd file (at least one must
be specified). If more than one command method is used, will process Cmd file first, then SCmd string second and lastly
directly supplied frame numbers. The command frames will be acted upon via the Reject, and Ordered, args (as in FrameSel)
and then re-written to the output command file. Any comments in SCmd string or Cmd file will not be written to the output
command file.

The FrameSel_CmdReWrite() function returns the total number of frames written to the output file (including ranges).

This function could have several uses:-
To combine multiple frame specifying command methods into a single command file, and if Ordered, then remove duplicates.
Convert single frame command files to frame range command files, (smaller and perhaps easier to peruse).
Convert frame range command files to single frame command files, for use in another plugin that expects only frame numbers.
Convert a Reject=True command set to Reject=False command file, and vice versa.
Convert a command file of single frames/ranges to reject from a clip, into a Prune command file (Prune does not itself have a
Reject arg but it does fadein/out audio at splices and can also coalesce single frames into ranges before splicing so that
it does not fadein/out at every single individually specified frame).
Perhaps more uses.

*** NOTE ***, if you would normally use Reject=True in FrameSel, and you do a conversion with Reject=True, then the resultant
command file should be used with Reject=False in FrameSel.


Something like

FrameSel_CmdReWrite(c,"combed-range.log",Cmd="combed.log",Range=True)

should work, clip c compulsory but only really used where Reject arg is true so that it knows which frames not to reject (EDIT: ie c.FrameCount).

cagali
6th November 2015, 12:12
This isn't perfect, so I've actually been doing an intermediate pass at that point with fast deinterlacing and no post-processing and watching the encode to eyeball any outright missed combs, but they're pretty rare. I'm also fixing extra defects with extra clips to clipclop, so it's good for my use case. It's up to you whether you need that. This certainly "works", and is less frustrating than either full manual or automagic-and-pray, but it's time consuming.

Happy seeking.
@AzraelNewtype
This is really the kind of approach that I expected. Thank you!

The debug of tdeint maybe also helpful. An analysis pass will do, it outputs something like this:


00003641 21.41797256 [2620] TDeint: frame 3010: not deinterlacing (full = false, MIC = 4)
00003642 21.41988182 [2620] TDeint: frame 3011: not deinterlacing (full = false, MIC = 0)
00003643 21.42199707 [2620] TDeint: frame 3012: not deinterlacing (full = false, MIC = 0)
00003644 21.42488098 [2620] TDeint: frame 3013: not deinterlacing (full = false, MIC = 1)
00003645 21.42715073 [2620] TDeint: frame 3014: not deinterlacing (full = false, MIC = 1)
00003646 21.42849922 [2620] TDeint: frame 3015: deinterlacing (full = false, MIC = 104)
00003647 21.43368912 [2620] TDeint: frame 3015: accumPn = 9869 accumNn = 391965
00003648 21.43370247 [2620] TDeint: frame 3015: accumPm = 577 accumNm = 189553
00003649 21.70902634 [2620] TDeint: frame 3015: field = interp top (0) order = tff (1)
00003650 21.70903778 [2620] TDeint: frame 3015: mthreshL = 6 mthreshC = 6 type = 2
00003651 21.70933723 [2620] TDeint: frame 3016: deinterlacing (full = false, MIC = 175)
00003652 21.73060226 [2620] TDeint: frame 3016: accumPn = 174447 accumNn = 615751
00003653 21.73062134 [2620] TDeint: frame 3016: accumPm = 130209 accumNm = 387093
00003654 21.79043579 [2620] TDeint: frame 3016: field = interp top (0) order = tff (1)
00003655 21.79045486 [2620] TDeint: frame 3016: mthreshL = 6 mthreshC = 6 type = 2


It helps to pick better MI, cthresh, etc in tdeint.

cagali
6th November 2015, 12:13
@AzraelNewtype
I have not looked at your python script to change frames into ranges, but FrameSel_CmdReWrite() would probably do the same.


@StainlessS
There is a slight problem between TDeint and QTGMC even if I got a perfect frame range cmd file.
It is about having progressive and interlaced area on the same frame.
Would you have a quick look if you may visit this thread again? Thank you.

http://forum.doom9.org/showthread.php?p=1745392#post1745392

StainlessS
7th November 2015, 12:58
Sorry cagali, QTGMC does a way better job than anything I could do, ClipClop only selects frames as directed by a command file,
cannot do anything for mixed Progressive/Interlaced in same frame.

AzraelNewtype
7th November 2015, 21:28
You can always make a third clip where for those bits where you tweak the mask, and clipclop that in. And then if necessary a fourth. Or fifth. Dehumanize yourself and face to bloodshed (caused by tearing your hair out because it's not quite perfect yet but if you just do one little thing...)

cagali
8th November 2015, 07:58
@AzraelNewtype
@StainlessS
Thank you.
Let's pray there are only progressive videos some years later.
:)