View Full Version : 30i on top of 24p


Daodan
23rd December 2010, 16:56
I've looked the forums high and low, but couldn't find a thread about this particular problem, although I doubt it's new.

So let's say we have 24p scrolling images, then telecined to 30i, and on top of it overlayed a pure 30i of scrolling text.

How would one restore such a thing to a smooth motion of both the images and the text? I can only seem to manage to get 24p with proper motion in back and ok but jumpy text, or 30p with smooth text and obviously jumpy background due to duplicates.
Is there a way?
Thanks.

roozhou
23rd December 2010, 17:07
Convert to 60p.
1) IVTC the background part and apply 6:4 pulldown.
2) Bob the 30i text part.

Daodan
23rd December 2010, 17:14
Hm, I'm not sure I understood what you mean. It sounds like the 24 and 30 parts are separate. But they're not separate. The 30i is scrolling on top of the 24p.

cretindesalpes
23rd December 2010, 17:45
You can look at the p60to24p function:
http://forum.doom9.org/showthread.php?p=814547#post814547
However this may be not the best tool to achieve what you need.

The following function deinterlaces 60i credits on the top of a 24 fps telecined footage. It virtually oversamples the video to 120 fps with motion interpolation on credits only, and decimates to 24 fps. It has the advantage of avoiding footage frames interpolation, leaving them very clean, whatever the motion they contain. However, the drawback is that it requires to manually measure the origin of the 3:2 pulldown pattern (and split the clip in parts if it changes).

# Version 1.1
Function ivtc_txt60mc (clip src, int frame_ref, bool "srcbob", bool "draft")
{
srcbob = Default (srcbob, false)
draft = Default (draft, false)

field_ref = (srcbob) ? frame_ref : frame_ref * 2
field_ref = field_ref % 5
invpos = (5 - field_ref) % 5
pel = (draft) ? 1 : 2

src
(srcbob) ? last
\ : (draft ) ? Bob ()
\ : QTGMC (SourceMatch=3, Lossless=2, tr0=1, tr1=1, tr2=1)

clean = SelectEvery (5, 1 - invpos)
jitter = SelectEvery (5, 3 - invpos, 4 - invpos)
jsup = jitter.MSuper (pel=pel)
vect_f = jsup.MAnalyse (isb=false, delta=1, overlap=4)
vect_b = jsup.MAnalyse (isb=true, delta=1, overlap=4)
comp = jitter.MFlowInter (jsup, vect_b, vect_f, time=50, thSCD1=400)
fixed = comp.SelectEvery (2, 0)
Interleave (clean, fixed)
Trim (invpos / 2, 0)
}

The src parameter is a 30 fps interlaced clip. The frame_ref parameter indicates on which frame begins the 3:2 pattern (first frame number of a clean-combed-combed-clean-clean sequence). Add SetMemoryMax (1500) at the beginning of your script if you are processing HD content.

I've put in this archive (http://dl.free.fr/vtu0fcb4v) examples showing several common methods to deinterlace 60i credits. The one covered by the above script is correct.mp4.

If you can read french, I wrote a more detailed article about this kind of issue:
http://qualiter.fr/viewtopic.php?f=11&t=24

Daodan
23rd December 2010, 18:39
Sounds pretty good. The problem is it's so slow that I can't test it. Around 1 min per frame. Can't that qtgmc be replaced with smth else for speed?:eek:

TheRyuu
23rd December 2010, 18:56
Sounds pretty good. The problem is it's so slow that I can't test it. Around 1 min per frame. Can't that qtgmc be replaced with smth else for speed?:eek:

Pretty sure you can just insert any random bobber there (yadif, nnedi, etc). nnedi3 is probably going to give you the best bang for your buck I guess.

roozhou
23rd December 2010, 19:03
The scrolling credit only occupies a fixed area in the image. Cut the rectangle(top and bottom location should be mod4) off and run deinterlacer on it. Do IVTC to the rest of the image. Overlay the deinterlaced rectangle back to the original place.

Remember doing anything other than IVTC to telecined part will destroy the image.

