[PATCH v2] Add "sar" alias to "aspect" option of video encoders
It is impossible to pass "aspect" parameter to encoder from ffmpeg CLI because option from lavc/options_table.h is eclipsed by option with same name in ffmpeg_opt.c, which has different meaning (DAR, not SAR). --- v2: Updated tests reference results as suggested by Michael Niedermayer. libavcodec/options_table.h | 1 + tests/ref/fate/api-mjpeg-codec-param | 2 ++ tests/ref/fate/api-png-codec-param | 2 ++ 3 files changed, 5 insertions(+) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index d29996f..8efb889 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -254,6 +254,7 @@ static const AVOption avcodec_options[] = { {"median", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"}, #endif {"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E}, +{"sar", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E}, {"debug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"}, {"pict", "picture info", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"}, {"rc", "rate control", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_RC }, INT_MIN, INT_MAX, V|E, "debug"}, diff --git a/tests/ref/fate/api-mjpeg-codec-param b/tests/ref/fate/api-mjpeg-codec-param index 26822fd..c67d1b1 100644 --- a/tests/ref/fate/api-mjpeg-codec-param +++ b/tests/ref/fate/api-mjpeg-codec-param @@ -62,6 +62,7 @@ stream=0, decode=0 bits_per_coded_sample=0 pred=0 aspect=180/180 + sar=180/180 debug=0x00000000 vismv=0x00000000 cmp=0 @@ -218,6 +219,7 @@ stream=0, decode=1 bits_per_coded_sample=0 pred=0 aspect=180/180 + sar=180/180 debug=0x00000000 vismv=0x00000000 cmp=0 diff --git a/tests/ref/fate/api-png-codec-param b/tests/ref/fate/api-png-codec-param index 46ac8eb..bd53441 100644 --- a/tests/ref/fate/api-png-codec-param +++ b/tests/ref/fate/api-png-codec-param @@ -62,6 +62,7 @@ stream=0, decode=0 bits_per_coded_sample=0 pred=0 aspect=2835/2835 + sar=2835/2835 debug=0x00000000 vismv=0x00000000 cmp=0 @@ -218,6 +219,7 @@ stream=0, decode=1 bits_per_coded_sample=0 pred=0 aspect=2835/2835 + sar=2835/2835 debug=0x00000000 vismv=0x00000000 cmp=0 -- 2.8.2
On Wed, May 04, 2016 at 03:06:31AM +0300, Andrey Utkin wrote:
It is impossible to pass "aspect" parameter to encoder from ffmpeg CLI because option from lavc/options_table.h is eclipsed by option with same name in ffmpeg_opt.c, which has different meaning (DAR, not SAR). ---
v2: Updated tests reference results as suggested by Michael Niedermayer.
libavcodec/options_table.h | 1 + tests/ref/fate/api-mjpeg-codec-param | 2 ++ tests/ref/fate/api-png-codec-param | 2 ++ 3 files changed, 5 insertions(+)
doesnt this require an update to teh docs ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire
On Wed, May 04, 2016 at 05:07:10AM +0200, Michael Niedermayer wrote:
doesnt this require an update to teh docs ?
Indeed, thanks for commenting. But I wonder how should I format reference to "aspect" correctly and pretty. Now I have come up with this, which I think is not perfect. Any help is very appreciated. --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -456,6 +456,9 @@ Possible values: @item aspect @var{rational number} (@emph{encoding,video}) Set sample aspect ratio. +@item sar @var{rational number} (@emph{encoding,video}) +Set sample aspect ratio. Alias to @var{aspect}. + @item debug @var{flags} (@emph{decoding/encoding,audio,video,subtitles}) Print specific debug info.
On Wed, May 04, 2016 at 08:40:04AM +0300, Andrey Utkin wrote:
On Wed, May 04, 2016 at 05:07:10AM +0200, Michael Niedermayer wrote:
doesnt this require an update to teh docs ?
Indeed, thanks for commenting.
But I wonder how should I format reference to "aspect" correctly and pretty. Now I have come up with this, which I think is not perfect. Any help is very appreciated.
--- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -456,6 +456,9 @@ Possible values: @item aspect @var{rational number} (@emph{encoding,video}) Set sample aspect ratio.
+@item sar @var{rational number} (@emph{encoding,video}) +Set sample aspect ratio. Alias to @var{aspect}.
i think this is ok if noone has a better idea (i dont have one) [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus
Andrey Utkin <andrey_utkin <at> fastmail.com> writes:
It is impossible to pass "aspect" parameter to encoder from ffmpeg CLI because option from lavc/options_table.h is eclipsed by option with same name in ffmpeg_opt.c, which has different meaning (DAR, not SAR).
Wasn't the old behaviour intended because it assured you cannot pass contradicting options to the libraries via ffmpeg? Carl Eugen
On Thu, Jul 14, 2016 at 05:27:08PM +0000, Carl Eugen Hoyos wrote:
Andrey Utkin <andrey_utkin <at> fastmail.com> writes:
It is impossible to pass "aspect" parameter to encoder from ffmpeg CLI because option from lavc/options_table.h is eclipsed by option with same name in ffmpeg_opt.c, which has different meaning (DAR, not SAR).
Wasn't the old behaviour intended because it assured you cannot pass contradicting options to the libraries via ffmpeg?
I don't think so. Proper way to avoid contradiction is explicit check in code. It is a usability flaw to be unable to pass certain encoder option in CLI while all other are passed finely.
2016-08-08 20:58 GMT+02:00 Andrey Utkin <andrey_utkin@fastmail.com>:
On Thu, Jul 14, 2016 at 05:27:08PM +0000, Carl Eugen Hoyos wrote:
Andrey Utkin <andrey_utkin <at> fastmail.com> writes:
It is impossible to pass "aspect" parameter to encoder from ffmpeg CLI because option from lavc/options_table.h is eclipsed by option with same name in ffmpeg_opt.c, which has different meaning (DAR, not SAR).
Wasn't the old behaviour intended because it assured you cannot pass contradicting options to the libraries via ffmpeg?
I don't think so. Proper way to avoid contradiction is explicit check in code.
Where can this be checked?
It is a usability flaw to be unable to pass certain encoder option in CLI while all other are passed finely.
But in which situation (which command line) could you not set the aspect correctly before your patch? Carl Eugen
participants (4)
-
Andrey Utkin -
Carl Eugen Hoyos -
Carl Eugen Hoyos -
Michael Niedermayer