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 February 2019, 08:58   #1  |  Link
Metal-HTPC
Registered User
 
Join Date: Dec 2018
Posts: 38
NTSC DVD (29.97 + 23.976fps w/ 3:2 pd) to 25fps x264

hello,
since this looks like the ultimate forum when it comes to Avisynth scripts I'm wondering what you guys would suggest me for the following project:

I want to encode a MPEG2 NTSC DVD with short episodes (each episode has an intro) to MPEG4 (x264) with 25fps.
The intro of each episode is in 29.97 and when the episode starts it switches to telecined film (23.976 with 3:2 pulldown)

So what should I do ? To convert without visible quality loss or stuttering and without the Audio (always runs in 23.976) running out of synch?

Using a motion interpolating frame rate changer to convert the intro to 23.976, then IVTC the rest with TFM().TDecimate(). ?

MPEG2Source("E:\video.d2v")
p1 = Trim(0,2459).SmoothFPS2(24000,1001)
p2 = Trim(2460,0).TFM().TDecimate()
p1+p2
AssumeFPS(25.000)
LanczosResize(720,576)

Maybe you guys have a better idea. Thanks in advance for your help.
Metal-HTPC is offline   Reply With Quote
Old 26th February 2019, 19:19   #2  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,510
My first thought was why would you want to change to PAL 25 fps? Leave it at 29.97 and encode everything as interlaced with x264, without resizing. Every player will play it.

If you absolutely need to convert:
You should definitely IVTC the (hard) telecined section and speed it up to 25fps, as you suggest, and recover the progressive original frames.
For the intro part (is it true interlaced?) you can choose your poison: Interpolation artefacts, blending, or decimate and accept some jerkyness. Don't know what looks best to you, it also depends on the source.
Perhaps someone else has a better proposal.
Sharc is offline   Reply With Quote
Old 26th February 2019, 19:42   #3  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,200
Quote:
Originally Posted by Sharc View Post
My first thought was why would you want to change to PAL 25 fps? Leave it at 29.97 and encode everything as interlaced with x264, without resizing. Every player will play it.
That would be my recommendation as well. How often will you play this, over the next ten years? Is it really worth all the effort?

Last edited by johnmeyer; 26th February 2019 at 19:42. Reason: typo
johnmeyer is offline   Reply With Quote
Old 27th February 2019, 08:15   #4  |  Link
Metal-HTPC
Registered User
 
Join Date: Dec 2018
Posts: 38
I wouldn't do it if it isn't worth it. It's one of my favorite shows so I'm definitely going to watch it every 2-3 years. I'm not shure if the intro is true interlaced. I can check that later or post a sample if I'm not shure.

The reason why I need to convert it to PAL is that I need to adjust another audio Layer to the video which runs in PAL speed and has a pal tone pitch. There is no way for me to convert the audio without losing audible quality.
If you convert it to 23,970 directly it will sound too deep and if you convert to 23,970 with a pitch correction it will sound tinny.
Metal-HTPC is offline   Reply With Quote
Old 27th February 2019, 09:16   #5  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,200
With the proper software you should be able to do a relatively minor audio speed change, with pitch correction, and not be able to notice any artifacts whatsoever. The key is proper software. I use iZotope, which is quite expensive, but I think Audacity can also do pretty good changes. I also use my Vegas editing software with the "elastique" enabled, and cannot detect even a hint of flanging, which is what I think you are referring to when you say "tinny."

I much prefer changing audio duration, and leaving the video alone, whenever possible because, unlike what I just described for audio, it is impossible to change video speed without introducing artifacts that, at times, will be quite noticeable.
johnmeyer is offline   Reply With Quote
Old 27th February 2019, 14:54   #6  |  Link
Metal-HTPC
Registered User
 
Join Date: Dec 2018
Posts: 38
I never noticed any artifacts on any of the commerical released PAL DVD's I know. I also own many movies as a PAL and a NTSC version and compared them. They look identical to me. With x264 I can use a much higher bitrate because I'm not limited to the DVD spec of 9000 so there shouldn't be any pixelation if the above script works good.
Back in the past I converted all my NTSC DVD's to PAL with HCencoder with the same commands "tdecimate()" or "Telecide(guide=1,blend=true) and Decimate(cycle=5,quality=3)". which are only deleting one frame in five to convert 29.97 fps to 23.976 fps and doesn't do any pulldown removals. Although some videos had stuttering in faster scenes I never noticed any pixelations or visible artifacts.

