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 8th September 2017, 04:14   #1  |  Link
ogrgkyle
Registered User
 
Join Date: Aug 2015
Posts: 17
TFM IVTC not working on .MPG

Here's my script. The .mpg was copied from a DVD.

video = FFmpegSource2("F:\mymovie.mpg")
TFM(video, order = 1)
TDecimate(video)
video = BicubicResize(video, 640, 480)
return video

This outputs the video, but it is still telecined and it is still 30i. Why won't it work to detelecine? Thanks.
ogrgkyle is offline   Reply With Quote
Old 8th September 2017, 05:53   #2  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
Why not write your scripts like normal people?

FFmpegSource2("F:\mymovie.mpg")
TFM(order = 1)
TDecimate()
BicubicResize(640, 480)


You should also create a D2V project file using DGIndex and then use MPEG2Source on it, together with the DGDecode.dll. It'll save you creating that MPG before working on your video.
manono is offline   Reply With Quote
Old 8th September 2017, 16:42   #3  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,869
Quote:
Originally Posted by ogrgkyle View Post
Here's my script. The .mpg was copied from a DVD.

video = FFmpegSource2("F:\mymovie.mpg")
TFM(video, order = 1)
TDecimate(video)
video = BicubicResize(video, 640, 480)
return video

This outputs the video, but it is still telecined and it is still 30i. Why won't it work to detelecine? Thanks.
Consider using Spline64Resize over BicubicResize, I generally prefer it 'cause it's sharp and has less ringing than Bicubic. (Just a suggestion).

Anyway, I would use something like this to IVTC and Resize:

Code:
#Index 
#(I noticed you are using FFMpegSource2 and not FFVideoSource, so I assume you wanna index the audio track as well. To do so, add atrack=-1)

FFmpegSource2("F:\mymovie.mpg", atrack=-1)

#inverse telecine to 23.976
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate()

#Resize
Spline64Resize(640, 480)
Last but not least, if you wanna use multi-threading Resizers, consider using this: Link and call them like the normal resizers, but adding "MT" at the end, like: BicubicResizeMT(640, 480) or Spline64Resize(640, 480) etc.
FranceBB is offline   Reply With Quote
Old 8th September 2017, 17:22   #4  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,340
Quote:
Originally Posted by FranceBB View Post
Consider using Spline64Resize over BicubicResize, I generally prefer it 'cause it's sharp and has less ringing than Bicubic. (Just a suggestion).
Actually, Spline64Resize has more ringing because it's sharper
poisondeathray is offline   Reply With Quote
Old 8th September 2017, 18:14   #5  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,821
Quote:
Originally Posted by ogrgkyle View Post
Here's my script. The .mpg was copied from a DVD.

video = FFmpegSource2("F:\mymovie.mpg")
TFM(video, order = 1)
TDecimate(video)
video = BicubicResize(video, 640, 480)
return video

This outputs the video, but it is still telecined and it is still 30i. Why won't it work to detelecine? Thanks.
It's because the first and second last lines update the definition of "Video" and the last line tells AVisynth to return the latest definition of Video.

This would work:

video = FFmpegSource2("F:\mymovie.mpg")
video = TFM(video, order = 1)
video = TDecimate(video)
video = BicubicResize(video, 640, 480)
return video

But when a filter expects a clip as the first argument it's automatically taken from the "last" variable. "Video=" also becomes obsolete and the way manono suggested to do it is all that's required.

FFmpegSource2("F:\mymovie.mpg")
TFM(order = 1)
TDecimate()
BicubicResize(640, 480)

The special variable "last" passes the output of one filter to the input of the next and while you could add
return last
to the end of a script it's not necessary as it's automatically assumed.
http://avisynth.nl/index.php/Runtime..._and_functions

If you must use FFmpegSource2 it's generally a good idea for DVD sources to include rffmode=1 like so:
FFmpegSource2("F:\mymovie.mpg", rffmode=1)
So ffms2 will obey any repeat field flags. Without it, it ignores them and the output can be unexpected.

As manono said though, for mpeg/DVD sources, DGIndex/MPEG2Source is a better option.

PS If the source is a 4:3 DVD and you're not cropping, resizing to 656x480 would usually be a better choice. For 4:3 DVDs, only 704 of the width contributes to an exact 4:3 resolution. If you want exactly 4:3, you probably should do this:

Crop(8, 0, -8, 0)
BicubicResize(640, 480)

Last edited by hello_hello; 9th September 2017 at 02:23.
hello_hello is offline   Reply With Quote
Old 8th September 2017, 19:31   #6  |  Link
ogrgkyle
Registered User
 