Daodan
23rd December 2010, 19:53
The scrolling credit only occupies a fixed area in the image. Cut the rectangle(top and bottom location should be mod4) off and run deinterlacer on it. Do IVTC to the rest of the image. Overlay the deinterlaced rectangle back to the original place.

Remember doing anything other than IVTC to telecined part will destroy the image.

Interesting idea. I wonder how would that look. In any case, the text is more than 2/3 of the screen so it's no use here.

@cretindesalpes, that demo sample is very good, but I can't replicate the good results here. I did a couple seconds in the end and the script did it's thing, the text is definitely shifted compared to a normal ivtc, quite interesting, but it's not 'evenly distributed' so ti's still jumpy, slightly less than before.
I should mention the text and background both scroll the same way, unlike the demo where one was vertical and the other horizontal.

cretindesalpes
23rd December 2010, 21:05
Around 1 min per frame.
On which hardware ? I've got 0.75 fps with these settings (1440x1080) on a 4-core CPU, using only 50% CPU. Make sure you've allocated enough memory to AviSynth, otherwise things tend to become damn slow. QTGMC + subsequent MVTools is a real resource hog. Also, you shouldn't do any other processing in this script because of the aforementioned reasons. Load the video, trim the segment to process, call ivtc_txt60mc and save the result to a lossless file.

I did a couple seconds in the end and the script did it's thing, the text is definitely shifted compared to a normal ivtc, quite interesting, but it's not 'evenly distributed' so ti's still jumpy, slightly less than before.
Make sure the frame_ref value is correct, and constant on all the processed clip. If it still doesn't work, post a sample.

Daodan
23rd December 2010, 21:45
Well, I have a decent c2d, but i guess memory might be a problem.
Here's a raw sample: http://ul.to/zsq2yv
Compared to normal ivtc, where i get normal jump, normal jump, normal jump, big jump (the scrolling text), with this script now I get small jump, small jump, big jump, big jump. Which makes things slightly worse. I'm pretty sure the frame ref value was good, because the background remained in same position as normal ivtc (I tried other values and it's always worse).

cretindesalpes
24th December 2010, 00:15
Here's a raw sample: http://ul.to/zsq2yv
This works well with frame_ref = 0. But your input is not frame-accurate (typical with BD m2ts sources), hence the jumps. Possible workarounds:

Use RequestLinear() after your source. Works well during the actual processing, but your Trim may still be off by a few frames.
Reencode the whole stream in a single pass. Ex: x264 --preset ultrafast --tff --qp 0 --output accurate.mp4 inaccurate.avs with a single line DSS2("myfile.m2ts") in the script. Then use accurate.mp4 with a decent source filter, like FFmpegSource2().

Daodan
24th December 2010, 01:37
Can't say I managed to improve it. I'll try some more later.
Can you upload the processed clip somewhere to see how it should turn out?

