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 6th September 2013, 10:21   #1  |  Link
edheaded
Registered User
 
Join Date: Jun 2012
Posts: 5
Good compromise on speed/quality for 1080i 25fps to PAL resize script?

Howdy.

I've received over eight hours worth of MXF files (1080i 25fps, mpeg-2, AES audio) that need to be encoded for PAL DVD.

The normal safe/tedious workflow we use is to transcode using Episode to ProRes Quicktime, play out and downsize to PAL using a blackmagic card -> blackmagic card, then encode. However, I'm convinced I can more efficient results using avisynth to resize these, but there seems to be so many different methods out there.

I wondered if anyone had a fairly fast but good quality method for parsing 1080i 25fps mxf files for PAL MPEG-2 encoding?

I've used the hd2sd script before, but it's slow as hell (I don't have several days to encode) and I've ended up with some horrible aliasing artifacts/jitter, especially on vertical pans (even with a failry heavy vertical blur). I also tried using just a spline resize with a blur, which seemed to give good results and was fast but I'm concerned what it's doing with the fields.

I'm now playing around with various scripts and running test, but it seems debatable whether to:

a) deinterlace->resize->reinterlace
b) separate fields->resize->reinterlace
c) hd2sd with blur
d) just resize and let the encoder (Totalcode or HCenc) deal with interlacing and cross fingers

Anyone have a tried and tested methods? I seem to be going round in circles here.
edheaded is offline   Reply With Quote
Old 6th September 2013, 11:19   #2  |  Link
ajk
Registered User
 
Join Date: Jan 2006
Location: Finland
Posts: 134
Since you are going down from a high resolution to a low one, in my opinion a simple bob()/yadif() + reinterlacing should do just fine. Try something like

Code:
xxxSource("...")

bob()  # or yadif(mode=1)

bicubicresize(720,576)
blur(0, 0.5)  # not required, but some vertical blur may look nicer in the final image, experiment

separatefields()
selectevery(4, 0, 3)
weave()
You may also need to switch the field order, I'm not familiar with MXF files and what they contain exactly.

Last edited by ajk; 6th September 2013 at 21:57. Reason: fixed
ajk is offline   Reply With Quote
Old 6th September 2013, 15:12   #3  |  Link
edheaded
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks, I'll give this a go.

The original mxf is top field according to Mediainfo. There's some quite nasty line flicker on some vertical scrolling credits at the end (which is apparent in the source as well), which I'm hoping is just a computer monitor/interlacing issue.
edheaded is offline   Reply With Quote
Old 6th September 2013, 20:28   #4  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
Quote:
Originally Posted by edheaded View Post
However, I'm convinced I can more efficient results using avisynth to resize these
Certainly.

The first thing you should check is if the source files actually do show interlacing (in contrast to a tool reporting interlacing). The result is either 1) yes, all the time 2) no, only certain parts 3) no, never.

In case of 1) and 2) you want to keep the interlacing and need to account for it. In case of 3) you can ignore what the flags say and pretend it's all progressive.
However, if you're not 100% sure about 3) then go for the interlaced route because you absolutely don't want to blend any fields during resizing.

Quote:
Originally Posted by ajk View Post
Since you are going down from a high resolution to a low one, in my opinion a simple bob()/yadif() + reinterlacing should do just fine.
I agree. Though QTGMC with a fast preset is pretty fast, too. It all depends on how fast it needs to be but yeah, Bob() and Yadif(mode=1) are as fast as it gets and there would be a very minor improvement only if you use anything slower.


When it comes to lowpassing the lines vertically after resizing, at first it may seem odd but except for computer animated sources it's recommendable to have Blur() followed by Sharpen(). What this actually does is it "thickens" the vertical details a bit instead of just blurring them together.

This is what I would recommend:
Code:
#[Pick one line]
Blur(0, 0.6, false) Sharpen(0, 0.4, false) #this is very mild
Blur(0, 0.7, false) Sharpen(0, 0.4, false) #good starting point
Blur(0, 0.8, false) Sharpen(0, 0.5, false) #for very sharp sources
Where do these values come from? Elaborate tests I did.

Last edited by TheSkiller; 6th September 2013 at 22:39.
TheSkiller is offline   Reply With Quote
Old 6th September 2013, 21:29   #5  |  Link
ajk
Registered User
 
Join Date: Jan 2006
Location: Finland
Posts: 134
Sounds worth a try I corrected the script a bit, had assumefieldbased() where assumeframebased() was intended.
ajk is offline   Reply With Quote
Old 6th September 2013, 21:41   #6  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
You don't need either actually, instead you should specify the desired field order of the output.
Replace AssumeFrameBased() with AssumeTFF() or AssumeBFF().


