View Full Version : VD2: Aspect ratio: Cropping and Muxer
nji
30th April 2021, 11:24
Recently I stumbled upon two questions with aspect ratio
where I got more and more confused.
(I use the naming of https://en.wikipedia.org/wiki/Pixel_aspect_ratio)
There seem to be two places to place the DAR: the stream and the muxer.
Most players seem to ignore the stream DAR and use the muxer's.
But where do I set the muxer's DAR in VD2?
(As I do in AviDemux).
When doing frame cropping I might like to preserve the SAR.
The crop filter in AviDemux provides that very fine interactively,
but how do I do that in VD2?
Do I really need to do that by using the calculator beside?
StainlessS
30th April 2021, 12:45
AVI [EDIT: container] has no standard Aspect Ratio flagging, [I believe some apps have tried to implement such, but most apps would completely ignore those flags].
EDIT: RIFF [which AVI is based upon] allows for custom chunks which could implement some form of Aspect Ratio flagging, but everybody execpt the implementor would likely skip over those chunks as allowed by RIFF.
When cropping frames, sample/pixel aspect ratio does not change at all, whether you want it to or not.
(Resizing can change sample/pixel aspect ratio)
nji
30th April 2021, 13:30
You are right, AVI container has no aspect ratio flagging.
But MKV, MOV/QT, MP4 and WebM has it.
So...?
Aspect ratio when cropping:
If my orig frame has a SAR of 1 (=quadratic) and I chop off the upper half,
the SAR (= frame dimension ratio) will be halved.
If I keep the DAR constant then, the frame will be
stretched vertically by 2 when displaying.
As I said: Confused.
SeeMoreDigital
30th April 2021, 15:01
Most players seem to ignore the stream DAR and use the muxer's.
Hmmm...
In my experience, most software and hardware media players read the 'video streams' aspect ratio signalling, not the containers.
But where do I set the muxer's DAR in VD2?
I suggest you visit the encoders configuration settings and enter the ratio you require in the boxes provided: -
https://i.ibb.co/0VpYHjG/Capture.png
EDIT: I've just finished creating some 720x480 MPEG-4 AVC .mkv, .mp4 and .avi contained encodes using 'VirtualDub 2 v44282', and they all play at the correct aspect ratio on my OPPO UDP-203 hardware player, LG television, MPC-BE player, VLC player, Windows Media Player and my Android mobile phone ;)
StainlessS
30th April 2021, 15:55
But MKV, MOV/QT, MP4 and WebM has it.
Oops, yes, I forgot it does those now [I aint ever used for anything other than AVI].
Yes, DAR can change when crop, but SAR does not.
See Here,
https://forum.doom9.org/showthread.php?p=1576193#post1576193
The GetSAR() etc things were re-implemented in RT_Stats as eg RT_GetSAR().
Here is a snippet of stuff I use in some scripts
AviSource("...") # some source
DAR=1.78 # According to DVD, maybe DGIndex, FULL FRAME including possible borders
SAR=RT_GetSAR(DAR)
RoboCrop() # Crop borders
DAR=RT_GetDAR(SAR) # DAR after crop, SAR remains the same
RT_DebugF("CropDAR=%f",DAR) # DAR of active image, excluding borders
return last
EDIT:
RT_GetSAR(clip,dar float)
Gets Sample (pixel) Aspect Ratio from DAR Display Aspect Ratio.
***
***
***
RT_GetDAR(clip,sar float)
Gets DAR Display Aspect Ratio from SAR, Sample (pixel) Aspect Ratio.
***
***
***
RT_SignalDAR(float) # See Megui wiki (name change from SetDAR)
Signal DAR to MEGUI. Sets Global vars MeGUI_darX and MeGUI_darY which are read during MEGUI loading of AVS file.
***
***
***
RT_SignalDAR2(int darx,int dary)
As for RT_SignalDAR() except it allows setting of numerator and denominator individually.
Signal DAR to MEGUI. Sets Global vars MeGUI_darX and MeGUI_darY which are read during MEGUI loading of AVS file.
***
***
***
RT_GetCropDAR(clip,float DAR,float "X"=0,float "Y"=0,Float"W"=0,float "H"=0)
Call prior to Crop/Resize with (possibly fractional) cropping to calc resultant DAR, X,Y,W,H are cropping coords
DAR = FAR * SAR ::: FAR = DAR / SAR ::: SAR = DAR / FAR
Cropping affects FAR & usually DAR, resizing does not affect DAR (unless also cropped). Resizing affects FAR and maybe SAR.
We dont allow eg -ve X
EDIT: FAR = Frame Aspect Ration (pixel dimensions).
EDIT: And from the link (script versions)
Function GetDAR(clip c, float SAR) { return Float(c.width) * SAR / Float(c.height)} # Gets the DAR from the SAR
Function GetSAR(clip c, float DAR) { return DAR * Float(c.height) / Float(c.width) } # Gets the SAR from the DAR
Function SignalDAR(float DAR) { global MeGUI_darx = Round(1000 * DAR) global MeGUI_dary = 1000 } # Signals DAR for MEGUI
About AR in VD2: this is still to be developed, I have several feature requests in this area.
OK, thanks, I got it then.
But as there hasn't been any step in VD2 dev in the last months... and there are probably not only issues about AR... Will there ever be a new version of it? Or is it the end of the road?
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.