Hi,
I'm a happy user of ffmpeg -- thanks to everyone doing the hard work to
make it work so well for me.
I noticed that ffpresets are no longer honored when using it though and
spend some hours debugging ...
I think that this happens since commit
11a89bfe7bedc88980a178c565cc4d237e1ba0d8: AV options in presets no
longer are passed through.
The reason is this:
fftools/ffmpeg_opts.c
static int opt_preset(void *optctx, const char *opt, const char *arg)
{
//...
else if ((parse_option(o, key, value, options) < 0) &&
(opt_default_new(o, key, value) < 0)) {
//ERROR
}
}
Due to lazy evaluation, opt_default_new() only gets called of
parse_option() returns an error (<0).
This does NOT happen for unknown options (with option arguments), due to
fftools/cmdutils.c
int parse_option(void *optctx, const char *opt, const char *arg,
const OptionDef *options)
{
static const OptionDef opt_avoptions = {
.name = "AVOption passthrough",
.type = OPT_TYPE_FUNC,
.flags = OPT_FUNC_ARG,
.u.func_arg = opt_default,
};
//...
if (!po->name)
po = &opt_avoptions;
if (!po->name) {
// ERROR out
[...]
}
So the format/codec_opts in the preset files (passed e.g. with -vpre)
just get silently ignored.
There are a few ways to fix it, but neither is particularly nice.
1. Apparently opt_preset() assumed that parse_option() would return an
error for unknown options.
The second check for !po->name seems to be a remainder of that
previous logic ... and it can not possibly trigger currently.
If we just did error out on the first !po->name check, we'd fix
opt_preset().
However, we would need to audit all other parse_option() callers. At
least parse_options() would need to be adjusted,
possibly others.
2. We could adjust opt_preset() to test for the option to exist, call
parse_option() if it does and opt_default_new() otherwise.
find_option() is not currently exported; we'd probably add a wrapper
find_option_with_no() that also embeds the logic
to accept boolean options with a 'no' in front and use that both
from parse_option() and from opt_preset().
I have working prototype patches for both and I get the presets working
again.
Probably other approaches exist, I'm open to suggestions.
Overall the option handling code is not something that particularly
impressed me ...
Best,
--
Kurt Garloff
IT Consulting
Grafenwerthstr. 8
50937 Köln
[email protected]
+49-221-292772-0
+49-176-96969518
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]