Join Date: Aug 2015
Posts: 17
Manono - Thanks, that worked. I'm somewhat new to Avisynth.

FranceBB, poisondeathray - My rule of thumb in ffmpeg has been to use bicubic when scaling down and lanczos when scaling up. I'll have to see what scaling options are available in Avisynth. I will look at the multi-threaded scaling as well.

hello_hello - Ah, thanks for clarifying how my script wasn't working. So why is DGIndex/MPEG2Source a better option? Also, these are from DVDs recorded from TV, in case that makes a difference. For instance, I see less than 16 pixels of the width of this particular MPEG can be cropped, but that may be because I'm cropping after scaling. What I'm doing is converting to square pixels then cropping like so: Crop(6, 4, 628, 474, align=False). I was wondering though, given that the original width is 720, is it the best strategy to scale to 640? What if instead I scaled the height to 540?


My current script:

FFmpegSource2("F:\Movie files\Movies\Bundle Of Joy (1956).mpg", atrack=-1, rffmode=1)
TFM(order = 1, mode = 5, PP = 7, slow = 2, micmatching = 2)
TDecimate()
BicubicResizeMT(640, 480)
Crop(6, 4, 628, 474, align=False)
ogrgkyle is offline   Reply With Quote
Old 9th September 2017, 02:09   #7  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,821
Quote:
Originally Posted by ogrgkyle View Post
hello_hello - Ah, thanks for clarifying how my script wasn't working. So why is DGIndex/MPEG2Source a better option?
It's been around a long time and as close to 100% reliable as you can get for mpeg1/2, plus by default it obeys pulldown flags, whereas ffms2 ignores them, and that can lead to frame rate and audio sync problems unless you know to use rffmode=1.

Quote:
Originally Posted by ogrgkyle View Post
For instance, I see less than 16 pixels of the width of this particular MPEG can be cropped, but that may be because I'm cropping after scaling. What I'm doing is converting to square pixels then cropping like so: Crop(6, 4, 628, 474, align=False). I was wondering though, given that the original width is 720, is it the best strategy to scale to 640? What if instead I scaled the height to 540?
There's no guarantee there'll be exactly 8 pixels of black each side, sometimes it's a lot more, and sometimes there's almost none.

In theory at least, the best quality method is to crop and not resize at all, but set the correct pixel aspect ratio when encoding and let the player resize it on playback as it would for the original mpeg2/DVD video.
Next best would be to crop and only resize the width for the correct aspect ratio, while third best is resizing the height and/or width.
NTSC 4:3 DVDs are the only type of DVD that require reducing the width when resizing to square pixel dimensions, so that could be an argument for increasing the height instead, but I doubt it'd make a difference to picture detail. I usually go with 624x468 for 4:3 NTSC as it's exactly 4:3 and if you're also cropping a few pixels top and bottom, which I invariably do, after cropping you're not reducing the height by much. It's personal preference though....

I use the third best method nearly all the time because IMHO the the quality difference is largely theoretical, because I like to resize a bunch of related videos to the same resolution after cropping, because I'm OCD about cropping to exactly 4:3 or 16:9 if the source is close to those aspect ratios, and because the media player in my TV doesn't support anamorphic MKVs/MP4s (video with non-square pixels) and displays them incorrectly, so I always resize to square pixel dimension when encoding.

If you're just cropping the black and don't care about the final aspect ratio it doesn't matter which order you do it in, but if you want to control the output dimensions it's easier to do it the other way around because you can crop to a specific aspect ratio such as 4:3, and then resize to whatever 4:3 dimensions you prefer.

The resize filters also crop as the Crop() filter does, although for cropping the black it's probably better to use the cropping filter before resizing (see the info just above "Examples" here) however the resize filters aren't restricted to mod 2 cropping.
As an example, this would crop 10 pixels from the left, 9 from the right, and 2 from the bottom, and for a 4:3 NTSC DVD that'd give you an aspect ratio of 1.3332 so you could resize to any 4:3 dimensions with virtually zero aspect error.

Crop(10, 0, -8, -2) # or Crop(10, 0, 702, 478)
BicubicResizeMT(640, 480, 0, 0, -1, 0)

How you do it is personal preference of course, but if you want to try that method have a play with this calculator:
YodaResizeCalculator 0.4.0.1
As a rule of thumb, select "mpeg4" as the PAR Spec for 4:3 DVDs and "Generic" for 16:9 DVDs.

