[SOLVED] DGSource seems to be delivering incorrect aspect ratio ?

Support forum for DGDecNV
User avatar
Rocky
Moose Approved
Posts: 828
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by Rocky » Fri Jul 31, 2020 9:50 am

DGSource does not deliver any aspect ratio information at all (EDIT: yes it does but only for Vapoursynth). It delivers only the decoded video. So your question is incoherent. Nevertheless I try to clarify things for you.

The aspect ratio information is shown in the DGIndexNV Info dialog. There must have been a preview operation for that information to be included in the log file (there can't be a preview with CLI), but it is always available in the DGI file.

The source MPG file you provided specifies aspect_ratio_information as 3. That means DAR 16:9. The MPEG2 spec specifies a way to derive a SAR from the DAR and frame size. You can read the spec if you are interested. But be aware that DGDecNV does not calculate or report any SAR value, so all this is irrelevant to your question. DGIndexNV reports only the DAR, and DGSource() does not deliver anything regarding aspect ratio.

I cannot be held responsible for what other tools are /calculating/reporting/inferring for SAR. There is also a lot of confusion and ambiguity with the notation, so that may be underlying what you are seeing. E.g., SAR is sometimes used as "Storage Aspect Ratio" and as sometimes as "Sample Aspect Ratio".

User avatar
hydra3333
Moose Approved
Posts: 200
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by hydra3333 » Fri Jul 31, 2020 10:04 am

thank you for the clarification.

I guess lsmash must somehow deliver it, on the basis of the resulting output file characteristics when using lsmash as the source.

oh well.

User avatar
Rocky
Moose Approved
Posts: 828
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by Rocky » Fri Jul 31, 2020 10:10 am

Ah, noticed you are using Vapoursynth. Perhaps the SAR gets set in the per-frame metadata by lsmash. I'll check that.

User avatar
Rocky
Moose Approved
Posts: 828
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by Rocky » Fri Jul 31, 2020 10:16 am

Yes, Vapoursynth has this:

int _SARNum, int _SARDen
Pixel (sample) aspect ratio as a rational number.

I will add setting that to my to-do list, but it's not high priority. Is it some kind of showstopper for you?

BTW, my calculation yields 1.422 as the PAR (SAR).

User avatar
Rocky
Moose Approved
Posts: 828
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by Rocky » Fri Jul 31, 2020 10:21 am

Haha, I just looked and I am already setting it. I'll check to see what it is setting for your stream and correct it if needed.

EDIT: Yup, my bad. I wrote the DAR in there. Will fix it. Thank you for pointing this out.

User avatar
Rocky
Moose Approved
Posts: 828
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by Rocky » Fri Jul 31, 2020 11:11 am

Let me know if this is working better:

http://rationalqm.us/misc/DGDecodeNV_hydra.dll

I tested it for MPG2 only but it should be OK for all the video types.

EDIT: Rename it to DGDecodeNV.dll of course.

User avatar
hydra3333
Moose Approved
Posts: 200
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by hydra3333 » Fri Jul 31, 2020 8:22 pm

:) Thanks !

Close but no cigar I'm afraid.

Code: Select all

Width                                    : 720
Width                                    : 720 pixels
Height                                   : 576
Height                                   : 576 pixels
Sampled_Width                            : 720
Sampled_Height                           : 576
Pixel aspect ratio                       : 1.000
Display aspect ratio                     : 1.250
Display aspect ratio                     : 5:4
Looking for something more like:

Code: Select all

Width                                    : 720
Width                                    : 720 pixels
Height                                   : 576
Height                                   : 576 pixels
Sampled_Width                            : 720
Sampled_Height                           : 576
Pixel aspect ratio                       : 1.422
Display aspect ratio                     : 1.778
Display aspect ratio                     : 16:9
which is what one gets with lsmash or when adding '-vf "setdar=16/9"' on the ffmpeg commandline and then plays OK in media player classic home cinema.

User avatar
Rocky
Moose Approved
Posts: 828
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by Rocky » Sat Aug 01, 2020 9:08 am

