bavc / qctools

QCTools (Quality Control Tools for Video Preservation) is a free and open source software tool that helps users analyze and understand their digitized video files through use of audiovisual analytics and filtering. QCTools is funded by the National Endowment for the Humanities and the Knight Foundation, and is developed by the Bay Area Video Coalition.
http://www.bavc.org/qctools
Other
315 stars 41 forks source link

DAR ignoring pixel aspect ratio value in file list view #93

Open kieranjol opened 9 years ago

kieranjol commented 9 years ago

I have two PAL SD files which have non square pixels which result in mediainfo listing a DAR of 4:3. When I open them in QCtools, they are listed as presumably PAL square pixel 1.2500 with "Und" listed as the SAR. Am I correct in thinking that the "sample aspect ratio" is equivalent to pixel aspect ratio?

One clip is just PAL colour bars generated from FCP, the other is a tape ingest from AJA Control room. They have similar outputs via mediainfo, but the DAR is different for each in ffmpeg. FFmpeg readout of FCP bars: http://pastebin.com/TRZ4EK4U ffmpeg readout of AJA control betas ingest: http://pastebin.com/h2yRCZtE

The verbose mode of mediainfo has conflicting DAR/frame size info for the FCP bars: Width : 720 Width : 720 pixels Clean aperture width : 703 Clean aperture width : 703 pixels Height : 576 Height : 576 pixels Clean aperture height : 576 Clean aperture height : 576 pixels Pixel aspect ratio : 1.093 Clean aperture pixel aspect ratio : 1.093 Display aspect ratio : 1.366 Display aspect ratio : 4:3 Clean aperture display aspect ratio : 1.333 Clean aperture display aspect ratio : 4:3

And here's the control room ingest: Width : 720 Width : 720 pixels Height : 576 Height : 576 pixels Pixel aspect ratio : 1.067 Display aspect ratio : 1.334 Display aspect ratio : 4:3

FCP bars sample: https://dl.dropboxusercontent.com/u/3740512/Sequence%201.mov beta ingest: https://dl.dropboxusercontent.com/u/3740512/4_3_dar.mov

I'm worried that this will interfere with CropF readouts. I ingested a betaSP tape that shows up as 4:3 in ffmpeg and mediainfo. There is some blanking on all sides, so when I subtract the crops (32px from height, 16 from width, I get 688/560 = a ratio of 1.228:1, which is roughly equivalent to the ratio of 704/576, 1.22:1. If I factored in the standard non widescreen PAL pixel aspect ratio (1.09:1) to that 1.22:1 image, I would end up with close to 1.33:1. As such, it would be great if Qctools could report the correct DAR.

dericed commented 9 years ago

yes pixel aspect ratio = sample aspect ratio

MediaInfo and QCTools handle reporting differently. Mediainfo will round off aspect ratios to the nearest standard aspect ratio (so 1.2, 1.3, and 1.4 may be considered 4/3)

With mediainfo's report the output is not conflicting, it is just reporting on the multiple aspect ratios of the file, see the aperature atom you have in there vs the track description atom.

The crop filter is not affected by aspect ratio by only reporting on encoded pixels, so the results of the same stream would be the same even if at different aspect ratios.

kieranjol commented 9 years ago

Hi Dave,

That makes total sense re the crop filter.

I'm still confused about the DAR readout in QCtools, however. If Display Aspect Ratio equals Storage Aspect Ratio * Pixel/Sample Aspect Ratio, why is it still giving a square pixel readout?

I have not tried atom inspection yet, I'm totally green in this respect. Is the qctools readout because there is an issue with the files themselves, perhaps a messed up setting?

Thanks,

Kieran.

dericed commented 9 years ago

It looks like the DAR column uses a fallback https://github.com/bavc/qctools/blob/master/Source/Core/FFmpeg_Glue.cpp#L1649-L1668, perhaps I should remove the else condition of the if statement.

kieranjol commented 9 years ago

That would be interesting. it seems like it's not picking up the Sample Aspect Ratio at all for those files, though? it looks like it produced "und" if it receives a value of 0?

JeromeMartinez commented 9 years ago

I have some MediaInfo users who complained about the lack of DAR when there is no explicit SAR in the file. they want to consider the lack of SAR as 1:1 SAR (especially with AVI files)

dericed commented 9 years ago

currently DAR is a double. If I remove the else condition, the result may be 0.0. I'd prefer to say "Und" but would have to redefine DAR. Ideally this would stay in ratio form but we'd have somehow simplify (height * SAR) / width. @JeromeMartinez, is there a function to simplify such a ratio (i.e. reduce 640/480 to 4/3)?

JeromeMartinez commented 9 years ago

MediaInfo and FFmpeg both report the (nearly, I have to fix rounding issues in MediaInfo) same DAR:

In QCTools, we use FFmpeg data, I don't understand the reason I can not read DAR from FFmpeg with these files. InputData->Stream->codec->sample_aspect_ratio.num is 0 when I read value from FFmpeg API (using FFmpeg 2.5)

I'll update to FFmpeg 2.7

