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 May 2013, 06:27   #1  |  Link
DoctorM
Registered User
 
Join Date: Sep 2005
Posts: 558
(Yet Another) Weird Pattern 25 -> 29.97 telecined

I've been banging my head against a piece of interlaced video (29.97) for a couple days.

I tried IVTC'ing with TFM and Telecide (then decimating). The output keeps ending up jittery. (Duplicate and missing frames).

Finally in disgust I used bob() and counted unique fields and discovered the source to be 25 fps. The thing is there is no ghosting, blending or anything wierd. Just 25 unique fields and a very strange pattern of duplicates.

My current script looks like:
Code:
qtgmc(Preset="medium")
fdecimate(25)
assumefps(23.976)
I'm assuming there will be speed up in the audio that needs correction, but that's a different can of worms.

The point being, this method is slow (even at Medium).
TFM will inverse telecine to 29.97 but drop frames (that I can see with a bobber).

It would be quicker and produce better quality to IVTC directly, but I know of no filter that is tunable to match fields for frame rates besides 29.97.

Suggestions?
DoctorM is offline   Reply With Quote
Old 26th May 2013, 07:02   #2  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by DoctorM View Post
Suggestions?
My first suggestion is that you provide a sample. If you're asking here what to do, maybe you don't know how to diagnose what you have either. Samples are always better than descriptions.

Anyway, based on your description, maybe this will work:

TFM()
Tdecimate(Mode=0,Cycle=6,CycleR=1)

But I'd still feel more comfortable offering advice if there was a sample included.
Quote:
TFM will inverse telecine to 29.97 but drop frames (that I can see with a bobber).
TFM is a field matcher. It's only part of an IVTC. It doesn't drop frames. Your source is also 29.97fps, isn't it?

Quote:
but I know of no filter that is tunable to match fields for frame rates besides 29.97.
TIVTC can produce a virtually limitless number of framerates. As can Decomb. If there are a bunch of orphaned fields in this thing, then there will be problems and your current solution may be the best.

Last edited by manono; 26th May 2013 at 07:04.
manono is offline   Reply With Quote
Old 26th May 2013, 15:21   #3  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
Please provide a sample.

From your description it sounds like 25p wrapped in 29.97i using pulldown. Nothing weird about that. Manono's suggestion would deal with exactly that (result would be 24.97 fps which can be left as is or speed up to 25 fps).

If you're unlucky, editing has been done in 29.97i.
TheSkiller is offline   Reply With Quote
Old 26th May 2013, 16:45   #4  |  Link
DoctorM
Registered User
 
Join Date: Sep 2005
Posts: 558
Quote:
Originally Posted by manono View Post
My first suggestion is that you provide a sample. If you're asking here what to do, maybe you don't know how to diagnose what you have either. Samples are always better than descriptions.
Good point. Clip here.

Quote:
Anyway, based on your description, maybe this will work:

TFM()
Tdecimate(Mode=0,Cycle=6,CycleR=1)

But I'd still feel more comfortable offering advice if there was a sample included.

TFM is a field matcher. It's only part of an IVTC. It doesn't drop frames. Your source is also 29.97fps, isn't it?
And yet oddly TFM was dropping frames.
Haven't had a moment to test this yet, will a bit later.

Quote:
TIVTC can produce a virtually limitless number of framerates. As can Decomb. If there are a bunch of orphaned fields in this thing, then there will be problems and your current solution may be the best.
Yes, I realized I mis-spoke when I suggested I needed to IVTC to a different frame rate than 29.97. I meant I needed something besides the standard pattern after frame matching.

If by orphaned fields, you mean single fields without a match, yeah, I've got them. I assumed they'd end up as a remaining combed frame that gets passed to the post processor.
DoctorM is offline   Reply With Quote
Old 26th May 2013, 20:45   #5  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by DoctorM View Post
And yet oddly TFM was dropping frames.
It's dropping fields. And yes, they're orphaned fields - fields for which there's no match. TFM won't create a duplicate for an orphaned field on which to match, or bob it. It'll just drop it. This is a most peculiar way to convert PAL to NTSC. I'd do it as you showed in your first post, maybe changing the decimate portion to:

TDecimate(Mode=0,Cycle=60,CycleR=35)

But it doesn't matter a whole lot. Ignore the jump on frame 15 because there isn't a full cycle on which it can work.