cretindesalpes
24th December 2010, 10:15
Can you upload the processed clip somewhere to see how it should turn out?
(broken link) (http://dl.free.fr/fN04XBwCJ)
I also had to increase SetMemoryMax to 1300.

Daodan
24th December 2010, 17:19
Thanks. Looks good. Too bad I can't replicate the results. If values are the same as in the posted script, I guess it must be a wrong filter version on my side.

Later edit: seems like I solved the problem, thanks for the help.

TheRyuu
25th December 2010, 04:34
This works well with frame_ref = 0. But your input is not frame-accurate (typical with BD m2ts sources), hence the jumps. Possible workarounds:

Use RequestLinear() after your source. Works well during the actual processing, but your Trim may still be off by a few frames.
Reencode the whole stream in a single pass. Ex: x264 --preset ultrafast --tff --qp 0 --output accurate.mp4 inaccurate.avs with a single line DSS2("myfile.m2ts") in the script. Then use accurate.mp4 with a decent source filter, like FFmpegSource2().


Any of the dgavcdecode/nv/di should be fine when dealing with BD material. dss2 is ok although i've found it to not be frame accurate (or work) all the time. ffms2 sometimes works although with interlaced you do get a weird doubling framerate sometimes with interlaced content (if it even works).

Given the choice I would output it to mkv, not mp4, although h264 lossless would not be my first choice (see below).

Since the section we're talking about is probably not very big (an opening/ending perhaps), your second option to encode to some type of lossless file first is probably the best option, although I would use ut video instead of h264 lossless.

The Showstopper
16th June 2011, 15:40
Hi, I'm trying to do a script but it keeps geting me the error of invalid arguments for the function "ivtc_txt60mc", here is the part where it gets the error:


Trim(0,38889).AnimeIVTC(mode=4, omode=2, pass=1) + Trim(38890,40626).ivtc_txt60mc(frame_ref=108) + Trim(40627,41089).AnimeIVTC(mode=4, omode=2, pass=1)


Is it because I didn't use the "src_bob" and "draft" parameters?? Btw the frame_ref is the frame of the entire video (in that case it would be 38908) or only of the trimmed part (it would be 108)??

Gavino
16th June 2011, 16:43
frame_ref is a mandatory parameter (it is not enclosed in quotes in the function definition), so cannot be passed by name.

... + Trim(38890,40626).ivtc_txt60mc(108) + ...

but if your 38908 is correct, it should be 18, not 108.

The Showstopper
17th June 2011, 01:51
Thanks, it worked, btw what if the background instead of being 24p, was 29p would it still work?? If not would it be possible to make a script like this for 29p parts?

EDIT: Forget about that I thought I had 29p parts but it was just that the telecine was hard to spot... Is there something that we can change on the script to obtain credits at 29,970p instead of 23,976p?? But the backgorund stays at 24p

blank000
22nd April 2016, 09:02
Hi, cretindesalpes

Is this function interchangeable with mvtools-pfmod2.7.0.1?
It was used by the same condition, but error

"Error requesting frame 1"
"windowsError: exception: access violation reading 0x34AEF406"

Should this question be done by other threads? :(

system environment
windows10_32bit
Avisynth260_x86

thecoreyburton
27th April 2016, 05:23
If you're comfortable with having a VFR file as your output you could very comfortably IVTC the 24p sections and deinterlace the interlaced sections (albeit only to 30p) and have the resulting clip play both parts at their resulting rate.

It's not too tricky when you've done it a few times and if you want to go down this path I'd be happy to help.

blank000
29th April 2016, 14:33
Hi, cretindesalpes

Is this function interchangeable with mvtools-pfmod2.7.0.1?
It was used by the same condition, but error

"Error requesting frame 1"
"windowsError: exception: access violation reading 0x34AEF406"

Should this question be done by other threads? :(

system environment
windows10_32bit
Avisynth260_x86

This problem
mvtools2 2.7.0.22 for 32 and 64 bit (20160429)
It was settled by this:)

colours
29th April 2016, 14:57
VFR isn't tricky, except for the part where AviSynth does not natively support VFR and you have no choice but to use VFRaC. (I mean, that's not hard per se, but it was nonobvious to sufficiently many people that TheFluff wrote a blog post about it nine years ago.)

There're multiple ways of handling such content. You could:

- just disregard the interlaced overlay and IVTC as usual (upside: this is extremely easy; downside: the overlay will be jerky and look like it's combed or badly deinterlaced)

- use ivtc_txt60mc (upside: no judder at all and it's a standard solution so people know about it and can answer questions; downside: motion compensation is lolslow, and there may be shimmer because of how ivtc_txt60mc uses bottom fields a quarter of the time and top fields another quarter)

- deinterlace the section to 60p (upside: easy, overlay shows up as intended; downside: it's VFR, potential shimmer for the same reason as above, playback may need more resources because the frame rate is 2.5 times as high, playback might not even work with some renderers because of vsync-related shenanigans, more CPU time needed for deinterlacing, slight judder because of the 3:2 cadence in the background)

- deinterlace the section to 30p (upside: easy, negligible shimmer because all frames are deinterlaced from the same parity; downside: it's also VFR, significant judder because of the 2:1:1:1 cadence, potential loss of vertical resolution depending on deinterlacer used)

Pick your poison, basically. (I realise I'm responding to a post responding to another post written five years ago, but I assume this information would be generally useful.)