#10990: "Assertion best_input >= 0 failed" IFF upsampling AND complex 
filtergraph
-------------------------------------+-------------------------------------
             Reporter:  Hunter       |                    Owner:  (none)
  Hogan                              |
                 Type:  defect       |                   Status:  new
             Priority:  normal       |                Component:
                                     |  undetermined
              Version:  git-master   |               Resolution:
             Keywords:  resampling   |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Changes (by Hunter Hogan):

 * keywords:   => resampling


Old description:

> Summary of the bug:
> If resampler is invoked at the start of the filtergraph to upsample, an
> error will be thrown at the very end despite the output file being
> successfully written. `Assertion best_input >= 0 failed at
> src/fftools/ffmpeg_filter.c:2075`
>
> How to reproduce:
> I reproduced it with a few different wav files, including a white noise
> file. All were stereo, however. Batch file and 22 logs attached. Only 4
> logs have the error. The other logs are to compare changing only one
> variable but not getting an error.
>
> These quick tests all have filtergraphs loaded from a textfile, and I
> don't think I tested it without a text file. These tests all use
> `-/complex_filter` syntax, but I got the same error with the old syntax.
>
> I did not test downsampling at the start of the filtergraph.
>
> I first encountered this a couple of weeks ago after building version 7.
> Prior to that, however, I don't think I ever had a filtergraph that
> included upsampling and multiple input and/or output pads, so I am not
> claiming the error was recently introduced.
>
> If I recall correctly, originally, FFmpeg would crash, throw the error,
> and not write a usable file. IIRC, the output file was the size I
> expected (in bytes), but nothing could read it: ffprobe, ffmpeg, Goldwave
> all said the file was garbage. I interpreted it to mean that the
> "headers" were malformed. (By "headers", I probably mean metadata, but I
> don't know the precise term here.)
>
> I worked around it by scripting:
> 1. upsample my input file to a temp output file
> 2. filter as I want, output to a new temp
> 3. downsample
>
> IIRC, it was necessary for me to downsample in a different filtergraph.
> But, it now looks like downsampling doesn't throw an error.
>
> Today, I rebuilt, and noticed the differences.
>
> {{{
> % FFmpeg -hide_banner -loglevel warning -stats
> -i test_input_44100_2ch.wav -/filter_complex test_filter.txt
> -map "[Z0Z_out]" -codec:a pcm_f32le
> "output\\test_input_44100_2ch.wav_filtergraph_192000.wav"
>
> }}}
>
> ffmpeg version: media autobuilder suite, built today on Windows
>
> {{{
> ffmpeg version N-115035-g192f5b58b7-gb7debef3cc+4 Copyright (c) 2000-2024
> the FFmpeg developers
> built with gcc 13.2.0 (Rev6, Built by MSYS2 project)
> configuration:  --pkg-config=pkgconf --cc='ccache gcc' --cxx='ccache g++'
> --ld='ccache g++' --extra-cxxflags=-fpermissive --extra-cflags=-Wno-int-
> conversion --disable-autodetect --enable-amf --enable-bzlib --enable-
> d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-zlib
> --enable-sdl2 --enable-libmp3lame --enable-libopus --enable-libvorbis
> --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d
> --enable-libaom --disable-debug --enable-libfdk-aac --enable-fontconfig
> --enable-libass --enable-libfreetype --enable-libmysofa --enable-
> libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
> --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora
> --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-
> libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl
> --enable-avisynth --enable-libxvid --enable-libopenmpt --enable-version3
> --enable-librav1e --enable-libgsm --enable-libvmaf --enable-libsvtav1
> --enable-chromaprint --enable-frei0r --enable-libaribb24 --enable-libbs2b
> --enable-libcaca --enable-libcdio --enable-libflite --enable-libfribidi
> --enable-libgme --enable-libilbc --enable-libsvthevc --enable-libsvtvp9
> --enable-libkvazaar --enable-libmodplug --enable-librtmp --enable-
> librubberband --enable-libtesseract --enable-libxavs --enable-libzmq
> --enable-libzvbi --enable-openal --enable-libcodec2 --enable-ladspa
> --enable-libglslang --enable-vulkan --enable-libdavs2 --enable-libxavs2
> --enable-libuavs3d --enable-opengl --enable-libopenh264 --enable-
> libharfbuzz --enable-libfontconfig --enable-openssl --extra-
> cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DCACA_STATIC --extra-
> cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_NODLL --extra-
> cflags=-DZMQ_STATIC --extra-libs=-lpsapi --extra-cflags=-DLIBXML_STATIC
> --extra-libs=-liconv --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB
> --enable-nonfree --extra-cflags=-DAL_LIBTYPE_STATIC --extra-
> cflags='-IC:/apps/media-autobuild_suite/local64/include' --extra-
> cflags='-IC:/apps/media-autobuild_suite/local64/include/AL'
> libavutil      59. 16.101 / 59. 16.101
> libavcodec     61.  5.103 / 61.  5.103
> libavformat    61.  3.103 / 61.  3.103
> libavdevice    61.  2.100 / 61.  2.100
> libavfilter    10.  2.101 / 10.  2.101
> libswscale      8.  2.100 /  8.  2.100
> libswresample   5.  2.100 /  5.  2.100
> libpostproc    58.  2.100 / 58.  2.100
> }}}

New description:

 Summary of the bug:
 If resampler is invoked at the start of the filtergraph to upsample, an
 error will be thrown at the very end despite the output file being
 successfully written. `Assertion best_input >= 0 failed at
 src/fftools/ffmpeg_filter.c:2075`

 ----

 == [edit] To reproduce, copy/paste
 {{{
 FFmpeg -y -hide_banner -loglevel warning -stats ^
 -f lavfi -i anoisesrc=d=533:c=pink:r=44100:a=0.5 ^
 -filter_complex
 
[0]aresample=192000,asplit[in1][b0];[b0]atrim=start_sample=146155:end_sample=655680,asetpts
 =PTS-
 STARTPTS,afade=in:ns=970:curve=squ[TRIM0];[in1]anullsink;[TRIM0]anull[Z0Z_out]
 ^
 -ar 44100 -map "[Z0Z_out]" -codec:a pcm_f32le ^
 "anoisesrc_filtergraph_aresample_44100.wav"
 }}}

 But, no error with:
 {{{
 FFmpeg -f lavfi -i anoisesrc=d=533:c=pink:r=44100:a=0.5 ^
 -filter_complex
 [0]aresample=192000[b0];[b0]atrim=start_sample=146155:end_sample=655680,asetpts
 =PTS-STARTPTS,afade=in:ns=970:curve=squ[Z0Z_out] ^
 -ar 44100 -map "[Z0Z_out]" -codec:a pcm_f32le ^
 "anoisesrc_aresample.wav"
 }}}

 Build:
 {{{
 ffmpeg version N-115666-gae00db87ca-g417957ec5e+3 Copyright (c) 2000-2024
 the FFmpeg developers
   built with gcc 14.1.0 (Rev3, Built by MSYS2 project)
   configuration:  --pkg-config=pkgconf --cc='ccache gcc' --cxx='ccache
 g++' --ld='ccache g++' --extra-cxxflags=-fpermissive --extra-cflags=-Wno-
 int-conversion --disable-autodetect --enable-amf --enable-bzlib --enable-
 d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-zlib
 --enable-sdl2 --enable-libmp3lame --enable-libopus --enable-libvorbis
 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d
 --enable-libaom --disable-debug --enable-libfdk-aac --enable-fontconfig
 --enable-libass --enable-libfreetype --enable-libmysofa --enable-
 libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora
 --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-
 libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl
 --enable-avisynth --enable-libxvid --enable-libopenmpt --enable-version3
 --enable-librav1e --enable-libsrt --enable-libgsm --enable-libvmaf
 --enable-libsvtav1 --enable-chromaprint --enable-frei0r --enable-
 libaribb24 --enable-libbs2b --enable-libcaca --enable-libcdio --enable-
 libflite --enable-libfribidi --enable-libgme --enable-libilbc --enable-
 libsvthevc --enable-libsvtvp9 --enable-libkvazaar --enable-libmodplug
 --enable-librist --enable-librtmp --enable-librubberband --enable-
 libtesseract --enable-libxavs --enable-libzmq --enable-libzvbi --enable-
 openal --enable-libcodec2 --enable-ladspa --enable-libglslang --enable-
 vulkan --enable-libdavs2 --enable-libxavs2 --enable-libuavs3d --enable-
 libplacebo --enable-libjxl --enable-opencl --enable-opengl --enable-
 libopenh264 --enable-libharfbuzz --enable-libfontconfig --enable-openssl
 --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DCACA_STATIC --extra-
 cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_NODLL --extra-
 cflags=-DZMQ_STATIC --extra-libs=-lpsapi --extra-cflags=-DLIBXML_STATIC
 --extra-libs=-liconv --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB
 --enable-nonfree --extra-cflags=-DAL_LIBTYPE_STATIC --extra-
 cflags='-IC:/apps/media-autobuild_suite/local64/include' --extra-
 cflags='-IC:/apps/media-autobuild_suite/local64/include/AL'
   libavutil      59. 21.100 / 59. 21.100
   libavcodec     61.  7.100 / 61.  7.100
   libavformat    61.  3.104 / 61.  3.104
   libavdevice    61.  2.100 / 61.  2.100
   libavfilter    10.  2.102 / 10.  2.102
   libswscale      8.  2.100 /  8.  2.100
   libswresample   5.  2.100 /  5.  2.100
   libpostproc    58.  2.100 / 58.  2.100
 }}}

 ----

 == Previous ramblings:
 How to reproduce:
 I reproduced it with a few different wav files, including a white noise
 file. All were stereo, however. Batch file and 22 logs attached. Only 4
 logs have the error. The other logs are to compare changing only one
 variable but not getting an error.

 These quick tests all have filtergraphs loaded from a textfile, and I
 don't think I tested it without a text file. These tests all use
 `-/complex_filter` syntax, but I got the same error with the old syntax.

 I did not test downsampling at the start of the filtergraph.

 I first encountered this a couple of weeks ago after building version 7.
 Prior to that, however, I don't think I ever had a filtergraph that
 included upsampling and multiple input and/or output pads, so I am not
 claiming the error was recently introduced.

 If I recall correctly, originally, FFmpeg would crash, throw the error,
 and not write a usable file. IIRC, the output file was the size I expected
 (in bytes), but nothing could read it: ffprobe, ffmpeg, Goldwave all said
 the file was garbage. I interpreted it to mean that the "headers" were
 malformed. (By "headers", I probably mean metadata, but I don't know the
 precise term here.)

 I worked around it by scripting:
 1. upsample my input file to a temp output file
 2. filter as I want, output to a new temp
 3. downsample

 IIRC, it was necessary for me to downsample in a different filtergraph.
 But, it now looks like downsampling doesn't throw an error.

 Today, I rebuilt, and noticed the differences.

 {{{
 % FFmpeg -hide_banner -loglevel warning -stats
 -i test_input_44100_2ch.wav -/filter_complex test_filter.txt
 -map "[Z0Z_out]" -codec:a pcm_f32le
 "output\\test_input_44100_2ch.wav_filtergraph_192000.wav"

 }}}

 ffmpeg version: media autobuilder suite, built today on Windows

 {{{
 ffmpeg version N-115035-g192f5b58b7-gb7debef3cc+4 Copyright (c) 2000-2024
 the FFmpeg developers
 built with gcc 13.2.0 (Rev6, Built by MSYS2 project)
 configuration:  --pkg-config=pkgconf --cc='ccache gcc' --cxx='ccache g++'
 --ld='ccache g++' --extra-cxxflags=-fpermissive --extra-cflags=-Wno-int-
 conversion --disable-autodetect --enable-amf --enable-bzlib --enable-
 d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-zlib
 --enable-sdl2 --enable-libmp3lame --enable-libopus --enable-libvorbis
 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d
 --enable-libaom --disable-debug --enable-libfdk-aac --enable-fontconfig
 --enable-libass --enable-libfreetype --enable-libmysofa --enable-
 libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora
 --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-
 libwebp --enable-libxml2 --enable-libzimg --enable-libshine --enable-gpl
 --enable-avisynth --enable-libxvid --enable-libopenmpt --enable-version3
 --enable-librav1e --enable-libgsm --enable-libvmaf --enable-libsvtav1
 --enable-chromaprint --enable-frei0r --enable-libaribb24 --enable-libbs2b
 --enable-libcaca --enable-libcdio --enable-libflite --enable-libfribidi
 --enable-libgme --enable-libilbc --enable-libsvthevc --enable-libsvtvp9
 --enable-libkvazaar --enable-libmodplug --enable-librtmp --enable-
 librubberband --enable-libtesseract --enable-libxavs --enable-libzmq
 --enable-libzvbi --enable-openal --enable-libcodec2 --enable-ladspa
 --enable-libglslang --enable-vulkan --enable-libdavs2 --enable-libxavs2
 --enable-libuavs3d --enable-opengl --enable-libopenh264 --enable-
 libharfbuzz --enable-libfontconfig --enable-openssl --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DCACA_STATIC --extra-
 cflags=-DMODPLUG_STATIC --extra-cflags=-DCHROMAPRINT_NODLL --extra-
 cflags=-DZMQ_STATIC --extra-libs=-lpsapi --extra-cflags=-DLIBXML_STATIC
 --extra-libs=-liconv --disable-w32threads --extra-cflags=-DKVZ_STATIC_LIB
 --enable-nonfree --extra-cflags=-DAL_LIBTYPE_STATIC --extra-
 cflags='-IC:/apps/media-autobuild_suite/local64/include' --extra-
 cflags='-IC:/apps/media-autobuild_suite/local64/include/AL'
 libavutil      59. 16.101 / 59. 16.101
 libavcodec     61.  5.103 / 61.  5.103
 libavformat    61.  3.103 / 61.  3.103
 libavdevice    61.  2.100 / 61.  2.100
 libavfilter    10.  2.101 / 10.  2.101
 libswscale      8.  2.100 /  8.  2.100
 libswresample   5.  2.100 /  5.  2.100
 libpostproc    58.  2.100 / 58.  2.100
 }}}

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10990#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
_______________________________________________
FFmpeg-trac mailing list
FFmpeg-trac@avcodec.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-trac

To unsubscribe, visit link above, or email
ffmpeg-trac-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to