[FFmpeg-devel] [PATCH 1/1] [RFC] ffprobe: report DAR even if SAR is undefined
Timo Teräs
timo.teras at iki.fi
Sun Apr 15 14:57:06 EEST 2018
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.
Normally undefined SAR means 1:1. E.g. in mov/mp4 files there's
'pasp' atom to explicitly define SAR. If that is not specified,
the video codec's SAR should be used. Should it be also undefined,
the SAR should be assumed to be 1:1. It makes sense to not change
SAR in the demux info, so ffmpeg can make copies with matching
atom structure and codec extra data. So the simplest way to
report DAR is assume SAR 1:1 when undefined.
Signed-off-by: Timo Teräs <timo.teras at iki.fi>
---
This applies on top of the previous DAR/SAR reporting fix:
https://ffmpeg.org/pipermail/ffmpeg-devel/2018-April/228141.html
For more details behind this patch, see:
https://ffmpeg.org/pipermail/ffmpeg-devel/2018-April/228146.html
This seemed to be the most simple and logical fix. Alternatively,
we could add a new 'effective_display_aspect_ratio' or add a flag
to enable this assumption if the existing functionality should be
kept unchanged. I felt this would be the most sensible thing to do.
I am happy this if there's a more desirable approach to the issue.
Hopefully this and the DAR/SAR reporting fix can be applied before
next release tag. Thanks for considering!
fftools/ffprobe.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 8b2a18b6b1..f7022bd3c2 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2523,15 +2523,15 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
if (sar.num) {
print_q("sample_aspect_ratio", sar, ':');
- av_reduce(&dar.num, &dar.den,
- par->width * sar.num,
- par->height * sar.den,
- 1024*1024);
- print_q("display_aspect_ratio", dar, ':');
} else {
print_str_opt("sample_aspect_ratio", "N/A");
- print_str_opt("display_aspect_ratio", "N/A");
+ sar = (AVRational){ 1, 1 };
}
+ av_reduce(&dar.num, &dar.den,
+ par->width * sar.num,
+ par->height * sar.den,
+ 1024*1024);
+ print_q("display_aspect_ratio", dar, ':');
s = av_get_pix_fmt_name(par->format);
if (s) print_str ("pix_fmt", s);
else print_str_opt("pix_fmt", "unknown");
--
2.17.0
More information about the ffmpeg-devel
mailing list