For me it's much easier to convert the video. For commerical blu-rays even more. I just change the framerate in ts muxer to 25 which is a very easy and fast speedup. I don't need to touch the audio at all and can finish my project pretty fast. I also only do this if the sound has a pal speedup tone which is only used for TV shows and a a few direct to video releases. All other versions can be easily converted with eac3to with the "25.000 -changeTo23.970" command and the video stays untouched.
Metal-HTPC is offline   Reply With Quote
Old 27th February 2019, 19:57   #7  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,510
The problem with artifacts is neither PAL as such nor the x264 encoding bitrate. Nobody said this. Artifacts are introduced when you frame-rate convert the (interlaced?) introduction (your p1) from 29.97 to 25 with a "motion interpolating frame rate changer" as per your original post. Framerate changers will always introduce artifacts of some kind. Depending on the video (motion) and the interpolating algorithm they might be quite acceptable though and may not be noticed at normal playback speed on TV for example. Stuttering (as you observed) due to skipping or doubling frames is just one kind of "artifact". Some people can't stand it, other people hate blends etc. As I said when you do framerate conversion you can choose your poison.
The telecined part is not the problem. You can IVTC it to 23.976 and get perfect progressive pictures without introducing any artifacts, speed it up to 25 and add your extra (25fps) audio track, as you intend.
Sharc is offline   Reply With Quote
Old 27th February 2019, 21:03   #8  |  Link
SeeMoreDigital
Life looks better in UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 11,457
Quote:
Originally Posted by Metal-HTPC View Post
...It's one of my favorite shows so I'm definitely going to watch it every 2-3 years.
What show?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 27th February 2019, 23:24   #9  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,003
Maybe increasing the frame rate of the intro would look better than trying to reduce it.... the idea being to increase the frame rate to 47.952fps, so the PAL speed-up takes it to 50fps. Then you could repeat every frame in the second section to make the whole thing 50fps. And myself.... I tend to resize to square pixel dimensions anyway, but if you have to resize, why not go straight to square pixels?

MPEG2Source("E:\video.d2v")
Trim(0,2459).FrameRateConverter(48000,1001).AssumeFPS(50)\
++Trim(2460,0).TFM().TDecimate().AssumeFPS(25).ChangeFPS(50)
LanczosResize(640,480) # or 720x540 or some other 4:3 dimensions

Or it wouldn't be hard to encode as variable frame rate, given there's only two different frame rates. 50fps for the intro and 25fps for the rest. The two sections must have a single frame rate in the script though, to keep Avisynth happy.

MPEG2Source("E:\video.d2v")
Trim(0,2459).FrameRateConverter(48000,1001).AssumeFPS(25).GreyScale()\
++Trim(2460,0).TFM().TDecimate().AssumeFPS(25)
LanczosResize(640,480)

I'd add GreyScale() to the first section as you'll need to check the new frame numbers after converting the frame rate, unless you're good at maths, and GreyScale() makes it easy to see where the first section ends (assuming it doesn't fade to black). Obviously you'd remove it for encoding, but a timecodes file for the above example would look like this. Frames 0-2459 become frames 0-3935 after the frame rate conversion.

# timecodes format v1
Assume 25.000000
0,3935,50.000000

The timecodes would be added to the x264 command line this way:

--tcfile-in "D:\timecodes.txt"

I guess you could also apply a speedup to the 29.97fps section directly using a timecodes file. It'd avoid the frame rate conversion, but the resulting frame rate wouldn't be standard, if you care about that sort of thing. It might be the least offensive way to do it though. Frames 0-2459 are increased to 31.25fps via the timecodes.

MPEG2Source("E:\video.d2v")
Trim(0,2459).AssumeFPS(25)\
++Trim(2460,0).TFM().TDecimate().AssumeFPS(25)
LanczosResize(640,480)

# timecodes format v1
Assume 25.000000
0,2459,31.250000

I think that's correct, although my preference would be to change the audio speed instead.

Last edited by hello_hello; 28th February 2019 at 00:20.
hello_hello is offline   Reply With Quote
Old 28th February 2019, 08:00   #10  |  Link
Metal-HTPC
Registered User
 
Join Date: Dec 2018
Posts: 38
thanks so far guys I will try a bit get back to you with additional information on sunday.

@hellohello. Your guide looks pretty interesting tho my project has to be compatible to a BD-R specifictation since I already have pretty awesome cover boxes for this show and plan on making several bd-r's out of it which have to be compatible for stand alone bd player playback.
Metal-HTPC is offline   Reply With Quote
Old 28th February 2019, 15:05   #11  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,003
That's a pity... Does your Bluray player play MKVs? I assume they pretty much all do these days. If so, you could still use discs but burn the MKVs as data files instead of having to worry about all the Bluray compatibility stuff.

Other than that, maybe converting the 29.97fps section to interlaced PAL might be the next best bet. I think this is the standard method, only instead of converting to 50fps before removing fields for 25i, you'd convert to 47.952fps and apply PAL speedup. Chances are it'll look better though if you interpolate new frames rather than blend them.
ie FrameRateConverter(48000,1001) instead of ConvertFPS(48000,1001) etc.
Obviously you'll have to encode as interlaced, but assuming the source intro section is progressive...

Trim(0,2459)\
.LanczosResize(720,576)\
.ConvertFPS(48000,1001)\
.AssumeFPS(50)\
.SeparateFields()\
.SelectEvery(4,0,3)\
.Weave()\
\
++Trim(2460,0)\
.TFM().TDecimate()\
.LanczosResize(720,576)\
.AssumeFPS(25)

