xiph / rav1e

The fastest and safest AV1 encoder.
BSD 2-Clause "Simplified" License
3.67k stars 250 forks source link

rav1e crashes with assertion failed while encoding from ffmpeg #2922

Open guidow opened 2 years ago

guidow commented 2 years ago

Describe the bug When encoding a long video with ffmpeg using librav1e codec, rav1e will crash after a long time of encoding with this message:

thread '<unnamed>' panicked at 'assertion failed: MV_LOW <= comp && comp <= MV_UPP', src/context/mod.rs:191:5
note: run with \`RUST_BACKTRACE=1\` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
Abgebrochen

To Reproduce On my machine, the crash is fully reproducible with this one particular video (not with others) when running the following command:

ffmpeg -i 2021-12-19\ 02-12-30.mkv -c:v librav1e -qp 130 -c:a libopus -b:a 128K -f matroska '2021-12-19 02-12-30 Starbase More Zone 3 Mining AV1 qp 130.mkv'

Unfortunately, reproducing it takes several weeks.

Expected behavior ffmpeg and rav1e should encode the video fully until the end without crashing.

Required Information Toolchain (if is a build problem):

$ cargo --version
cargo 1.58.0
$ rustc --version
rustc 1.58.1 (gentoo)
$ nasm --version # if on x86_64
ASM version 2.15.05 compiled on Oct  8 2020

Version:

$ rav1e --version
rav1e 0.5.1 (0.5.1) (release)

Operating system:

$ uname -a
Linux adams 5.15.23-gentoo #1 SMP Thu Feb 17 13:56:52 CET 2022 x86_64 AMD Ryzen 3 4300GE with Radeon Graphics AuthenticAMD GNU/Linux

Console Output Please paste the console output below if it is relevant,

Full console output: ``` $ time ffmpeg -i 2021-12-19\ 02-12-30.mkv -c:v librav1e -qp 130 -c:a libopus -b:a 128K -f matroska '2021-12-19 02-12-30 Starbase More Zone 3 Mining AV1 qp 130.mkv' ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 11.2.1 (Gentoo 11.2.1_p20220115 p4) 20220115 configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-4.4.1-r3/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --nm=x86_64-pc-linux-gnu-nm --strip=x86_64-pc-linux-gnu-strip --ranlib=x86_64-pc-linux-gnu-ranlib --pkg-config=x86_64-pc-linux-gnu-pkg-config --optflags='-march=native -O2 -pipe' --extra-libs= --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-optimizations --disable-libcelt --enable-nonfree --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=oss --disable-indev=jack --disable-indev=sndio --disable-outdev=oss --disable-outdev=sndio --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --enable-gnutls --disable-gmp --enable-gpl --disable-hardcoded-tables --enable-iconv --disable-libxml2 --disable-lzma --enable-network --disable-opencl --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl2 --enable-vaapi --disable-vdpau --disable-vulkan --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --disable-libv4l2 --enable-libpulse --disable-libdrm --disable-libjack --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libcodec2 --enable-libdav1d --disable-libfdk-aac --disable-libopenjpeg --disable-libbluray --disable-libgme --disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug --enable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libspeex --disable-libsrt --enable-librsvg --disable-ffnvcodec --enable-libvorbis --enable-libvpx --disable-libzvbi --disable-appkit --disable-libbs2b --disable-chromaprint --disable-cuda-llvm --disable-libflite --disable-frei0r --disable-libvmaf --disable-libfribidi --disable-fontconfig --disable-ladspa --disable-libass --disable-libtesseract --disable-lv2 --enable-libfreetype --disable-libvidstab --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-libvo-amrwbenc --enable-libmp3lame --disable-libkvazaar --enable-libaom --disable-libopenh264 --enable-librav1e --disable-libsnappy --disable-libsvtav1 --disable-libtheora --disable-libtwolame --disable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --disable-amf --disable-gnutls --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-vsx --disable-power8 --disable-amd3dnow --disable-amd3dnowext --disable-aesni --disable-avx --disable-avx2 --disable-fma3 --disable-fma4 --disable-sse3 --disable-ssse3 --disable-sse4 --disable-sse42 --disable-xop --cpu=host --disable-doc --disable-htmlpages --enable-manpages libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Input #0, matroska,webm, from '2021-12-19 02-12-30.mkv': Metadata: ENCODER : Lavf58.29.100 Duration: 04:15:28.75, start: 0.000000, bitrate: 6333 kb/s Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 2560x1440 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn, 120 tbc (default) Metadata: DURATION : 04:15:28.750000000 Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default) Metadata: title : Track1 DURATION : 04:15:28.725000000 Stream #0:2: Audio: aac (LC), 48000 Hz, stereo, fltp (default) Metadata: title : Track2 DURATION : 04:15:28.725000000 Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> av1 (librav1e)) Stream #0:1 -> #0:1 (aac (native) -> opus (libopus)) Press [q] to stop, [?] for help Output #0, matroska, to '2021-12-19 02-12-30 Starbase More Zone 3 Mining AV1 qp 130.mkv': Metadata: encoder : Lavf58.76.100 Stream #0:0: Video: av1 (AV01 / 0x31305641), yuv420p(tv, bt709, progressive), 2560x1440 [SAR 1:1 DAR 16:9], q=2-31, 60 fps, 1k tbn (default) Metadata: DURATION : 04:15:28.750000000 encoder : Lavc58.134.100 librav1e Stream #0:1: Audio: opus ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, stereo, flt, 128 kb/s (default) Metadata: title : Track1 DURATION : 04:15:28.725000000 encoder : Lavc58.134.100 libopus thread '' panicked at 'assertion failed: MV_LOW <= comp && comp <= MV_UPP', src/context/mod.rs:191:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace fatal runtime error: failed to initiate panic, error 5 Abgebrochen real 24025m26,343s user 23746m12,683s sys 62m38,480s ```
vibhoothi commented 2 years ago

Hi, Thanks for the bug-report, will it be possible to share the sample ?

guidow commented 2 years ago

Hi, Thanks for the bug-report, will it be possible to share the sample ?

I am currently uploading a version of the video with audio removed (for privacy reasons). I don't know how I would go about sharing just a sample, mostly because I have no idea what part of the original video causes the problem to surface.

Unfortunately, the original video is over 10GiB in size.

guidow commented 2 years ago

Hi, Thanks for the bug-report, will it be possible to share the sample ?

The sample (11GiB) can be downloaded from here:

https://unknownsite.de/recordings/rav1e_crashing_video_without_sound.mkv

For privacy reasons, I stripped the audio with this command:

ffmpeg -i 2021-12-19\ 02-12-30.mkv -map 0:0 -c:v copy rav1e_crashing_video_without_sound.mkv

I hope this won't make a difference for the bug, but since the video stream was copied with -c:v copy, it shouldn't.