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

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 13th October 2011, 03:37   #1  |  Link
sebazvideo
Registered User
 
Join Date: Sep 2009
Posts: 83
Example of ConvertFPS 25i to 29.97i?

I'm trying to convert a PAL HD interlaced video into an NTSC interlaced one to put in a Blu-ray. I did some research and the ConvertFPS command seems to be the best way to do it, but I tried to find examples and all I get in Google results seem to be from the same Wiki, and it's cryptic to me:

ConvertFPS(clip clip, int numerator [, int denominator, int zone, int vbi])

Then in the example, it shows this:

AVISource("NTSC_clip.avi") # Get clip
Bob(height=576) # Separate fields and interpolate them to full height.
BicubicResize(768,576) # Resize to PAL square-pixel frame size.
ConvertFPS(50) # Convert field rate to PAL, using Blend Mode.
SeparateFields.SelectEvery(4,0,3) # Undo Bob, even field first. Use SelectEvery(4,1,2) for odd field first.
Weave() # Finish undoing Bob.


Which I understand better, but I would like to also try the switch mode, and I can't find an example of how to use it. I just gather that it needs the parameters zone and vbi, but the syntax is not clear to me. Can anyone give me the right syntax for this type of conversion?

Thanks,

Sebastian
sebazvideo is offline  
Old 13th October 2011, 03:51   #2  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
This is a cut/paste from a script I saw either here or another forum. It seems to provide the best PAL to NTSC conversion of anything I've tried.

You'll have to change or remove the SetMTMode statements if you aren't set up for multithreading, or you don't have 8 cores (I find that with QTGMC I get more stability by using only 1/2 my cores).

I'm sure that some of the experts may have a few tweaks to suggest.

Quote:
#Script to convert PAL to NTSC

loadplugin("C:\Program Files\AviSynth 2.5\plugins\MVTools\mvtools2.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE2.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\SSE3Tools.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools-25.dll")

Import("E:\Documents\My Videos\AVISynth Scripts\QTGMC-3.31a.avsi") #Use version with hpad,vpad hardwired to 8 (avoids crash)

SetMemoryMax(1000)
SetMTMode(5,4)
AviSource("e:\frameserver.avi").killaudio().AssumeTFF()
SetMTMode(2)

ConvertToYUY2(interlaced=true, matrix="PC.601")

Spline36Resize(720,height)
QTGMC("faster", sharpness=0, SubPel=2) #SubPel must match pel in MSuper below
super = MSuper(levels=1, pel=2)
MFlowFps(super, QTGMC_bVec1, QTGMC_fVec1, num=60000, den=1001)
Spline36Resize(width,480)

blur(0.0,1.0)
sharpen(0.0,0.75) #Adjust 2nd value between 0.5 and 1.0 to taste

separatefields()
SelectEvery(4,0,3)
Weave()
johnmeyer is offline  
Old 13th October 2011, 04:08   #3  |  Link
sebazvideo
Registered User
 
Join Date: Sep 2009
Posts: 83
Quote:
Originally Posted by johnmeyer View Post
This is a cut/paste from a script I saw either here or another forum. It seems to provide the best PAL to NTSC conversion of anything I've tried.
Thanks John, although that script seems to be a lot more complicated than I can afford to spend time in right now, since also I would have to find and install those extra plugins. I would just like to give it a simple try to see if I can get a decent conversion, but if it's too complicated I can always leave it in PAL and play it in the computer, since my second monitor is my TV set anyway. I was wondering which would do a more accurate conversion, the graphics card or the Avisynth script.
sebazvideo is offline  
Old 13th October 2011, 06:24   #4  |  Link
nhope
partially-informed layman
 
Join Date: Jan 2002
Location: Bangkok, Thailand
Posts: 314
John's example is for SD. What resolution are you trying to convert from/to?

The extra plugins wouldn't take much finding. I'm using -Vit-'s updated modded plugins package from the first post of his QTGMC thread, along with v3.32 of QTGMC, and SEt's Avisynth 2.6 MT version 2011.09.13. I'm getting good stability running multi-threaded.

Here is a script for converting 1080-50i to 1080-60i, that should do better than your graphics card. You might need to change Rec709 to PC.709 to get the colorspace right, or leave that line out completely, depending on your scenario. I only just tested this very briefly, so there may be errors.

Code:
AviSource("d:\fs.avi")
AssumeTFF()
ConvertToYUY2(interlaced=true, matrix="Rec709")