Edit: I was thinking about this some more. The only IVTC that bobs fields if needed is the old SmartDecimate. I tried it and even it had trouble going straight to the final framerate. But if field-matching/bobbing to 29.97 followed by a decimate, it did better. Here's the script:

SmartDecimate(30,60)
TDecimate(Mode=0,Cycle=30,CycleR=5)


Here's an MP4 I made of it. I can't tell if it's perfect or not but, while it isn't as fast as using TIVTC alone, it's way faster than having QTGMC in there:

https://mega.co.nz/#!kJxwERSK!ZaG5iH...PB2R-O1ikP4as0

Last edited by manono; 26th May 2013 at 21:33.
manono is offline   Reply With Quote
Old 27th May 2013, 00:12   #6  |  Link
DoctorM
Registered User
 
Join Date: Sep 2005
Posts: 558
Good suggestions, manono.

TDecimate seemed to hit on unique frames more accurately. SmartDecimate preserves a lot more detail. Which onsidering the condition of the source is nice.

I play around with that some more, but that looks to be the best answer... and much faster.

Edit: I cannot get my head around what exactly it is that SmartDecimate is doing. The page doesn't make a lot of sense when I read it.
http://avisynth.org.ru/docs/english/...rtdecimate.htm

Last edited by DoctorM; 27th May 2013 at 00:19.
DoctorM is offline   Reply With Quote
Old 27th May 2013, 01:41   #7  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by DoctorM View Post
Edit: I cannot get my head around what exactly it is that SmartDecimate is doing.
Do you really have to understand what it's doing? Isn't it enough that it works?

Think of it as a regular IVTC with the extra added attraction of being able to use bobbed fields when needed. I believe it was developed as a way to get a single framerate out of hybrid material - things like the Star Trek spinoffs where there's a mix of film and interlaced computer generated material. By being able to use bobbed fields on occasion, it's better at getting nicer-looking results from the video portions than the Decomb or TIVTC methods of blending frames (when converting from interlaced 29.97fps to progressive 23.976fps).

Knowing that, I decided to see if it worked with your sample or other material with orphaned fields. It does, after a fashion. I think it bobbed and kept all the orphaned fields, but because the duplicate pattern was peculiar afterwards, I decided TDecimate was better to remove those dupes. As I mentioned, I used SmartDecimate to get progressive 29.97fps from your source, before then using TDecimate to bring it down to 24.975fps.

You'll notice it uses the AviSynth Bob filter when bobbing. You might want to use a better bobber when needed, maybe even QTGMC. The manual explains how to replace Bob with any bobber you might want to use.

Last edited by manono; 27th May 2013 at 01:55.
manono is offline   Reply With Quote
Old 27th May 2013, 21:22   #8  |  Link
DoctorM
Registered User
 
Join Date: Sep 2005
Posts: 558
Good point. There are some confusing details about the filter. At one point it is just about saying it decombs instead of matching fields and then later you can set how aggressively it matches fields.

Good eyes with the bob= option. Missed that. Unfortunately, Yadif, Yadifmod and qtgmc all cause a crash. Either a silent crash or a program error (not avisynth) (Media Player Classic, VDubMod, etc.) and "R6025 Pure Virtual Function Call". Even dgbob (their example) didn't work. Huh?

Not sure what's going on there.
DoctorM is offline   Reply With Quote
Old 28th May 2013, 00:02   #9  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Yeah, I had trouble getting it going too. It's been years since I used it and several AviSynth versions ago. Maybe someone with more knowledge than I can give a more efficient way to set it up, but what made it work for me was sticking the other needed DLLs before the AviSynth_C.dll needed by SmartDecimate. I couldn't get it going with either the LoadCPlugin or StdCallPlugin. Something like this worked:

LoadPlugin("D:\AviSynth Stuff\Dlls\DGDecode.dll")
LoadCPlugin("D:\AviSynth Stuff\Dlls\Yadif.dll")
LoadPlugin("D:\AviSynth Stuff\Dlls\avisynth_c.dll")
#Yadif before AviSynth_C.dll
LoadCplugin("D:\AviSynth Stuff\Dlls\SmartDecimate.dll")
LoadPlugin("D:\AviSynth Stuff\Dlls\TIVTC.dll")
MPEG2Source("E:\Test\Test.d2v")
SmartDecimate(30,60,Bob=Yadif(Mode=1))
TDecimate(Mode=0,Cycle=30,CycleR=5)


