Crash when decoding this file
Created by: brglng
Overview
PyAV crashes when decoding the attached file.
Expected behavior
PyAV should throw an exception for files that cannot be decoded.
Actual behavior
PyAV crashes Python.
Traceback:
Could not find codec parameters for stream 0 (Audio: none, 0 channels): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
zsh: segmentation fault (core dumped) ./pyav-test.py wKgJoFpLeY6Aq4m8ADbC_Q3Lcec358.m4a
Reproduction
Use the following code for decoding.
import sys
import av
in_file = open(sys.argv[1], 'rb')
out_file = open('out.pcm', 'wb')
resampler = av.AudioResampler(format='fltp', layout='mono', rate=16000)
container = av.open(in_file)
stream = next(s for s in container.streams if s.type == 'audio')
for packet in container.demux(stream):
try:
for frame in packet.decode():
frame.pts = None
out_frame = resampler.resample(frame)
if out_frame is not None:
plane = out_frame.planes[0]
nbytes = 4 * out_frame.samples
with memoryview(plane) as m:
l = 0
while l < nbytes:
l += out_file.write(m[l:nbytes])
except av.InvalidDataError as e:
sys.stderr.write(f'{e}\n')
Versions
- OS: Ubuntu 20.04
- PyAV runtime:
PyAV v8.0.2
git origin: git@github.com:PyAV-Org/PyAV
git commit: v8.0.2
library configuration: --disable-doc --disable-static --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-shared --enable-version3 --enable-zlib --prefix=/tmp/vendor
library license: GPL version 3 or later
libavcodec 58. 54.100
libavdevice 58. 8.100
libavfilter 7. 57.100
libavformat 58. 29.100
libavutil 56. 31.100
libswresample 3. 5.100
libswscale 5. 5.100
- PyAV build: pypi version
- FFmpeg:
ffmpeg version 4.2.2-1ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Research
I have done the following:
-
Checked the PyAV documentation -
Searched on Google -
Searched on Stack Overflow -
Looked through old GitHub issues -
Asked on PyAV Gitter -
... and waited 72 hours for a response.
Additional context
The problematic file is in the attached archive.