Also, you don't need

interleave(selectodd(), selecteven())

it doesn't do anything at all, except wasting CPU cycles.
TheSkiller is offline   Reply With Quote
Old 6th September 2013, 21:57   #7  |  Link
ajk
Registered User
 
Join Date: Jan 2006
Location: Finland
Posts: 134
Yeah, I've just now actually ran the script on a clip, shouldn't answer threads when at work... Of course bob() leaves the clip in the frame based state already and the interleaving is performed by the selectevery(). Updated the script again.
ajk is offline   Reply With Quote
Old 9th September 2013, 13:40   #8  |  Link
edheaded
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks for the advice.

So, here's my final script:

Code:
FFVideoSource("myVideo.mxf)
Load_Stdcall_Plugin("C:\..\yadif.dll")

AssumeTFF()
Yadif(mode=1)
BicubicResize(720,576)

Blur(0, 0.6, false).Sharpen(0, 0.4, false)
ConvertToYV12()

separatefields()
selectevery(4, 0, 3)
weave()
I can't see any interlacing/combing apart from the end credits scroll, but thought it's safest to presume interlaced.

I also need to convert to YV12 for the encoder. I've put this before it's re-interlaced. Is this correct?
edheaded is offline   Reply With Quote
Old 9th September 2013, 19:51   #9  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
Yes, the script is fine, ConvertToYV12() can be put before the re-interlacing lines.

Before you start encoding, to make sure the field order is correct (believe me, you really should test this), you may add Bob() at the end of the script, open the script in VirtualDub and play back the part with the interlaced credits. If the motion is fluid you can remove Bob() and encode with Top Field First setting.
TheSkiller is offline   Reply With Quote
Old 11th September 2013, 12:00   #10  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
Simple BicubicResize is unnecessarily soft in the horizontal domain. You want to try to maintain as much horizontal sharpness as possible. lanczosX, splineX, etc. Or something even more clever (though that would slow things down).

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 12th September 2013, 12:32   #11  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,731
Didée came up with a brilliant idea for using BicubicResize when downsizing. Play with the b and c parameters, like BicubicResize(720,576,-0.6,0.3). When I resize 1080p stuff to 720p, I usually end up with having c between 0.2 and 0.35, b is 2*c and negative.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 12th September 2013, 21:56   #12  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
I remember that, here it is.
TheSkiller is offline   Reply With Quote
Old 16th September 2013, 04:47   #13  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
with reference to http://forum.doom9.org/showthread.ph...25#post1177125, & provided that the MXF files contain true interlaced footage:

Code:
Global NewWidth  = 704
Global NewHeight = 576

xxxSource(.....)

# Pick the right one manually:
AssumeTFF()
#AssumeBFF()

SeparateFields()

Shift = (GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)

E    = SelectEven() . Spline36Resize(NewWidth, NewHeight/2, 0,    Shift)
O    = SelectOdd()  . Spline36Resize(NewWidth, NewHeight/2, 0,   -Shift)
Echr = SelectEven() . Spline36Resize(NewWidth, NewHeight/2, 0,  2*Shift)
Ochr = SelectOdd()  . Spline36Resize(NewWidth, NewHeight/2, 0, -2*shift)

Interleave(E, O)
IsYV12() ? MergeChroma(Interleave(Echr, Ochr)) : Last
Weave()
Pick the resizer as you prefer .... you may even try a sharper resizer for luma (E & O) and a softer resizer for chroma (Echr & Ochr).
henryho_hk is offline   Reply With Quote
Old 19th September 2013, 16:23   #14  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
The separated fields resizing trick above DOUBLES the height of any resizer artefacts/effects/etc compared with the bob/resize/re-interlace approach. You may find that to be a good or bad thing, but it certainly changes the decision of which resizer and parameters to use.

I think it limits the final vertical resolution to half that for a full frame. With interlaced content, if you maintained full vertical resolution it would twitter/shimmer like mad, but going down to half is a little brutal IMO.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 19th September 2013, 20:13   #15  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
I agree with 2Bdecided. The field based approach seems impractical considering a plain ultra fast Bob() provides better results...

I'm not sure if a field based resize results in vertical resolution cut in half, but it sure gives a very soft vertical.
If it does reduce the vertical resolution to half or less it would make that whole interlacing affair redundant – you might as well store the video as 288p/240p then.

Yeah you can't put that on DVD but the point is one really needs to find that sweet spot of vertical resolution that looks good: detailed, but not so much that it results in pronounced line twitter and aliasing (hence my Blur-Sharpen recommendations in post #4).

Last edited by TheSkiller; 19th September 2013 at 20:16.
TheSkiller is offline   Reply With Quote
Old 30th September 2013, 16:45   #16  |  Link
edheaded
Registered User
 
Join Date: Jun 2012
Posts: 5
Thanks for the suggestions.

So, I've tried out the original suggestions by TheSkiller and the updated chroma/luma script by henryho_hk but we're always seeing some bad horizontal line shimmer/wobble on both interlaced broadcast monitors and progressive LCD TVs (despite increasing the amount of blur).

To be honest, although I'm a bit paranoid about what it's doing with the fields, this script seems to give the best quality (can't see any difference in movement either) on both displays:

Quote:
#1080i 25fps ProRes source
Spline16Resize(720,576)
Blur(0.1, 0.6, false).Sharpen(0, 0.3, false)
ConvertToYV12
It is being flagged as an interlaced source on the encoder (Totalcode/Cinevision) before encoding, but I'm concerned it's effectively being deinterlaced by the script and re-interlaced by the encoder.

Any ideas?
edheaded is offline   Reply With Quote
Old 30th September 2013, 17:27   #17  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
What about .... :

FFVideoSource("myVideo.mxf)
Load_Stdcall_Plugin("yadif.dll")
AssumeTFF().Bob()
BilinearResize(720,576)
separatefields().selectevery(4,0,3).weave()
ConvertToYV12(interlaced=true)
henryho_hk is offline   Reply With Quote
Old 30th September 2013, 19:17   #18  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
If it is progressive then something like this should give you some speed boost, (if it is interlaced its probably not worth bothering with anyway);

SeparateFields().SelectEven().BilinearResize(720,576)

(If there are short burst of interlaced stuff, this will take care of that as well, since we are only taking "one field")
__________________
certain other member

Last edited by smok3; 30th September 2013 at 19:20.
smok3 is offline   Reply With Quote
Old 30th September 2013, 19:26   #19  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
If it is progressive then something like this should give you some speed boost, (if it is interlaced its probably not worth bothering with anyway);
SeparateFields().SelectEven().BilinearResize(720,576)
__________________
certain other member
smok3 is offline   Reply With Quote
Old 30th September 2013, 19:41   #20  |  Link
TheSkiller
Registered User
 
Join Date: Dec 2007
Location: Germany
Posts: 632
Quote:
Originally Posted by edheaded View Post
So, I've tried out the original suggestions by TheSkiller and the updated chroma/luma script by henryho_hk but we're always seeing some bad horizontal line shimmer/wobble on both interlaced broadcast monitors and progressive LCD TVs (despite increasing the amount of blur).
Not entirely sure but it sure sounds like you have put the Blur().Sharpen() combo after the re-interlacing lines, which is wrong and will produce rubbish (whenever there is interlaced content).
Sorry, I should have explained where to put it.


Quote:
Originally Posted by edheaded View Post
To be honest, although I'm a bit paranoid about what it's doing with the fields, this script seems to give the best quality (can't see any difference in movement either) on both displays:
Code:
#1080i 25fps ProRes source
Spline16Resize(720,576)
Blur(0.1, 0.6, false).Sharpen(0, 0.3, false)
ConvertToYV12
This is where to put it. However the lack of a Bob deinterlacer and re-interlacing means: this script does mess up the interlacing (while the non-interlaced parts will be absolutely fine). The fields will be blended together, which may not be too obvious until you come across fast scrolling credits for example. It's pretty much like a blend-deinterlacer.

henryho_hk's suggestion is almost what you want:
Code:
#1080i 25fps ProRes source
Bob()
Spline16Resize(720,576)
Blur(0, 0.6, false).Sharpen(0, 0.3, false)
ConvertToYV12()

AssumeTFF() #for Top Field First OR:
#AssumeBFF() #for Bottom Field First output

SeparateFields().SelectEvery(4,0,3).Weave()

Quote:
Originally Posted by smok3 View Post
SeparateFields().SelectEven().BilinearResize(720,576)
Problem is, like you've mentioned, this totally throws away one field. In case of fast scrolling interlaced credits for example, this will make them appear like a strobe and it'll be hard and annoying to read. Since we're going to make an interlace-enabled DVD anyway, this is not recommended imo.

Last edited by TheSkiller; 30th September 2013 at 19:52.
TheSkiller 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 09:13.


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