mlt icon indicating copy to clipboard operation
mlt copied to clipboard

avformat: vbr parameter should also accept integer values

Open gsnoff opened this issue 1 year ago • 1 comments

Currently when I specify vbr=4 while using the libfdk_aac encoder, something like this happens:

$ melt -consumer avformat:bar.mp4 vcodec=h264_vaapi vprofile_high vq=25 compression_level=1 acodec=libfdk_aac vbr=4 movflags=+faststart foo.mlt
...
[libfdk_aac @ 0x7f4118312c40] [Eval @ 0x7f411d412eb0] Undefined constant or missing '(' in 'on'
[libfdk_aac @ 0x7f4118312c40] Unable to parse option value "on"
[libfdk_aac @ 0x7f41183130c0] [Eval @ 0x7f411d412f20] Undefined constant or missing '(' in 'on'
[libfdk_aac @ 0x7f41183130c0] Unable to parse option value "on"
[libfdk_aac @ 0x7f4118312c40] VBR quality 472 out of range, should be 1-5
[libfdk_aac @ 0x7f4118312c40] Note, the VBR setting is unsupported and only works with some parameter combinations

Apparently MLT attempts to represent any non-false value for the vbr parameter as on boolean value, before passing to libavformat. This may be correct for codecs like libopus, which do expect a boolean value in this parameter. However the libfdk_aac codec actually expects an integer there (see https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_vbr).

(MLT 7.22.0, Debian GNU/Linux testing 13 'trixie', with Deb Multimedia Packages, Linux 6.6.15)

gsnoff avatar Apr 30 '24 09:04 gsnoff

MLT (see src/modules/avformat/consumer_avformat.c) does not treat "vbr" as boolean. It handles it generically by supplying the value as a string using av_opt_set(). Many AVOptions take a numeric or string value. I do not know why FFmpeg has a problem converting a string to an integer, which is rather trivial compared to converting video! ;-) Search that code file, and there is no "vbr" or "on" string in it! So, maybe this is some bug internal to your FFmpeg version. (I do not use libfdk_aac anymore to test this myself.)

ddennedy avatar Apr 30 '24 15:04 ddennedy