Last edited by hello_hello; 9th September 2017 at 02:25.
hello_hello is offline   Reply With Quote
Old 9th September 2017, 02:29   #8  |  Link
ogrgkyle
Registered User
 
Join Date: Aug 2015
Posts: 17
This spurs a few questions:

I should have mentioned that I want to avoid non-square pixels for simplicity, so I have to resize at least one of the dimensions. How is it better to resize the width only rather than keep the width and resize the height?

How important is it to have standard resolutions like 640x480? For example, my current script outputs 628x474, which is not quite 4:3. I want maximum compatibility with various media players and servers. This is a very large movie library. (BTW, I also like the idea of keeping it simple and resizing everything to the nearest standard ratio; I just want to make sure it's worth doing.)

That's nice that you can crop down to the pixel. Is there a Avisynth filter that auto-crops?

These movies often have a video (30i) introduction. It's usually pretty simple: maybe the first two minutes are video, and the rest is the movie. Now, my current script seems to do a pretty good job of IVTC with TFM, but I still see combing in the video introduction. So how do I properly deinterlace this section, and can I convert this section to 24p like the movie without it looking choppy?
ogrgkyle is offline   Reply With Quote
Old 9th September 2017, 03:53   #9  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,821
Quote:
Originally Posted by ogrgkyle View Post
This spurs a few questions:

I should have mentioned that I want to avoid non-square pixels for simplicity, so I have to resize at least one of the dimensions. How is it better to resize the width only rather than keep the width and resize the height?
For 16:9 NTSC, PAL 4:3 and PAL 16:9, the height needs to be reduced for the correct aspect ratio if you don't resize the width, so there's a potential for some loss of picture detail. That's probably the main reason. NTSC 4:3 is the exception there.
Mind you it's often possible to resize down a bit without any visible loss of detail, especially for interlaced sources (if you de-interlace them). I'm in PAL-land so resizing the "width only" would give you something like 1024x576 for 16:9 and 786x576 for 4:3, but I often use 960x540 and 640x480.
In fact.... if you use a sharp(ish) resizer to resize to square pixels, even if you resize down a little, when the encoded version is upscaled on playback for a 1080p display, it can still end up looking sharper than the original video. Mostly that's a good thing, in my opinion, but it's all personal preference.
Here's some screenshots of anamorphic encoding verses resizing to 1024x576 for encoding, upscaled to 1080p.
https://forum.videohelp.com/threads/...ty#post2444902
https://forum.videohelp.com/threads/...ty#post2445018

Quote:
Originally Posted by ogrgkyle View Post
How important is it to have standard resolutions like 640x480? For example, my current script outputs 628x474, which is not quite 4:3. I want maximum compatibility with various media players and servers. This is a very large movie library. (BTW, I also like the idea of keeping it simple and resizing everything to the nearest standard ratio; I just want to make sure it's worth doing.)
Standard resolutions are not required at all.
Back in the mpeg2 and Xvid (mpeg4) days, mod16 dimensions were often required (width and height evenly divisible by 16), but they could be any mod16 dimensions. That's why AVI resolutions such as 656x272 or 640x256 etc were once quite common. These days even that's not an issue, at least for h264, but if you want to be 100% safe, you could stick to mod4 dimensions. It's not something to stress about though. I've not met a h264 hardware player that cares.

Quote:
Originally Posted by ogrgkyle View Post
That's nice that you can crop down to the pixel. Is there a Avisynth filter that auto-crops?
Yes. It's included with the zip file for this cropping and resizing script (the plugin isn't my creation, just the script).
CropResizeBorder
Or Google "AutoCrop.dll Avisynth".
That script was created to automatically do the type of cropping and resizing I referred to. You only need to specify the desired output resolution and it'll do the rest.
It uses AutoCrop.dll to do all the cropping, which means it's limited to mod2 cropping, although that's enough for pretty accurate resizing. I did start working on a new version that only uses AutoCrop.dll to crop the black and any additional cropping would be done by the resize filter, giving it sub-pixel resizing accuracy, but I got distracted and never went back to it. I will at some stage.

Quote:
Originally Posted by ogrgkyle View Post
These movies often have a video (30i) introduction. It's usually pretty simple: maybe the first two minutes are video, and the rest is the movie. Now, my current script seems to do a pretty good job of IVTC with TFM, but I still see combing in the video introduction. So how do I properly deinterlace this section, and can I convert this section to 24p like the movie without it looking choppy?
TDecimate has hybrid modes.
hybrid=1 outputs 23.976fps. Any 29.970fps sections in the source are converted to 23.976fps by removing/blending frames.
Hybrid=3 outputs 29.970fps. Any "film" sections are converted to 29.970fps using frame blending.

The default is hybrid=0 which just assumes everything is "film" but what should happen is TFM would de-interlace the 30i sections and TDecimate will drop frames for 23.976fps, so while that might effect how smooth motion looks it shouldn't leave combing.
Try TFM(cthresh=-1) to tell TFM everything is combed. If that fixes the problem try increasing it till it doesn't (the default cthresh is 9), otherwise I'd suggest you upload a small sample for someone to look at.

Last edited by hello_hello; 9th September 2017 at 03:57.
hello_hello is offline   Reply With Quote
Old 12th September 2017, 19:49   #10  |  Link
ogrgkyle
Registered User
 
Join Date: Aug 2015
Posts: 17
That's a lot of info. Thanks.

Here's some five-minute video clips that represent most of my movie collection. If you want, feel free to play with Avisynth/FFmpeg settings, including IVTC, scaling, and sharpening.

Fullscreen 256kbps NTSC MPEG

Fullscreen 256kbps NTSC MPEG (poorer film quality)

Widescreen 256kbps NTSC MPEG

Fullscreen black and white 256kbps NTSC MPEG

Widescreen black and white 256kbps NTSC MPEG

Last edited by ogrgkyle; 12th September 2017 at 20:38. Reason: Specifying the clips are NTSC.
ogrgkyle is offline   Reply With Quote
Old 12th September 2017, 20:03   #11  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,685
I use 656x480 for NTSC 4:3 material. If you start with non-square pixels and 720x480, 720 * 0.9091 = 654.55. It is good to use numbers divisible by four, so I round up to 656.
johnmeyer is offline   Reply With Quote
Old 12th September 2017, 20:43   #12  |  Link
ogrgkyle
Registered User
 
Join Date: Aug 2015
Posts: 17
Isn't 640x480 correct for 4:3? For instance, if I use ffmpeg to scale 720x480 NTSC DVD/MPEG recording like scale=iw*sar:ih, I get 640x480.
ogrgkyle is offline   Reply With Quote
Old 12th September 2017, 22:43   #13  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,821
Quote:
Originally Posted by ogrgkyle View Post
Isn't 640x480 correct for 4:3? For instance, if I use ffmpeg to scale 720x480 NTSC DVD/MPEG recording like scale=iw*sar:ih, I get 640x480.
It depends which SAR you use.
I don't use ffmpeg much, but it appears to assume 8:9 for an NTSC 4:3 DVD.

Input #0, mpeg, from 'E:\test\VTS_01_1.VOB':
Duration: 00:00:10.88, start: 0.280633, bitrate: 6168 kb/s
Stream #0:0[0x1bf], 11, 1/90000: Data: dvd_nav_packet
Stream #0:1[0x1e0], 152, 1/90000: Video: mpeg2video (Main), yuv420p(tv, top first), 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0:2[0x80], 157, 1/90000: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:3[0x20], 2, 1/90000: Subtitle: dvd_subtitle
Successfully opened the file.

List Of PARs (SARs)

If you stick to the mpeg4 or ITU specs, 704x480 = 4:3 so you'd crop 8 pixels from each side and use SAR 10/11 for exactly 4:3.

It surprises me ffmpeg uses the generic SARs. Mind you, all software players do (as far as I know), as do players/TVs when connected via HDMI.
For 4:3 DVDs though, in my experience mpeg4 SARs are almost always correct. 16:9 DVDs are different. They tend to use generic SARs although there's no rule either way.

Last edited by hello_hello; 12th September 2017 at 22:45.
hello_hello is offline   Reply With Quote
Old 13th September 2017, 01:12   #14  |  Link
ogrgkyle
Registered User
 
Join Date: Aug 2015
Posts: 17
I will take a look at those SARs. I did not know 640x480 wasn't necessarily the correct scaling! I've always assumed that.

Are you saying using anamorphic pixels is closer to the MP4 container spec? Does this make any practical difference?

Quote:
If you stick to the mpeg4 or ITU specs, 704x480 = 4:3 so you'd crop 8 pixels from each side and use SAR 10/11 for exactly 4:3.
I'm a little confused. Aren't you still ending up with a display resolution of 640x480?

By the way, my "widescreen" DVD/MPEG recordings are not actually technically widescreen ratio, but letterboxed, so these unfortunately have even fewer useful pixels than the "fullscreen" recordings.

Here is my current Avisynth script:

Code:
FFmpegSource2("movie.mpg", atrack=-1, rffmode=1)
TFM(order = 1, mode = 5, PP = 7, slow = 2, cthresh = 0, micmatching = 2)
TDecimate(hybrid = 1)
BicubicResizeMT(640, 480)
Crop(6, 4, 628, 474, align=False)
And my current FFmpeg command:
Code:
avs2pipemod -y4mp movie.avs | ffmpeg -y -i - -c:v libx264 -preset slower -tune film -crf 16 -pix_fmt yuv420p -g 48 -an -movflags +faststart "movie.mp4"
Any suggestions to get the best picture quality when encoding to x264? Thanks.
ogrgkyle is offline   Reply With Quote
Old 14th September 2017, 19:52   #15  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,821
Quote:
Originally Posted by ogrgkyle View Post
I will take a look at those SARs. I did not know 640x480 wasn't necessarily the correct scaling! I've always assumed that.

Are you saying using anamorphic pixels is closer to the MP4 container spec? Does this make any practical difference?
The mpeg4 PARs are the official PARs for standard definition Bluray. You can use whatever PARs you like, the mpeg4 PARs in the list are just the official anamorphic, standard definition PARs.

The whole thing's a bit of a mess and I only partly understand the history, but the original ITU spec was based on sampling analogue video and if you follow the spec it works out to roughly 704x480 or 702x576 for 4:3 (which was usually rounded to 704x576).
The mpeg4 PARs are the digital equivalent and result in almost exactly the same display aspect ratios as the ITU PARs but the numbers are simpler.

Contrary to all that though, the HDMI spec seems to say 4:3 and 16:9 are exactly 4:3 and 16:9, and most digital devices resize to exactly 4:3 or 16:9.
For reasons I don't understand (based on experience) pretty much all 4:3 DVDs follow the ITU/mpeg4 spec while the majority of 16:9 DVDs seem to use the generic PARs. What broadcasters may or may not do I have no idea.

Quote:
Originally Posted by ogrgkyle View Post
I'm a little confused. Aren't you still ending up with a display resolution of 640x480?
Yes but the MPEG4 PARs are based on (roughly) 704x480 being 4:3 and for the generic PARs 720x480 is 4:3. Therefore if you assume an mpeg4 PAR and resize the whole 720 width without cropping, you end up with something a little wider than 4:3. 656x480 would be an appropriate resizing if you don't crop.

Quote:
Originally Posted by ogrgkyle View Post
By the way, my "widescreen" DVD/MPEG recordings are not actually technically widescreen ratio, but letterboxed, so these unfortunately have even fewer useful pixels than the "fullscreen" recordings.
Not only that, but the one I looked at isn't 720x480, it's 352x480. The DVD spec doesn't support widescreen 352x480.
By the time it's cropped, you're down to 352x252 worth of picture.
I assume 352x480 should be exactly 4:3, so the pixels would be twice as wide as mpeg4 for 20/11, although I tried three encoding programs and StaxRip assumed 20/11 while Handbrake and MeGUI apparently assume 16/9 (8/9 x 2) which seems a bit unlikely to me.

Quote:
Originally Posted by ogrgkyle View Post
Any suggestions to get the best picture quality when encoding to x264? Thanks.
For your first sample I'd do something like this for cropping and resizing:

tfm().tdecimate()
crop(8, 2, -14, -2)
Spline36Resize(640,480)

but the picture quality is only just a tad shy of disastrous and while there's no doubt ways to improve it, it's not something I do often, so I'll wait to see if someone clever comes along to help there.
hello_hello is offline   Reply With Quote
Old 14th September 2017, 22:24   #16  |  Link
ogrgkyle
Registered User
 
Join Date: Aug 2015
Posts: 17
Only a very small percentage of my DVDs are 352x480. I selected that one by mistake. That being low-res and letterboxed, though, reflects some of the lowest quality video I have.

Most of them are 720x480, 256kbps, and recorded from TV (USA). All are NTSC. I'm guessing that 5%-10% have pretty extreme letterboxing and that 75% are black and white.

My collection is very large, so I need some good default settings in case I can't tailor them to individual DVDs.
ogrgkyle is offline   Reply With Quote
Old 15th September 2017, 05:27   #17  |  Link
LemMotlow
Registered User
 
Join Date: Jul 2011
Location: Tennessee, USA
Posts: 266
Quote:
Originally Posted by ogrgkyle View Post
How important is it to have standard resolutions like 640x480? For example, my current script outputs 628x474, which is not quite 4:3.
To many people I guess it's not really important. You could make it 474x474 square and tell your encoder to play it 4:3. Or make it a skinny 400x100 rectangle and tell your enocder to make it 4:3 on playback. You can make it anything you want. Some people thrive on chaos.

I like to do what the commercial DVD, BluRay, and broadcast industries do, which is to stick to mod-16 or at least mod-8 frame dimensions. I realize that many eccentric users don't like what the commercial industry does and that they feel some compulsion to re-invent the wheel, but since I've never had a problem playing products produced by the commercial video industry I place more trust in following their lead. 640 and 480 are two mod-16 numbers. So are 720, 704, 352, 576, 1280, 1440, and 1080. The only popular format dimension that isn't mod-16 is 1920, which is mod-8. Many Avisynth filters will insist on mod-8 images. If you want to play with mod-2 and mod-4, it's up to you. Two of the reworked video samples linked below are square-pixel and at least mod-8, and the anamorphic is mod-16.

There's an obsession I guess with 4:3 Hollywood movie frames at exact 4:P3 sizes, but Hollywood never shot 4:3 movies except for Tv shows. Hollywood used several aspect ratios since the ancient 1880's, but 4:3 wasn't one of them. Most movies until the early 1950's were shot in the world-wide "Academy" format, or 1.37:1, which is a little wider than 1.333:1. The "4:3" samples you posted are movies that were all shot as 1.37:1. As far as I can tell, TV broadcasters have three ways of handling those 1.37:1 movies. They either crop from one or both edges to make the broadcast image 4:3, or they cleverly have a couple of pixels of top and bottom border that has a 1.37:1 image inside of it, or they just squish a 1.37:1 image into 1.333:1. The edge crop is the one I see most often.

Determine what you're going to do with the two movies that were shot at an aspect ratio of 2.35:1. On a typical 1920x1080 display, if you want full width without playtime resizing, you need a square-pixel frame of 1920x816.

Quote:
Originally Posted by ogrgkyle View Post
That's nice that you can crop down to the pixel.
No, you can't crop down to a single pixel -- at least, not with YV12. There's a 2-pixel minimum, and with interlace or telecine YV12 there's a 4-pixel minimum vertically.

Quote:
Originally Posted by ogrgkyle View Post
my current script seems to do a pretty good job of IVTC with TFM, but I still see combing in the video introduction.
That's because the introduction is almost always pure interlace, not telecine.

Quote:
Originally Posted by ogrgkyle View Post
So how do I properly deinterlace this section, and can I convert this section to 24p like the movie without it looking choppy?
The movies aren't 24p, they're 23.976p after IVTC (yes, the difference matters during processing). And the introductions aren't 30i, they're 29.97i. In their original form as MPG's, both the intro and the movie are both treated as interlaced videos. How do you match up your 29.97i with your 23.976p in the same video? You don't. On an authored DVD or BluRay you mount them as separate tracks. If you did it the normal way, you'd replace the telecine during your re-encode. Welcome to the world of screwing around with standard formats.


Where did you get these dark, low-bitrate videos? I'm afraid those low bitrates will hinder your effort to get clean resizes and re-encodes. Some samples are so dark they're unwatchable. If you try to brighten the details in those crushed blacks you'll find mostly noise and distortion, not detail. There's some bad object ripple and temporal warping, motion smear, block noise, some very noisy, simmering gradient areas, details and lines that disappar during motion, etc. After brightening, some of the segments look like late 50's tv kinescopes. That's quite a cleanup job ahead, I don't ency you. The more resizing and re-encoding you do, the more you'll see those defects.

You can brighten the originals or not, or a little or a lot, whatever. Others might have better ideas. I resized the "49th Man" video from anamorphic 4:33 to 640x480 square pixel. I resized "The Apartment" from letterboxed 4:3 to 856x364 (2.35:1) in an 856x480 letterboxed 16x9 frame. You could get the same thing from "The Apartment" if you sized the 16x9 frame to 720x480 and encoded for 16:9 playback. Why not do it the anamorphic way? Because too many so-called smart TV's are too stupid to play anamorphic video properly (why do we call them smart?). Actually the anamorphic plays cleaner because only the height was resized for anamorphic rather than height and width for square pixel. In any case, all three of the linked mp4 reworks still need a lot more repair -- I'm certain many members here will offer their excellent solutions.

frame 714 original played as 640x480 DAR in 16x9 display.jpg


frame 714 new 640x480 square pixel in 16x9.jpg, won't fill very much of a 6x9 display.


frame 714 new 856x480 in 16x9 display.jpg -- can get same results with the 16:9 anamorphic.


Ideas for reworked samples:
49thMan_640x480_square.mp4 https://www.mediafire.com/file/eya69...480_square.mp4
Apartment_16x9_square.mp4 https://www.mediafire.com/file/2mzix...6x9_square.mp4
Apartment_16x9_anamorphic.mp4 https://www.mediafire.com/file/6ba3s...anamorphic.mp4

The color samples can be resized the same way as the others, but they're really too fuzzy for me right now, I lost so much patience with the other two samples I was too worn down to struggle with fuzz. Not that they're impossible, because overall color balance is about right. As for the 352x480 sample of "20,000 Leagues" recorded at a paltry 6-hour bitrate, that's a mistake that I hope you didn't repeat.
Attached Images
   

Last edited by LemMotlow; 15th September 2017 at 13:28.
LemMotlow is offline   Reply With Quote
Old 15th September 2017, 07:55   #18  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,821
Quote:
Originally Posted by LemMotlow View Post
I like to do what the commercial DVD, BluRay, and broadcast industries do, which is to stick to mod-16 or at least mod-8 frame dimensions. I realize that many eccentric users don't like what the commercial industry does and that they feel some compulsion to re-invent the wheel, but since I've never had a problem playing products produced by the commercial video industry I place more trust in following their lead.
The commercial industry must have breathed a huge sigh of relief when online stores such as itunes arrived. Much of their "1080p" video is actually 1916x1076 or thereabouts, or 1280x716 for "720p" etc.
https://arstechnica.com/civis/viewto...f=19&t=1268043
TV show: only DVD available, no Blu-ray, iTunes HD=what? upscaled?

Quote:
Originally Posted by LemMotlow View Post
There's an obsession I guess with 4:3 Hollywood movie frames at exact 4:P3 sizes, but Hollywood never shot 4:3 movies except for Tv shows. Hollywood used several aspect ratios since the ancient 1880's, but 4:3 wasn't one of them.
My personal obsession is to make 1.333 the "minimum" aspect ratio. If you only crop the black from many older 4:3 DVDs, you'll often end up with aspect ratios such as 1.32 or 1.30 etc, so I prefer to cop a little picture top and bottom if need be to make it 4:3 again. Wider than 4:3 is even better if possible.

Quote:
Originally Posted by LemMotlow View Post
No, you can't crop down to a single pixel -- at least, not with YV12. There's a 2-pixel minimum, and with interlace or telecine YV12 there's a 4-pixel minimum vertically.
That part of the conversation was referring to using the Avisynth resizers for cropping. They even accept float as cropping values so they can theoretically do sub pixel cropping.

Last edited by hello_hello; 15th September 2017 at 08:05.
hello_hello is offline   Reply With Quote
Old 19th September 2017, 02:58   #19  |  Link
ogrgkyle
Registered User
 
Join Date: Aug 2015
Posts: 17
Quote:
Determine what you're going to do with the two movies that were shot at an aspect ratio of 2.35:1. On a typical 1920x1080 display, if you want full width without playtime resizing, you need a square-pixel frame of 1920x816.
Is there much value in resizing ahead of time to avoid playtime resizing? How important is it, in your opinion?

Quote:
How do you match up your 29.97i with your 23.976p in the same video? You don't. On an authored DVD or BluRay you mount them as separate tracks. If you did it the normal way, you'd replace the telecine during your re-encode. Welcome to the world of screwing around with standard formats.
Sure, I know you can't have multiple frame rates in a single video. It's just that I have a huge amount of DVDs where there's a short video intro and then a movie, and it's all in one continuous recording. I'm was wondering if there's a solution where it can all be converted to 23.976p, including the intro, for simplicity.

Although I just realized that the intros are always 4:3 fullscreen, and the movies often need to be cropped, and this would present a problem. In that case, what's a simple solution where both the intro and the movie can be in the same container, but be separate chapters or streams? Would you suggest MKV? I want to have compatibility and keep things simple for "dumb" players. (Which is why I'm leaning towards square pixels.) I've ripped over 1,000 DVDs, and I'm looking for a long-term solution which would work in various media servers, TVs, and video players. I'm thinking about x264/aac in MKV, with different video streams. So please give your thoughts.

