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 28th March 2015, 14:04   #1  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 387
Does ffpmegsource2 change aspect?

I have some footage in MP4 format. Footage details comes from mediainfo.

The source footage is:
- Size: 720x480
- Display Aspect: 16:9
- Pixel aspect: 1.185
- Display aspect: 1.777

I create a basic AVISynth script:

ffmpegsource2("source.m4v", vtrack = -1)
QTGMC()

In VirtualDub Save AVI as Lagarith codec with fast recompress. No other changes.

Output is:
- Size: 720x480
- Display Aspect: 3:2
- Pixel aspect: 1.000
- Display aspect: 1.500

Any idea why the aspect change happens? I personally did not set any resizing settings during the conversion.

Thanks.

JR
jriker1 is offline   Reply With Quote
Old 28th March 2015, 14:09   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 12,935
As you can see, the video resolution remains exactly the same: 720x480. So nothing has been resized. Or in other words: The actual video data has not changed.

Only the "Pixel aspect" ratio, which is a meta-information, has changed from 1.185 (aka "Anamorphic Video") to 1.0 (aka "Square Pixels"). That's why the "Display aspect" ratio is now computed to a different value too!

Avisynth delivers "raw" video data to the application. I don't think Avisynth internally carries meta-information, such as "Pixel aspect" ratio, for the clip. Nor does it deliver any such an information to the application.

