AviSynth / AviSynthPlus

AviSynth with improvements
http://avs-plus.net
963 stars 73 forks source link

Using Overlay results in error Assertion `IsArray() && index>=0 && index<array_size' failed #370

Closed Andreii closed 11 months ago

Andreii commented 11 months ago

Hello,

I am trying to use Overlay function in AviSynthPlus and I am getting the following error: ffmpeg: ../avs_core/core/interface.cpp:871: const AVSValue& AVSValue::OPERATOR_INDEX(int) const: Assertion 'IsArray() && index>=0 && index<array_size' failed.

I took the test avs script from the documentation here: http://avisynth.nl/index.php/Overlay

Am I doing something wrong?

Thank you in advance !

Environment:

Installation aviSynthPlus:

apt update && apt install -y libdevil-dev build-essential cmake git ninja-build checkinstall nasm libsdl2-dev
git clone https://github.com/AviSynth/AviSynthPlus && \
cd AviSynthPlus && \
mkdir avisynth-build && \
cd avisynth-build && \

cmake ../ -G Ninja && \
ninja && \
    checkinstall --pkgname=avisynth --pkgversion="$(grep -r \
    Version avs_core/avisynth.pc | cut -f2 -d " ")-$(date --rfc-3339=date | \
    sed 's/-//g')-git" --backup=no --deldoc=yes --delspec=yes --deldesc=yes \
    --strip=yes --stripso=yes --addso=yes --fstrans=no --default ninja install

Installation ffmpeg:

git clone https://git.videolan.org/git/ffmpeg.git
cd ffmpeg

./configure --enable-gpl --enable-version3 \
    --disable-doc --disable-debug --enable-pic --enable-avisynth && \
make -j$(nproc) && \
make install

checkinstall --pkgname=ffmpeg --pkgversion="7:$(git rev-list \
--count HEAD)-g$(git rev-parse --short HEAD)" --backup=no --deldoc=yes \
--delspec=yes --deldesc=yes --strip=yes --stripso=yes --addso=yes \
--fstrans=no --default

Overlay test: test.avs

bg = ColorBars(512,384).ConvertToYUY2
text = BlankClip(bg)
return Overlay(bg, text, x=50, y=20, mode="blend", opacity=0.25)
root@781f82538b08:/ffmpeg# ffmpeg -i test.avs test.mov
ffmpeg version N-112453-ga7663c9604 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
  configuration: --enable-gpl --enable-version3 --disable-doc --disable-debug --enable-pic --enable-avisynth
  libavutil      58. 27.100 / 58. 27.100
  libavcodec     60. 30.102 / 60. 30.102
  libavformat    60. 15.100 / 60. 15.100
  libavdevice    60.  2.101 / 60.  2.101
  libavfilter     9. 11.100 /  9. 11.100
  libswscale      7.  4.100 /  7.  4.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
**ffmpeg: ../avs_core/core/interface.cpp:871: const AVSValue& AVSValue::OPERATOR_INDEX(int) const: Assertion `IsArray() && index>=0 && index<array_size' failed.**
Aborted (core dumped)
pinterf commented 11 months ago

Your build must be a debug avisynth build. Anyway, yes, such an assert should not be kicked, usually the arrayness is always checked in the internal code, before we access something as an array. (even if it is a single variable which is a one-element array, where only index=0 exists)

pinterf commented 11 months ago

Fixed on my system, I will commit it later this week (other changes are pending). The bug occured when ConvertToYUY2 was called. When there is no direct conversion path between the input color space and YUY2, first ConvertToYV16 is called internally. But ConvertToYV16 (ConvertToYUV422) has one more parameter (ChromaOutPlacement) than ConvertToYUY2 has, so there was a mismatch when passing only YUY2's 8 parameters while YV16 conversion expected 9 parameters.

Andreii commented 11 months ago

Hello @pinterf !

Thank you for your prompt response! And for the fast fix.

For future reference, how could I make a debug avisynth build? I saw I can remove "--disable-debug" in ffmpeg, what should I change for the aviSynthBuild?

pinterf commented 11 months ago

I'm not familiar with ninja, on Windows I'm using --config Release for my gcc builds In a context something like this:

cmake ..\AviSynthPlus -G "MinGW Makefiles" -DBUILD_DIRECTSHOWSOURCE:bool=off -DENABLE_PLUGINS:bool=on -DENABLE_INTEL_SIMD:bool=on
cmake --build . --config Release

By default it seems that you built a debug Avisynth, if you've seen the assert. if not, use --config Debug I guess.

qyot27 commented 11 months ago

You can configure the build type in the cmake line, -DCMAKE_BUILD_TYPE.

When not set by the project, CMAKE_BUILD_TYPE is an empty string, which probably does fall through to Debug in some circumstances. I could reproduce this with a default build, but not with -DCMAKE_BUILD_TYPE=Release.