Quote:
Where did you get these dark, low-bitrate videos? I'm afraid those low bitrates will hinder your effort to get clean resizes and re-encodes. Some samples are so dark they're unwatchable. If you try to brighten the details in those crushed blacks you'll find mostly noise and distortion, not detail. There's some bad object ripple and temporal warping, motion smear, block noise, some very noisy, simmering gradient areas, details and lines that disappar during motion, etc. After brightening, some of the segments look like late 50's tv kinescopes. That's quite a cleanup job ahead, I don't ency you. The more resizing and re-encoding you do, the more you'll see those defects.
I agree that they are typically low-quality, but unfortunately, that's the way they were typically recorded. Almost all are 720x480, 256kbps, and NTSC. A majority of them are black and white, and a relatively small minority have extreme letterboxing.

I do want to improve them, but not if it's an enormous job. Again, I'm talking about a 1,000+ DVDs. For what it's worth, the people watching these are used to this quality and do not necessarily expect it to be improved, so maybe I can do some lighter touch-up. I can't spend endless time on it, so that's why I uploaded sample sections that represent the main categories of my DVDs. Maybe I can at least tailor my settings to all color films, all black and white films, etc.

Quote:
I resized the "49th Man" video from anamorphic 4:33 to 640x480 square pixel.
And it looks like you padded the top and bottom edges. I guess you did this to have Academy ratio?

