[FFmpeg-devel] Return value of av_log_format_line

Andreas Weis der_ghulbus at ghulbus-inc.de
Sun Apr 17 13:18:42 CEST 2016


Hi everyone!

I was trying to use a custom log callback and noticed that this pretty
much requires using av_log_format_line(), as the interpretation of the
format string is not trivial.

Unfortunately this approach offers no way of determining the size of the
output buffer for the log message. Typically in such a situation, one
would do two calls to snprintf - one with the buffer set to NULL which
then gives the required buffer size as a return value and then a second
call to perform the actual copy of the message.

I noticed that ffmpeg internally simply uses a hardcoded buffer size of
1024, which might be fine for most cases, but probably not all.

My question is, could we change the return value of av_log_format_line
(which currently returns void) to returns the number of characters
written to its `line` argument, or the number of characters which would
have been written if that argument is set to NULL?

Since av_log_format_line calls snprintf internally, that might be as
trivial as just forwarding the return value from that call.

Thanks & regards,
Andreas


More information about the ffmpeg-devel mailing list