QTGMC("faster", SubPel=2) #SubPel must match pel in MSuper below
super = MSuper(levels=1, pel=2)
#super = MSuper(levels=1, pel=2, hpad=16, vpad=16) #For very fast and quicker QTGMC presets
MFlowFps(super, QTGMC_bVec1, QTGMC_fVec1, num=60000, den=1001)

separatefields()
SelectEvery(4,0,3)
Weave()
nhope is offline  
Old 13th October 2011, 15:03   #5  |  Link
sebazvideo
Registered User
 
Join Date: Sep 2009
Posts: 83
Thanks, but it gives me an error, "there is no function named "mt_lutxy", so I guess I'll just encode it in PAL. It looks decent when played through the computer anyway.
sebazvideo is offline  
Old 13th October 2011, 15:27   #6  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
What do you mean "I'll just encode it in PAL"? PAL or NTSC can refer to many things, but actually it is just the way the analog color modulation is done, nothing else (not even lines count and framerate if you're picky), so please be more precise.
If I understood this correctly then you're trying to go from HD with the NTSC framerate of 29.97 (interlaced) to HD with the PAL framerate of 25 (interlaced). Edit: Of course the other way round.
The script posted by nhope does that, but I don't see a reason for ConverttoYUY2(). If the source is YV12 (which it should if it's a Bluray source) then the matrix parameter does not have any effect, it is only for RGB<->YUY2/YV12 conversions.

You need masktools-v2, get the latest one (masktools-v2.0a48.zip).


Edit: The very basic script without advanced tools would look like this:
Code:
WhateverSource() 
AssumeTFF() #or AssumeBFF, depending on source's field order
Bob() #Bob resets the internal field order flag to BFF 
ConvertFPS(60000,1001) 
AssumeTFF() #or AssumeBFF, keeps the original lines
SeparateFields().SelectEvery(4,0,3).Weave()