Quote:
Why not do it the anamorphic way? Because too many so-called smart TV's are too stupid to play anamorphic video properly (why do we call them smart?).
Yeah, like I said above, I'm leaning towards square pixels for simplicity.

Quote:
As for the 352x480 sample of "20,000 Leagues" recorded at a paltry 6-hour bitrate, that's a mistake that I hope you didn't repeat.
Yeah. As I said above, at least most of them are 720x480, but still not great quality. So that particular movie is an outlier.
ogrgkyle is offline   Reply With Quote
Old 19th September 2017, 04:27   #20  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,821
Quote:
Originally Posted by ogrgkyle View Post
Is there much value in resizing ahead of time to avoid playtime resizing? How important is it, in your opinion?
In my opinion it's pointless because if you upscale to 1080p first there's more video to encode and the bitrate will therefore increase for a given quality but there's no additional picture detail.
I'd never add black borders to video myself. Unless you're encoding for "industry standard" compliance because you want to author a DVD/Bluray disc, and nobody does that any more, the player will simply add the required borders on playback according to the display's aspect ratio.
When you play a 4:3 DVD with a widescreen picture on a 16:9 display and see that tiny picture in the middle surrounded by black, it's a perfect illustration as to why encoding back isn't a good idea... in my opinion.

Quote:
Originally Posted by ogrgkyle View Post
Sure, I know you can't have multiple frame rates in a single video. It's just that I have a huge amount of DVDs where there's a short video intro and then a movie, and it's all in one continuous recording. I'm was wondering if there's a solution where it can all be converted to 23.976p, including the intro, for simplicity.
Sure you can have multiple frame rates in a single video if you're not confined to "industry standards". It's called variable frame rate encoding. The Handbrake GUI is configured to output VFR by default. You can do the same using AVIsynth, but there's more user input required. I'm not sure about ffmpeg.
For a constant frame rate output the standard method is to convert everything to a common frame rate with an Avisynth plugin such as TIVTC. I explained the process earlier in the thread.

