[FFmpeg-devel] [PATCH 1/1] [RFC] ffprobe: report DAR even if SAR is undefined
Timo Teras
timo.teras at iki.fi
Mon Apr 16 09:06:55 EEST 2018
On Sun, 15 Apr 2018 16:42:01 +0200 (CEST)
Marton Balint <cus at passwd.hu> wrote:
> On Sun, 15 Apr 2018, Timo Teräs wrote:
>
> > Calculate DAR with assumed SAR 1:1 when SAR is undefined. Same
> > assumption is done in ffplay to create the play window. Usually
> > DAR is more useful metadata than SAR when e.g. choosing which
> > media of multiple versions to use to fit the display.
>
> I don't think it's good idea to generally assume 1:1
> display_aspect_ratio for every undefined sample aspect ratio. It
> depends heavily on your actual use case. If MOV/MP4 specifies that
> 1:1 SAR should be used, then maybe you should fix
> av_guess_sample_aspect_ratio instead, and return 1:1 there if the
> format context is MOV/MP4. You may add a demuxer (AVFMT) flag to
> signal that such behaviour should be used, and
> av_guess_sample_aspect_ratio can check for that demuxer flag.
Looking at code, av_guess_sample_aspect_ratio() is used only in ffplay
and ffprobe.
ffplay implicitly assumes undefined SAR is 1:1 to create the playback
window properly; this happens in calculate_display_rect() when
"bad" aspect_ratio is reset to 1.0.
I would expect same logic would have been useful in ffprobe. This would
help to report back to user what ffplay is going to do with the video.
Or at least give a hint on how to categorize the clip. SAR 1:1 is
pretty good guess for most formats.
For this reason, my preferred solution was to patch ffprobe so we can
give a guess for all files. If the above patch is not a good idea, how
about adding new "effective_{sample,display}_aspect_ratio" fields? Or
just a flag "aspect_ratio_guessed" to tell if it's not defined in the
file?
I would prefer not to do any file type specific special handling if
possible. However, if that's the only acceptable solution, I'm happy to
implement that too. But then I'd prefer to have a 'no default SAR of
1:1' flags so file formats can inhibit the assumption instead of
explicitly needing to enable it. Is there any formats where this would
be useful? Or how about just making av_guess_sample_aspect_ratio()
return 1:1 in case nothing better exists? It's called "guess" after all
and is used in ffplay/ffprobe only...
Thanks
Timo
More information about the ffmpeg-devel
mailing list