But as I said, there are probably better ways to set it up.
manono is offline   Reply With Quote
Old 28th May 2013, 00:32   #10  |  Link
DoctorM
Registered User
 
Join Date: Sep 2005
Posts: 558
Cheers. I'll give it a go.
DoctorM is offline   Reply With Quote
Old 28th May 2013, 05:33   #11  |  Link
DoctorM
Registered User
 
Join Date: Sep 2005
Posts: 558
Still unable to get a custom bobber to work. I figured it was because I wasn't calling the autoloading plugins, but that didn't help.

Btw, I found there was still the occasional incorrect frame after decimation.
Counting SmartDecimate's output I found this pattern: 12344 1234566 12344 1234566

As a result having TDecimate check cycles of 30, a range not divisible by 12, produces one improper decimation every second.

Changing to: TDecimate(Mode=0, Cycle=12, CycleR=2) improved accuracy and produced a serious bump to performance.
The pattern seems to hold throughout the video.

Now if I can just get the bobber fixed...

Last edited by DoctorM; 28th May 2013 at 05:42.
DoctorM is offline   Reply With Quote
Old 28th May 2013, 08:25   #12  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by DoctorM View Post
Counting SmartDecimate's output I found this pattern: 12344 1234566 12344 1234566
I noticed that too, but it's not consistent all the way through. Sometimes it switches.
Quote:
As a result having TDecimate check cycles of 30, a range not divisible by 12, produces one improper decimation every second.
I found the two different decimation methods to produce frame-for-frame identical results with the sample. Of course, yours is faster and if it works throughout the whole complete video, then of course you should go with it.

I'm sorry you haven't got the other bobbers to work with SmartDecimate yet. I don't know what other advice to offer. Good luck.
manono is offline   Reply With Quote
Old 28th May 2013, 20:06   #13  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
The pattern in your sample is a little convoluted, but appears to repeat. Therefore the Cycle/CycleR in TDecimate works perfectly, if you count the pattern correctly. Here is the field count I came up with, where each digit represents a frame, and 1, 2, and 3 represent the number of fields in each frame in the original video ("2" fields is, of course, what you want for every frame). I viewed this using a script that is nothing more than "separatefields()" :

3-1-3-2-3-2-3-2-3-2-2-2-3-2-3-2-3-2

If you count the number of digits, there are 18 digits, so there are 18 frames. So, after field matching and decimation, we want to end up with 18 frames (36 fields) from these 43 fields. Therefore, out of every 43 fields, we should decimate 7.

Code:
AssumeTFF()
tfm(display=false,order=-1)
tdecimate(display=false,cycleR=7,cycle=43)
However ...

There is something in the TFM logic that I don't quite understand in how it post-processes the individual fields that have no match. If you set "order=1" TFM will correctly post-process the unmatched odd fields. For these single fields (shown by the "1" in the pattern above) it will give you a frame that contains the original unmatchable field plus a synthesized field, created using whatever technique you choose using the "pp" parameter. However, it skips the even fields. If you instead set "order=0," it then does the even fields but skips the odd fields.

So near and yet ...

So, the TDecimate logic works great, but the TFM matching and post-processing doesn't quite do the trick.

Another approach might be to double the frame rate using a bobber or deinterlacer, and then decimate from that.

One final note. I found that the pattern repeats every 43 fields but when I actually walked through the result, putting a separatefields() at the end of the recovered video so I could see what was happening, I found there was still an undecimated result every two cycles. So I doubled Cycle and CycleR and then added one to CycleR in order to remove these remaining duplicates:

Code:
AssumeTFF()
tfm(display=false,order=1)
tdecimate(display=false,cycleR=15,cycle=86) 
separatefields()
The separatefields() statement is there for debugging purposes, so I can see exactly what is going on, and would of course be removed when using the script to actually generate the final video.

Last edited by johnmeyer; 28th May 2013 at 20:10. Reason: added: ("2" fields is, of course, what you want for every frame)
johnmeyer is offline   Reply With Quote
Old 28th May 2013, 20:14   #14  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
P.S. to my last post. I didn't actually use "MPEG2Source("E:\Test\Test.d2v")" to read the video and perhaps I should. In reading the TFM documentation, there is a parameter that sounds like it might solve the problem:

Quote:
d2v -