Having trouble duplicating your result (not to mention the nightmare of vapoursynth error messages -- don't give a full path to the DLL and it tells you to update windows -- are you kidding me?). I have these scripts:

FILE2_dgdecodenv.vpy:

Code: Select all

import vapoursynth as vs
from vapoursynth import core
core.std.LoadPlugin(r'D:\Don\Programming\C++\DGDecNV\DGDecodeNV\x64\release\DGDecodeNV.dll') 
video = core.dgdecodenv.DGSource(r'FILE2.dgi', deinterlace=0, use_pf=False) 
video = vs.core.text.ClipInfo(video) 
video.set_output()
FILE2_lsmash.vpy:

Code: Select all

import vapoursynth as vs
from vapoursynth import core
core.std.LoadPlugin(r'D:\tmp\hydra3333 SAR problem\LSMASHSource.dll') 
video = core.lsmas.LWLibavSource(source=r'D:\tmp\hydra3333 SAR problem\FILE2.mpg', ff_loglevel=6)
video = vs.core.text.ClipInfo(video) 
video.set_output()
When opened in VirtualDub2, they both show identical ClipInfo. There are no other properties that I am aware of, so it seems both scripts make available the same information.

Now, on to ffmpeg. I can't follow your command at all. It's complicated by NVENC and stuff. And my latest ffmpeg says that '-input vapoursynth' is an unknown input format. So I made simple ffmpeg lines using a pipe:

vspipe --y4m FILE2_lsmash.vpy - | ffmpeg -i pipe: encoded_lsmash.mp4
vspipe --y4m FILE2_dgdecodenv.vpy - | ffmpeg -i pipe: encoded_dgdecodenv.mp4

Then I run mediainfo on the MP4 files and I get the same thing for both (except for very small difference in bitrate):

Code: Select all

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 29 s 640 ms
Bit rate                                 : 369 kb/s
Width                                    : 720 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 5:4
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.036
Stream size                              : 1.31 MiB (99%)
Writing library                          : x264 core 161
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Codec configuration box                  : avcC
This does not show PAR like your post does. I do not understand why.

So I am simply unable to account for your result either theoretically or by trying to duplicate it. The ball is in your court if you want to go further. Do things with a simplified ffmpeg command as I am not going through the NVENC rigamarole. You have to somehow prove that the two source filters are delivering different information, whereas I claim to have shown that they deliver the same information.

User avatar
hydra3333
Moose Approved
Posts: 200
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by hydra3333 » Sun Aug 02, 2020 4:27 am

Thank you for trying !

How interesting.

The ffmpeg.exe is a custom cross-compile (but no patching on my part) with vapoursynth enabled.

I'll do some further testing (using the updated dll you posted) with ffmpeg/vsedit/virtualdub2 and let you know what I find.

I cannot currently explain the difference ! I'm leaning toward my error but cannot as yet say why.

User avatar
hydra3333
Moose Approved
Posts: 200
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: DGSource seems to be delivering incorrect aspect ratio ?

Post by hydra3333 » Sun Aug 02, 2020 5:56 am

Just checking ... you and I are using the same DLL (the link you provided to DGDecodeNV_hydra.dll) ?
I still get the same results so far (re-doing my ffmpeg commands)

Edit: it looks like ffmpeg and/or vapoursynth may be playing up. Initial result:
1. consistently - using lsmash : with vapoursynth input directly it is successful, however with pipe is now fails with the same .vpy.
2. consistently - with dgsource: it fails with the same .vpy on both pipe and direct .vpy input.
I used a .bat to ensure the right .vpy etc were consistently used repeatably :(

I'll try another video and the original dgsource .dll to see what happens.

So, I tend to concur it isn't dgsource since issues also arise with lsmash.

I cannot explain why my pipe result (a fail) differs from yours, although I had upgraded to vapoursynth R51 just prior to these tests.
Last edited by hydra3333 on Sun Aug 02, 2020 10:18 am, edited 1 time in total.

Post Reply