(Also note that applications, especially video players, generally assume a "Pixel aspect" ratio of 1:1, if no explicit Pixel aspect" ratio information is available)


[EDIT]

Also keep in mind that the AVI format has no proper way for signaling "Pixel aspect" on the container level anyway! Some video formats have their own way, but I have no idea if that applies to Lagarith (probably not).
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 28th March 2015 at 14:20.
LoRd_MuldeR is offline   Reply With Quote
Old 28th March 2015, 15:11   #3  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 387
Quote:
Originally Posted by LoRd_MuldeR View Post
As you can see, the video resolution remains exactly the same: 720x480. So nothing has been resized. Or in other words: The actual video data has not changed.

Only the "Pixel aspect" ratio, which is a meta-information, has changed from 1.185 (aka "Anamorphic Video") to 1.0 (aka "Square Pixels"). That's why the "Display aspect" ratio is now computed to a different value too!

Avisynth delivers "raw" video data to the application. I don't think Avisynth internally carries meta-information, such as "Pixel aspect" ratio, for the clip. Nor does it deliver any such an information to the application.

(Also note that applications, especially video players, generally assume a "Pixel aspect" ratio of 1:1, if no explicit Pixel aspect" ratio information is available)


[EDIT]

Also keep in mind that the AVI format has no proper way for signaling "Pixel aspect" on the container level anyway! Some video formats have their own way, but I have no idea if that applies to Lagarith (probably not).
Thanks for the reply. There is no way to pass the aspect information in the ffmpegsource2 line of the AVISynth script is there? Also since that information has been lost in the file assuming it won't play visually right on a lot of players. Do I need to convert this to like 853 x 480 since it's 1:1 now?

Thanks.

JR
jriker1 is offline   Reply With Quote
Old 28th March 2015, 15:20   #4  |  Link
creaothceann
Registered User
 
Join Date: Jul 2010
Location: Germany
Posts: 360
Just put the output into MKVmerge GUI and set the aspect ratio. Players (at least those on PC?) will then stretch the output window to that aspect ratio.
creaothceann is offline   Reply With Quote
Old 28th March 2015, 15:26   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,067
Is AVI final output or intermediate lossless ?
MeGUI allows MeGUI_darX, MeGUI_darY in Avisynth script if feeding in intermediate.
__________________
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 28th March 2015, 16:06   #6  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 387
Quote:
Originally Posted by StainlessS View Post
Is AVI final output or intermediate lossless ?
MeGUI allows MeGUI_darX, MeGUI_darY in Avisynth script if feeding in intermediate.
It's an intermediate format while I do some cleanup and adjusting. Note my eventual plan is to have this be square aspect as some Microsoft technologies don't necessarily honor the aspect ratio settings depending on the device or player being used.

Also is MeGUI better to use than pumping the AVISynth scripts thru VirtualDub?

Thanks.

JR
jriker1 is offline   Reply With Quote
Old 28th March 2015, 16:22   #7  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 12,935
Quote:
Originally Posted by jriker1 View Post
Note my eventual plan is to have this be square aspect as some Microsoft technologies don't necessarily honor the aspect ratio settings depending on the device or player being used.
If you want your video to be displayed with proper aspect ratio assuming an "pixel aspect" ration of 1:1 (square pixels), then you need to apply a resize filter!

Just resize your 720x480 video to 848x480 and it will display at ~16:9 (assuming an "pixel aspect" ration of 1:1).

Quote:
Originally Posted by jriker1 View Post
Also is MeGUI better to use than pumping the AVISynth scripts thru VirtualDub?
Totally depends on what you want to do!

VirtualDub is primarily a video editor. You can use it for editing, but you shouldn't use for the final encoding. VirtualDub only supports VFW Codecs, which isn't the best idea for encoding H.264 and the like.

MeGUI (or a similar encoder front-end) is good for encoding, but has limited video editing capabilities...

Quote:
Originally Posted by jriker1 View Post
Also since that information has been lost in the file assuming it won't play visually right on a lot of players. Do I need to convert this to like 853 x 480 since it's 1:1 now?
Keep in mind that the video has not changed at all! It's still the exactly same content as before.

The PAR ("pixel aspect" ratio) is just a meta-information, which can be signaled to the playback software in one way or another; and which might be respected by your individual video player, or not.

Resizing the video so that it will be displayed correctly with a PAR of 1:1 is one option. And maybe the most reliable one - as you don't need to rely on the player to properly apply the PAR.

Nonetheless, if you want to avoid resizing the video, then you can simply specify the proper PAR when doing the final encode! The x264 encoder, for example, has the "--sar" option for that purpose!
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 28th March 2015 at 16:33.
LoRd_MuldeR is offline   Reply With Quote
Old 28th March 2015, 16:36   #8  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 387
Quote:
Originally Posted by LoRd_MuldeR View Post
If you want your video to be displayed with proper aspect ratio assuming an "pixel aspect" ration of 1:1 (square pixels), then you need to apply a resize filter!

Just resize your 720x480 video to 848x480 and it will display at ~16:9 (assuming an "pixel aspect" ration of 1:1).

I thought when you had a 16:9 DVD source that was 720x480 the correct square pixel frame size was 853x480 or 864x480? Is what I have read in the past off?

Thanks.

JR
jriker1 is offline   Reply With Quote
Old 28th March 2015, 16:43   #9  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 12,935
Quote:
Originally Posted by jriker1 View Post
I thought when you had a 16:9 DVD source that was 720x480 the correct square pixel frame size was 853x480 or 864x480? Is what I have read in the past off?
853 would be the closest integer resolution, yes. However, due to the chroma sub-sampling in YV12 (YUV 4:2:0) - which is the color format you most likely are going to use - the resolution needs to be even. So you could pick 852 or 854. But, yet another thing to keep in mind is that most of today's video formats work with 16x16 macro blocks internally. So they work best with a "mod16" (integer multiple of 16) resolution. And the closest "mod16" resolution to 853 would be 848, I think.
__________________
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.



Last edited by LoRd_MuldeR; 28th March 2015 at 16:46.
LoRd_MuldeR is offline   Reply With Quote
Old 28th March 2015, 17:12   #10  |  Link
creaothceann
Registered User
 
Join Date: Jul 2010
Location: Germany
Posts: 360
Quote:
Originally Posted by LoRd_MuldeR View Post
VirtualDub only supports VFW Codecs, which isn't the best idea for encoding H.264 and the like.
http://sourceforge.net/projects/x264vfw/
creaothceann is offline   Reply With Quote
Old 30th March 2015, 02:56   #11  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 387
Assuming I shouldn't resize physically with Virtualdub, is there a recommended way of resizing in AVISynth? Not sure if one works better than another of if it matters.

Thanks.

JR
jriker1 is offline   Reply With Quote
Old 30th March 2015, 05:15   #12  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 3,777
http://avisynth.nl/index.php/Resize

AVISynth resizing filter comparison

I mostly use Spline36Resize myself. ie

Spline36Resize(854, 480)

I'm a bit OCD when it comes to aspect ratio, and I don't think I've ever encoded a DVD where I didn't want to crop at least a couple of pixels of crud from the sides or a few pixels top and bottom etc, and if the picture is very close to 16:9 I prefer to resize to exactly 16:9 given I have a 16:9 TV so I adjust the cropping as required and do just that (admittedly technically it's probably better not to resize the height but in reality the whole thing is invariably going to be upscaled on playback anyway, assuming you're using a 1080p or 720p TV). Something like:

Crop(4, 2, -2, -2)
Spline36Resize(832, 468)

Quote:
Also is MeGUI better to use than pumping the AVISynth scripts thru VirtualDub?
I don't know about "better" but I use MeGUI. It'll probably make some Avisynth things easier. It's Avisynth Script Creator will automatically take care of the aspect ratio when anamorphic encoding is used, or if you resize to square pixels it'll calculate the aspect ratio distortion so you can adjust the cropping and/or resizing to minimise it (similar to this calculator). Plus you can easily modify scripts manually and see the changes instantly in the script creator's preview.
And for x264 encoding, MeGUI means you don't need to user VirtualDub's "external encoders" feature.

Last edited by hello_hello; 30th March 2015 at 05:18.
hello_hello is offline   Reply With Quote
Old 30th March 2015, 08:16   #13  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,528
Quote:
it's probably better not to resize the height but in reality the whole thing is invariably going to be upscaled on playback anyway
It's definitely better not to resize the height, because the whole thing is going to be upscaled on playback.
__________________
My AviSynth filters / I'm the Doctor
davidhorman is online now   Reply With Quote
Old 30th March 2015, 10:51   #14  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 3,777
Quote:
Originally Posted by davidhorman View Post
It's definitely better not to resize the height, because the whole thing is going to be upscaled on playback.
Maybe you could show me why using these screenshots. It's a PAL video, resized in AVIsynth (or not), then running fullscreen on my TV courtesy of MPC-HC (bicubic resizing), and I used PrintScreen to take a screenshot. The resolutions listed are the resolutions after resizing with Avisynth's Spline36Resize, before MPC-HC then resized it again to 1080p.

720x576 (no Avisynth resizing):


1024x576:


960x540 (my usual PAL DVD encoding resolution):


I know technically not resizing the height is better but it's a PAL DVD, which isn't exactly packed full of high definition goodness, and for NTSC there's even less (and given much of the time I'd be applying some sort of filtering such as noise removal anyway) what did first resizing to 960x540 do in this case that's so detrimental it shows I definitely shouldn't resize that way?
hello_hello is offline   Reply With Quote
Old 30th March 2015, 17:15   #15  |  Link
davidhorman
I'm the Doctor
 
Join Date: Jan 2004
Posts: 1,528
I never promised it would be noticeably better

But it's certainly going to be mathematically better.

Imagine trying the same thing with interleaved black/white rows of pixels. Mathematically you're still doing the same thing to any other picture, even if you can't necessarily see it.
__________________
My AviSynth filters / I'm the Doctor
davidhorman is online now   Reply With Quote
Old 30th March 2015, 17:53   #16  |  Link
colours
Registered User
 
colours's Avatar
 
Join Date: Mar 2014
Posts: 312
You answered your own question!

Quote:
Originally Posted by hello_hello View Post
I know technically not resizing the height is better []
__________________
Say no to AviSynth 2.5.8 and DirectShowSource!
colours is offline   Reply With Quote
Old 31st March 2015, 03:45   #17  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 3,777
Quote:
Originally Posted by davidhorman View Post
I never promised it would be noticeably better
No, but you said it's "definitely" better not to resize the height which to me implies it's "noticeably" better not to.

Quote:
Originally Posted by davidhorman View Post
But it's certainly going to be mathematically better.
You could probably say the same thing regarding x264 encodes using the PNSR or SSIM tunings.

Quote:
Originally Posted by davidhorman View Post
Imagine trying the same thing with interleaved black/white rows of pixels. Mathematically you're still doing the same thing to any other picture, even if you can't necessarily see it.
I'm still waiting for a real world example where you can see it because I've never seen a DVD like that. I've compared "no height resizing" to a "small amount of height resizing" lots of times and if I'd seen "no height resizing" looks better I wouldn't resize it.
Quite often a 960x540 resized DVD looks a little sharper running fullscreen on my TV than an equivalent anamorphic encode, because Spline36 Resize tends to sharpen a little, although admittedly the same applies to a 1024x576 encode.

Quote:
Originally Posted by colours View Post
You answered your own question!
I realise that. I admitted "technically" no height resizing is better but I went on to say I often resize the height a little, obviously because in practice it doesn't make a noticeable difference to quality.
hello_hello is offline   Reply With Quote
Old 1st April 2015, 00:41   #18  |  Link
jriker1
Registered User
 
Join Date: Dec 2003
Posts: 387
Without getting into the badness of deinterlacing in the first place, Is it technically bad to be deinterlacing footage that the aspect ratio is not what it should be? Also is it better to resize (to 1:1) and then deinterlace or deinterlace and then resize?

Thanks.

JR

Last edited by jriker1; 1st April 2015 at 00:46.
jriker1 is offline   Reply With Quote
Old 1st April 2015, 02:02   #19  |  Link
creaothceann
Registered User
 
Join Date: Jul 2010
Location: Germany
Posts: 360
Quote:
Originally Posted by jriker1 View Post
Is it technically bad to be deinterlacing footage that the aspect ratio is not what it should be?
(De-)Interlacing is a vertical-only process, so aspect ratio doesn't matter. (In fact, aspect ratio stuff is better handled by the aspect ratio flag in e.g. the *.mkv file format -you shouldn't need to resize horizontally at all.)

Quote:
Originally Posted by jriker1 View Post
Also is it better to resize (to 1:1) and then deinterlace or deinterlace and then resize?
Whatever you do, don't change the number of lines with a resizer before deinterlacing.
creaothceann is offline   Reply With Quote
Old 1st April 2015, 13:23   #20  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 3,777
As a general rule, if you de-interlace, you'd de-interlace before any resizing other filtering.
hello_hello 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 13:01.


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