[Libav-user] av_guess_format Returns Null

Mariah Smith mariah.cherice at gmail.com
Thu Oct 1 06:33:09 EEST 2020


I'm encoding audio data to .m4a files. I've got the usual container format
setting using av_guess_format function:

/* Guess the desired container format based on the file extension */
if (!((*output_format_context)->oformat = av_guess_format("m4a",
fileUrl, "audio/m4a"))) {

    __android_log_print(ANDROID_LOG_ERROR, FREQUENCY_ENGINE_TAG,
                        "Could not output file format!");
    goto cleanup;
}

About 1/30 times this call will be null and I will get the error message
you see. My question is, how do I resolve this? Again this happens 1/30
times so wondering what could be happening on that special time that it's
not working?

Second question is, according to documentation, this function should work
with any of the 3 arguments:


/**
 * Return the output format in the list of registered output formats
 * which best matches the provided parameters, or return NULL if
 * there is no match.
 *
 * @param short_name if non-NULL checks if short_name matches with the
 * names of the registered formats
 * @param filename if non-NULL checks if filename terminates with the
 * extensions of the registered formats
 * @param mime_type if non-NULL checks if mime_type matches with the
 * MIME type of the registered formats
 */
ff_const59 AVOutputFormat *av_guess_format(const char *short_name,
                                const char *filename,
                                const char *mime_type);

However, I'm seeing that it only works with the filename, as in when I keep
the "m4a" and "audio/m4a" and set filename to NULL, it errors out. Is this
expected? I was hoping that even when it NULLs like it does 1/30 times that
maybe providing all 3 arguments would help.

Thanks!
-- 
Mariah Smith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200930/561e9988/attachment.html>


More information about the Libav-user mailing list