Last edited by TheSkiller; 13th October 2011 at 19:23.
TheSkiller is offline  
Old 13th October 2011, 17:08   #7  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by TheSkiller View Post
If the source is YV12 (which it should if it's a Bluray source) then the matrix parameter does not have any effect, it is only for RGB<->YUY2/YV12 conversions.
Not only does it have no effect, it is actually illegal and produces an error. This suggests (if this error was not reported) that the source really is RGB, and the conversion is required. (He said the destination was Bluray, not the source.)
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline  
Old 13th October 2011, 17:55   #8  |  Link
sebazvideo
Registered User
 
Join Date: Sep 2009
Posts: 83
Quote:
Originally Posted by TheSkiller View Post
What do you mean "I'll just encode it in PAL"?
Simply that, I'll leave it in PAL HD, 1080i 25 fps and watch it in the computer, which sends a 1080-60p signal to the TV set. I still have to encode it to burn it to a Blu-ray, because the original footage is in 50 Mbps and 4:2:2, which I believe Blu-ray players wouldn't accept, correct? I mean the chroma format for Blu-ray is supposed to be 4:2:0, correct?

I would just demux it and try to author it in 4:2:2 to see what happens, but the file is 48.4 GB, and I doubt it would fit even on a dual layer Blu-ray.
sebazvideo is offline  
Old 13th October 2011, 19:18   #9  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
Don't bother trying, 4:2:2 is not Bluray compliant and not commonly used in domestic compressed non-professional applications, which means the chances of having a player that does play it anyway are almost zero. Your video is probably not encoded using AVC, VC-1 or MPEG2 anyway. Bluray is 4:2:0 (YV12) only, correct. Also HD video is supposed to be using Rec.709 color coefficients. I don't know what source format you have but if it's 4:2:2 and HD then it's probably already in Rec.709.

Last edited by TheSkiller; 13th October 2011 at 19:24.
TheSkiller is offline  
Old 13th October 2011, 19:29   #10  |  Link
sebazvideo
Registered User
 
Join Date: Sep 2009
Posts: 83
This is the Media Info report on it:

Format : MPEG-TS
File size : 48.4 GiB
Duration : 2h 9mn
Overall bit rate mode : Variable
Overall bit rate : 53.4 Mbps

Video
ID : 514 (0x202)
Menu ID : 1 (0x1)
Format : MPEG Video
Format version : Version 2
Format profile : 4:2:2@High
Format settings, BVOP : Yes
Format settings, Matrix : Custom
Format settings, GOP : M=3, N=12
Codec ID : 2
Duration : 2h 9mn
Bit rate mode : Variable
Bit rate : 50.4 Mbps
Maximum bit rate : 90.0 Mbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Scan type : Interlaced
Scan order : Top Field First
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.972
Stream size : 45.6 GiB (94%)

Audio
ID : 670 (0x29E)
Menu ID : 1 (0x1)
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2
Codec ID : 3
Duration : 2h 9mn
Bit rate mode : Constant
Bit rate : 384 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Compression mode : Lossy
Delay relative to video : 10ms
Stream size : 356 MiB (1%)
Language : English
sebazvideo is offline  
Old 13th October 2011, 20:09   #11  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Gavino View Post
Not only does it have no effect, it is actually illegal and produces an error. This suggests (if this error was not reported) that the source really is RGB, and the conversion is required.
I overlooked the other possibility, which now seems to be the correct one, that the source was already YUY2 (4:2:2), so the Convert call was simply ignored.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline  
Old 13th October 2011, 22:06   #12  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
The ConvertFPS(clip clip, int numerator [, int denominator, int zone, int vbi]) algorithm is for use with interlace CRT displays.

It relies on the scanning spot on the CRT display actually taking time to move left to right (~64usecs) and top to bottom (a little less than 1/50th or 1/60th sec). By calculating where the spot will be at the time the next input field is due for display it can switch to that field at that position in the frame. So with a 60Hz display you get 50 new fields per second each displayed over 1.2 fields. Or with a 50Hz display you get 60 new fields per second each displayed over 0.83 fields.

On a real interlaced CRT the effect is very very good. The motion is very fluid and with a small amount of blending (zone param) the shift from one field to the next mid frame is not noticeable.

On a modern flat panel display (LCD, Plasma) the effect is very very horrible. The motion judders and the shift from one field to the next mid frame is quite obvious.

The options johnmeyer and nhope quoted are the state of the art Avisynth has to offer. It uses an advanced bob to produce a 50fps progressive frame stream (QTGMC). Then applies a motion analysis derived frame rate conversion (MFlowFps). The 60fps progressive frame stream is then interlaced back to 60i stream. Done carefully, the results can be very impressive.

The resizing is a SD thing, the SetMTmodes are crash faster options and the Blur/Sharpen are fine tuning taste things all muddy the scripts somewhat.

Unless you are prepared to wade through the mire of Bob de-interlacing and motion analysis derived frame rate conversion, both of which can have severe artefacts that may require careful tuning to avoid. I would suggest you carefully consider just making a 50i Blu-ray. Most players and displays will faithfully display 50i content these days.

Also you need to consider your content, if it is a mostly static image of talking heads then some simple bash ChangeFPS solution could be more than adequate.
IanB is offline  
Old 13th October 2011, 23:19   #13  |  Link
sebazvideo
Registered User
 
Join Date: Sep 2009
Posts: 83
Quote:
Originally Posted by IanB View Post
Most players and displays will faithfully display 50i content these days.

Also you need to consider your content, if it is a mostly static image of talking heads then some simple bash ChangeFPS solution could be more than adequate.
Actually not so much, I authored a PAL BD-RE with the few minutes I had encoded as a test in 50i. My Sony BD player doesn't take it, and my Panasonic player apparently plays it but wihout converting it, it sends a PAL signal to the TV set, which in turn says "signal not supported".

The content is a concert from a Scottish broadcast, but apparently somebody got this from a direct satellite feed from station to station because no TV broadcast is 50 Mbps. But besides being in 50i, it seems they used a very high speed shutter in all the cameras, which is annoying because they do a lot of panning and fast movement, and you see a lot of repeated borders that are typical with high shutter speeds. When I load the file into MeGUI and it shows me the preview, even in one still frame I can see double borders. So when played as interlaced, it looks weird, like that 120 Hz effect they put on TVs these days which is nothing but a lot of frame blending (or at least looks like it). So I'm considering doing a Yadif deinterlace and author it as a 25p instead.
sebazvideo is offline  
Old 13th October 2011, 23:24   #14  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Quote:
Originally Posted by sebazvideo View Post
The content is a concert from a Scottish broadcast, but apparently somebody got this from a direct satellite feed from station to station because no TV broadcast is 50 Mbps.
Closed for rule 6 violation.

Last edited by Guest; 14th October 2011 at 00:18.
Guest is offline  
Closed Thread

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 08:43.


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