Or.... you could deinterlace the first section for 25p. I could be wrong, but I suspect it'll look better than going from 29.97fps to 23.976fps and applying speedup, especially if you de-interlace with QTGMC().
I'd also try running QTGMC() in progressive mode over the second section too, assuming it could do with some cleaning up and/or noise removal. I use it for that sort of thing regularly.

Trim(0,2459)\
.LanczosResize(720,576)\
.FrameRateConverter(48000,1001)\
.AssumeFPS(50)\
.SeparateFields()\
.SelectEvery(4,0,3)\
.Weave()\
.QTGMC(FPSDivisor=2)\
\
++Trim(2460,0)\
.TFM().TDecimate()\
.LanczosResize(720,576)\
.QTGMC(InputType=1, EzDenoise=1)\
.AssumeFPS(25)

Last edited by hello_hello; 28th February 2019 at 15:44.
hello_hello is offline   Reply With Quote
Old 28th February 2019, 15:51   #12  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,510
The OP should upload a sample of the critical intro part (and preferably also of the telecined 2nd part). Otherwise all advice is speculative and based on possibly wrong assumptions.

Last edited by Sharc; 28th February 2019 at 15:57.
Sharc is offline   Reply With Quote
Old 1st March 2019, 07:48   #13  |  Link
Metal-HTPC
Registered User
 
Join Date: Dec 2018
Posts: 38
your suggestion sounds pretty interesting, hello_hello.
Now I have so many suggestions that I also think that it will probably the best to upload a sample here. I will do that later on.
Metal-HTPC is offline   Reply With Quote
Old 1st March 2019, 15:17   #14  |  Link
Metal-HTPC
Registered User
 
Join Date: Dec 2018
Posts: 38
ok here is the sample: https://www.file-upload.net/download...ample.m2v.html
Metal-HTPC is offline   Reply With Quote
Old 1st March 2019, 17:07   #15  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,510
The hoster permanently tries to install some executable crap.
Change the file hoster. I won't download anything from this site.
Sharc is offline   Reply With Quote
Old 1st March 2019, 17:26   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,268
MediaFire is often used on Doom9, you need an account.
SendSpace, I think that you dont need account (but easier with), but uploads deleted 30 days after last download.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 1st March 2019, 20:13   #17  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,003
Here's some more. You can upload without an account. I've used all three in the past and I'm pretty sure they're okay.

http://ge.tt/
https://www.filedropper.com/
https://uploadfiles.io/
hello_hello is offline   Reply With Quote
Old 2nd March 2019, 01:20   #18  |  Link
Metal-HTPC
Registered User
 
Join Date: Dec 2018
Posts: 38
hey guys,
sorry didn't know that service turned into crap. I just put it on wetransfer. We use that one at work it's very safe.

https://we.tl/t-YbUNuA5p4m
Metal-HTPC is offline   Reply With Quote
Old 2nd March 2019, 06:30   #19  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,003
I gave my previous suggestion a try and it seems okay.

In case you're wondering, the cropping/resizing in the included script was done with a script (although a newer version with support for anamorphic resizing I haven't quite finished yet), but I cropped the crud because I have to.... it's probably some sort of OCD thing (Obsessive Crud Disorder )

I only encoded about 2/3 of the sample as my upload speed tends to be more of an upload slow, and there's wasn't a great deal of 29.97fps video anyway. The pulldown starts right after the "Tales From The Crypt" logo, about 35 seconds from the beginning.

Sample.zip
hello_hello is offline   Reply With Quote
Old 2nd March 2019, 11:09   #20  |  Link
Metal-HTPC
Registered User
 
Join Date: Dec 2018
Posts: 38
dear hello_hello,
the sample you encoded looks pretty amazing. I will try the script tomorrow. Regarding cropping it's totally okay to get rid of black bars ;-). I will download your CropResize script and use that.
By the way I noticed something weird. For Season 1-2 the audio I need to adjust to the video runs in NTSC speed, so I only need to convert season 3-7 to 25fps and can encode the seasons 1-2 in 23976.
Would you use your script for a x264 NTSC encode as well and would the main commands look like this instead

Trim(0,2459)\
.FrameRateConverter(30000,1001)\ or .FrameRateConverter(24000,1001)\ ?
.AssumeFPS(23.976)\
.SeparateFields()\
.SelectEvery(4,0,3)\
.Weave()\
.QTGMC(FPSDivisor=2)\
\
++Trim(2460,0)\
.TFM().TDecimate()\
.QTGMC(InputType=1, EzDenoise=1)\
.AssumeFPS(23.976)

or wouldn't you use that and make a direct encode with only .AssumeFPS(23.976) and the cropping command in the avisynth script?

Also as far as I understood your cropping script, it works automatically so I could just change the command to .CropResize(720,480,12,0,-10,-4,InDAR=15.0/11.0,OutDAR=15.0/11.0)\ right?
Metal-HTPC 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:52.


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