[FFmpeg-devel] [PATCH 1/2] lavf: fall back to a more meaningful log instance name

Stefano Sabatini stefasab at gmail.com
Sun Apr 2 22:06:35 EEST 2023


On date Thursday 2023-03-30 11:38:07 +0200, Anton Khirnov wrote:
> An uninitialized AVFormatContext instance with neither iformat nor
> oformat set will currently log as 'NULL', which is confusing and
> unhelpful. Print 'AVFormatContext' instead, which provides more
> information.
> 
> This happens e.g. if choosing an output format fails in
> avformat_alloc_output_context2().
> ---
>  libavformat/options.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/options.c b/libavformat/options.c
> index 22ad523b2d..e4a3aceed0 100644
> --- a/libavformat/options.c
> +++ b/libavformat/options.c
> @@ -44,7 +44,7 @@ static const char* format_to_name(void* ptr)
>      AVFormatContext* fc = (AVFormatContext*) ptr;
>      if(fc->iformat) return fc->iformat->name;
>      else if(fc->oformat) return fc->oformat->name;
> -    else return "NULL";
> +    else return fc->av_class->class_name;
>  }

Do you have an example to show? Anyway LGTM.


More information about the ffmpeg-devel mailing list