This option is intended to be used if you are using an mpeg2source() with a d2v file.
It sets the name and path to a d2v file, which TFM will analyze to see if there are any
illegal field order changes and optionally set the order parameter using the field
order of the d2v file.
johnmeyer is offline   Reply With Quote
Old 28th May 2013, 23:16   #15  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Quote:
Originally Posted by johnmeyer View Post
If you set "order=1" TFM will correctly post-process the unmatched odd fields.
It doesn't. There are 2 missing fields/frames doing it that way. Using this script:

TFM(Order=1)

Even before decimation there are already two missing frames, before frames 30 and 73. TFM just cannot handle this.

AssumeTFF()
tfm(display=false,order=-1)
tdecimate(display=false,cycleR=7,cycle=43)


That can't be correct. The final framerate is 25.091 when it should be 24.975fps. You still have the same two 'jumps' plus three duplicate frames.

AssumeTFF()
tfm(display=false,order=1)
tdecimate(display=false,cycleR=15,cycle=86)


Nope again, the same two missing frames and the wrong final framerate. Anything that doesn't return 24.975fps is wrong.


Quote:
In reading the TFM documentation, there is a parameter that sounds like it might solve the problem:
It won't as there are no field order problems with the sample. The D2V setting is mainly for helping when there's a mix of hard and soft telecine.

TIVTC isn't optimum for this video.

Last edited by manono; 29th May 2013 at 01:31.
manono is offline   Reply With Quote
Old 28th May 2013, 23:25   #16  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,695
OK, I guess I'm an idiot. I'm sorry I spent the time doing this.
johnmeyer is offline   Reply With Quote
Old 28th May 2013, 23:33   #17  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
It's a learning experience sometimes just to discover how many ways a simple video can be completely messed up by the so-called 'professionals'. There are so many ways to screw up PAL2NTSC when it's so easy just to do it correctly the first time. The mind boggles sometimes because it's then up to us amateurs to try and put things right. I was stumped too, and had tried all sorts of things with TIVTC before giving up, but had had experience with SmartDecimate years ago and decided to give it a try. Maybe there are other and more simple ways to solve this one, but that will have to await the efforts of someone else.
manono is offline   Reply With Quote
Old 29th May 2013, 00:11   #18  |  Link
DoctorM
Registered User
 
Join Date: Sep 2005
Posts: 558
@johnmeyer - If I read you right, you didn't get TFM to work then? It seems apparent that TFM won't properly process an orphaned field.

Besides, I don't know how I feel about using a 43 frame range. That'll take forever to process.

@manono - Fixed my bobber issue. You need to get the bobbing out of the way before SmartDecimate made things awkward.

Code:
MPEG2Source("Test.d2v")
yada=yadif(mode=1)
SmartDecimate(30,60,bob=yada)
TDecimate(Mode=0,Cycle=12,CycleR=2)
Btw, I see what you mean about the odd pattern. The clip I posted generates a 7 7 5 7 5. The full version produces a slightly different one with one 9 frame run.

Yet once fully run through the script there are no duplicate frames or apparent missing ones (the movement is smooth).

With the 30/5 numbers I did see some duplicates and missing frames in the video 1-2 seconds before the clip I posted (when there was a smaller difference for the frame matcher to detect).
DoctorM is offline   Reply With Quote
Old 29th May 2013, 09:09   #19  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by DoctorM View Post
Fixed my bobber issue. You need to get the bobbing out of the way before SmartDecimate made things awkward.
Code:
...
yada=yadif(mode=1)
SmartDecimate(30,60,bob=yada)
Not sure what you mean here.
Internally, that code is exactly the same as manono's
SmartDecimate(30,60,bob=yadif(mode=1))

Your earlier problem almost certainly has something to do with incompatibilities between the built-in LoadCPlugin() and the older avisynth_c.dll (which declares its own LoadCPlugin() function).
I suspect Yadif needs the built-in version while SmartDecimate needs the older one, so the order of loading the dll's becomes important. Hence manono's solution of manually loading the plugins in the appropriate order.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 29th May 2013, 18:26   #20  |  Link
DoctorM
Registered User
 
Join Date: Sep 2005
Posts: 558
Except manono's script as he posted it did not work for me. Yes, I loaded the plugins in the same order he did, but for me I had to actually use Yadif before SmartDecimate.
DoctorM 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 00:46.


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