You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importavforchannelsinrange(1, 25):
forsample_formatinav.audio.frame.format_dtypes.keys():
frame=av.AudioFrame(format=sample_format, layout=str(channels) +'C', samples=1)
if (sample_format[-1] !='p'andlen(frame.planes) !=1) or (sample_format[-1] =='p'andlen(frame.planes) !=channels):
print(f"{sample_format}: {frame.layout.nb_channels}{len(frame.planes)}")
The expected outcome would be, that everything runs fine without printing anything.
In my case (PyAV 14.3.0, FFmpeg 7.1.1, Python 3.11.11, Debian based Linux) for all planar sample formats with more than 7 channels a line is printed. For 8 channels there are always 9 planes and for more than 8 channels the number of planes seems to be a random number >= number of channels (so it might just print no line by accident, but usually there are more planes than expected). The code uses just one sample and should run without problems, but with increasing number of channels or number of samples this will always crash the Python interpreter.
I think the reason for this bug is, that additional pointers for planar sample formats allocated by avcodec_fill_audio_frame are not handled correctly. [1]
In case this is considered just an academic bug: I tried to load an OGG Vorbis file with 8 channels and Python always crashed because of this.
PS: I'm iterating over all defined sample formats in format_dtypes and I think this dictionary needs an update, as there are additional sample formats for 64 bit signed integers (s64 and s64p) supported by libav since version 4. [2]
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Consider the following code:
The expected outcome would be, that everything runs fine without printing anything.
In my case (PyAV 14.3.0, FFmpeg 7.1.1, Python 3.11.11, Debian based Linux) for all planar sample formats with more than 7 channels a line is printed. For 8 channels there are always 9 planes and for more than 8 channels the number of planes seems to be a random number >= number of channels (so it might just print no line by accident, but usually there are more planes than expected). The code uses just one sample and should run without problems, but with increasing number of channels or number of samples this will always crash the Python interpreter.
I think the reason for this bug is, that additional pointers for planar sample formats allocated by avcodec_fill_audio_frame are not handled correctly. [1]
In case this is considered just an academic bug: I tried to load an OGG Vorbis file with 8 channels and Python always crashed because of this.
PS: I'm iterating over all defined sample formats in format_dtypes and I think this dictionary needs an update, as there are additional sample formats for 64 bit signed integers (s64 and s64p) supported by libav since version 4. [2]
[1] https://ffmpeg.org/doxygen/7.0/libavcodec_2utils_8c_source.html#l00369
[2] https://ffmpeg.org/doxygen/7.0/samplefmt_8h_source.html#l00055
Beta Was this translation helpful? Give feedback.
All reactions