[FFmpeg-devel] [PATCH v2 03/15] avfilter: add negotiation API for color space/range
Niklas Haas
ffmpeg at haasn.xyz
Thu Dec 14 16:09:51 EET 2023
> segfaults
>
> ./ffmpeg -f lavfi -i "amovie=fate-suite/wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv,asplit=3[out1][a][b]; [a]showwaves=s=340x240,pad=iw:ih*2[waves]; [b]showspectrum=s=340x240[spectrum]; [waves][spectrum] overlay=0:h [out0]" -t 0.1 -qscale 2 -bitexact /tmp/file-waves.avi
>
> Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
> 0x00005555557a7c07 in query_formats ()
> (gdb) bt
> #0 0x00005555557a7c07 in query_formats ()
> #1 0x00005555557a84d5 in avfilter_graph_config ()
> #2 0x000055555569ac0a in lavfi_read_header ()
> #3 0x0000555555a7bd61 in avformat_open_input ()
> #4 0x000055555574cb43 in ifile_open ()
> #5 0x0000555555763c49 in open_files.isra ()
> #6 0x0000555555765327 in ffmpeg_parse_options ()
> #7 0x00005555557442b4 in main ()
>
> (i can provide better backtrace if you cannot reproduce ...)
The culprit appears to be from this logic in formats.c:
case FF_FILTER_FORMATS_PASSTHROUGH:
case FF_FILTER_FORMATS_QUERY_FUNC:
type = ctx->nb_inputs ? ctx->inputs [0]->type :
ctx->nb_outputs ? ctx->outputs[0]->type : AVMEDIA_TYPE_VIDEO;
formats = ff_all_formats(type);
break;
In the case of an a/v filter (like avf_showspectrum), this incorrectly
determines the filter type as an audio filter, and therefore does not
run the default configuration logic on the video *output*.
Indeed, this logic would appear to break also in the case of
a (hypothetical) video->audio conversion filter, in which case channel
counts and samplerates would similarly fail to get assigned, because the
filter type would be incorrectly determined to be a video filter.
I think the correct resolution here would be to simply remove these
conditionals and always run ff_set_common_* in ff_default_query_formats.
They already explicitly ignore inputs/outputs of mismatching type, and
are a no-op if there is nothing to ref.
More information about the ffmpeg-devel
mailing list