pydub
pydub copied to clipboard
Android OGG audio files fail to decode
Steps to reproduce
We have an API for Speech-To-Text, we use websocket connection to create a file from the audio incoming from the mobile's microphone (iOS and Android).
from pydub import AudioSegment
import io
if audio_format == AudioFormat.OGG:
extension = "ogg"
container = io.BytesIO(file_buffer)
AudioSegment.from_file(container).export(name, format="ogg")
container.seek(0)
We tried as well with codec="libvorbis"
and codec="opus"
, the same issue.
Expected behavior
Should create the file properly. This code does not fail when the audio bytes are coming from iOS, only from Android.
Actual behavior
Throws an error trying to decode. Below the output:
E1129 13:09:05.272731793 70743 fork_posix.cc:76] Other threads are currently calling into gRPC, skipping fork() handlers
ERROR:root:Trying to create audio file with type: audio/ogg;codecs=opus - Decoding failed. ffmpeg returned error code: 1
Output from ffmpeg/avlib:
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
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
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[ogg @ 0x55751faa5280] CRC mismatch!
Last message repeated 2 times
[ogg @ 0x55751faa5280] Header processing failed: Invalid data found when processing input
[cache @ 0x55751faa5f00] Statistics, cache hits:0 cache misses:1
cache:pipe:0: Invalid data found when processing input
Your System configuration
- Python version: 3.8
- Pydub version: 0.25.1
- ffmpeg or avlib?: ffmpeg
- ffmpeg/avlib version: 4.4.2-0ubuntu0.22.04.1
Is there an audio file you can include to help us reproduce?
You can include the audio file in this issue - just put it in a zip file and drag/drop the zip file into the github issue.
I'm having this issue in Android and while using avlib/ffmpeg/ffprobe at my Linux laptop, here's a file that renders this issue. brazilian_good_song.zip