Quote:
Originally Posted by ogrgkyle View Post
Although I just realized that the intros are always 4:3 fullscreen, and the movies often need to be cropped, and this would present a problem. In that case, what's a simple solution where both the intro and the movie can be in the same container, but be separate chapters or streams? Would you suggest MKV? I want to have compatibility and keep things simple for "dumb" players. (Which is why I'm leaning towards square pixels.) I've ripped over 1,000 DVDs, and I'm looking for a long-term solution which would work in various media servers, TVs, and video players. I'm thinking about x264/aac in MKV, with different video streams. So please give your thoughts.
I don't know of a way to do it automatically. Using AVIsynth you'd use the dimensions of the main movie as the dimensions for the 4:3 intro, but you would need to add back borders to the sides for the 4:3 part. For example, if you had a 4:3 DVD where the into is 4:3 but the main movie is 16:9 in a 4:3 frame you could do something like this:

Trim(0,999).Crop(12,2,10,-2).Spline36Resize(480,360).AddBorders(80,0,80,0)\
++Trim(1000,0).Crop(2,56,-2,-58).Spline36Resize(640,360)

That'd give you the intro as 460x360 with black borders at the sides for a total of 640x360 to match the rest.
Of course you can resize to any 16:9 dimensions and add the appropriate borders but it requires manually setting it up.
Mind you that sort of thing was my initial motivation for creating the script I mentioned earlier. To make doing that sort of thing easier.
hello_hello is offline   Reply With Quote
Reply

Tags
avisynth, ffmpeg, interlace, ivtc, telecine

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


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