JeromeMartinez commented 9 years ago

@JeromeMartinez, is there a function to simplify such a ratio (i.e. reduce 640/480 to 4/3)?

Not in my code. I think it is available in FFmpeg code (it says "SAR 59:54 DAR 295:216").

dericed commented 9 years ago

Actually note that @richardpl has been doing significant work with the filter library recently, so I'd like the next qctools release to either use git master or the next release.

dericed commented 7 years ago

@kieranjol your sample files are now offline. Could you please retest in git-master. @ElderOrb recently cleaned up a lot of the code related to report sar and dar.

kieranjol commented 7 years ago

Will do!

kieranjol commented 7 years ago

Hi @dericed/ @ElderOrb : I'll just reuse the file that @aoifefitz2016 uploaded to a different issue: https://drive.google.com/open?id=0B80EiSambHhLSnMwQnc1NFZ0Mnc

The DAR is listed as 1.25 in QCTools, with a SAR that is Und. FFmpeg and mediainfo pick up on the SAR/DAR, but perhaps QCTools is trying to glean these values from a different section of the file?

ffmpeg -i followed by a section of the mediatrace

ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.31)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libtesseract --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.1.2_1/include/openjpeg-2.1 --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, matroska,webm, from 'oe5909_vrep_clip.mkv':
  Metadata:
    COM.APPLE.PROAPPS.SCENE: ifi-es2-bme-j30sdi 
    COM.APPLE.PROAPPS.SHOT: 01
    MAJOR_BRAND     : qt  
    MINOR_VERSION   : 537199360
    COMPATIBLE_BRANDS: qt  
    COM.APPLE.PROAPPS.ANGLE: 01
    COM.APPLE.PROAPPS.LOGNOTE: oe5909
    COM.APPLE.PROAPPS.REEL: af
    ENCODER         : Lavf57.71.100
  Duration: 00:00:01.02, start: 0.000000, bitrate: 96178 kb/s
    Stream #0:0(eng): Video: ffv1 (FFV1 / 0x31564646), yuv422p10le(top coded first (swapped)), 720x576, SAR 16:15 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      HANDLER_NAME    : Apple Alias Data Handler
      TIMECODE        : 09:58:01:21
      ENCODER         : Lavc57.75.100 ffv1
      DURATION        : 00:00:01.000000000
    Stream #0:1(eng): Audio: pcm_s24le, 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default)
    Metadata:
      HANDLER_NAME    : Apple Alias Data Handler
      DURATION        : 00:00:01.018000000
At least one output file must be specified
mediaconch -mt oe5909_vrep_clip.mkv | grep aspect
                <data offset="1597" name="sample_aspect_ratio num">16</data>
                <data offset="1597" name="sample_aspect_ratio den">15</data>
                <data offset="20954" name="sample_aspect_ratio num">16</data>
                <data offset="20954" name="sample_aspect_ratio den">15</data>
                <data offset="42574" name="sample_aspect_ratio num">16</data>
                <data offset="42574" name="sample_aspect_ratio den">15</data>
                <data offset="66656" name="sample_aspect_ratio num">16</data>
                <data offset="66656" name="sample_aspect_ratio den">15</data>
                <data offset="88786" name="sample_aspect_ratio num">16</data>
                <data offset="88786" name="sample_aspect_ratio den">15</data>
                <data offset="123803" name="sample_aspect_ratio num">16</data>
                <data offset="123803" name="sample_aspect_ratio den">15</data>
                <data offset="159607" name="sample_aspect_ratio num">16</data>
                <data offset="159607" name="sample_aspect_ratio den">15</data>
                <data offset="192087" name="sample_aspect_ratio num">16</data>
                <data offset="192087" name="sample_aspect_ratio den">15</data>
                <data offset="221204" name="sample_aspect_ratio num">16</data>
                <data offset="221204" name="sample_aspect_ratio den">15</data>
                <data offset="257072" name="sample_aspect_ratio num">16</data>
                <data offset="257072" name="sample_aspect_ratio den">15</data>
                <data offset="288150" name="sample_aspect_ratio num">16</data>
                <data offset="288150" name="sample_aspect_ratio den">15</data>
                <data offset="314888" name="sample_aspect_ratio num">16</data>
                <data offset="314888" name="sample_aspect_ratio den">15</data>
                <data offset="338400" name="sample_aspect_ratio num">16</data>
                <data offset="338400" name="sample_aspect_ratio den">15</data>
                <data offset="376859" name="sample_aspect_ratio num">16</data>
                <data offset="376859" name="sample_aspect_ratio den">15</data>
                <data offset="415033" name="sample_aspect_ratio num">16</data>
                <data offset="415033" name="sample_aspect_ratio den">15</data>
                <data offset="447391" name="sample_aspect_ratio num">16</data>
                <data offset="447391" name="sample_aspect_ratio den">15</data>
kieranjol commented 7 years ago

Ah, I forgot that I'd already posted here. Anyhow I still see this issue in today's snapshot. SAR is listed as Und. More relevant info in the post before last.