jiaaro/pydub

Unknown encoder 'pcm_s8le'

Opened this issue · 1 comments

Steps to reproduce

File "myconverter.py", line 120, in process
audio = AudioSegment.from_wav(filepath_wav)
File "/usr/local/lib/python2.7/dist-packages/pydub/audio_segment.py", line 719, in from_wav
return cls.from_file(file, 'wav', parameters)
File "/usr/local/lib/python2.7/dist-packages/pydub/audio_segment.py", line 695, in from_file
p.returncode, p_err))
pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1

Output from ffmpeg/avlib:
..............................................................................
Guessed Channel Layout for Input Stream #0.0 : mono Input #0, wav, from './pdf/vmessages/2018-08-20 17:44:25_034_Outside Caller 08-20-18 13h44.WAV':
Duration: 00:00:17.31, bitrate: 64 kb/s
Stream #0:0: Audio: pcm_mulaw ([7][0][0][0] / 0x0007), 8000 Hz, 1 channels, s16, 64 kb/s Unknown encoder 'pcm_s8le'

Expected behavior

I'm attempting to convert a voicemail audio file to another format. This stopped working some time last week (8/13-8/17).

Actual behavior

Line 672 in audio_segment.py (acodec = 'pcm_s%dle' % bits_per_sample) uses 8 bits per sample, which then passes "-acodec pcm_s8le" to ffmpeg, which is an unsupported encoder per "ffmpeg -encoders".

Your System configuration

  • Python version: 2.7.12
  • Pydub version: 0.22.1
  • ffmpeg or avlib?: ffmpeg
  • ffmpeg/avlib version: 2.8.14-0ubuntu0.16.04.1

Is there an audio file you can include to help us reproduce?

VM-Extension 229 08-20-18 15h40.zip

Hello,

I ran into a issue with this update where it only works for mono wav files, I tried to use from wav with a stereo file and got a CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1.

Here is the file info for my stereo wave file:

avprobe version 9.20-6:9.20-0ubuntu0.14.04.1, Copyright (c) 2007-2014 the Libav developers
built on Dec 7 2016 21:22:31 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
[wav @ 0x1793c00] max_analyze_duration reached
Input #0, wav, from 'testing.wav':
Duration: 00:01:45.52, bitrate: 128 kb/s
Stream #0.0: Audio: pcm_mulaw, 8000 Hz, 2 channels, s16, 128 kb/s

avprobe output

[format]
filename=testing.wav
nb_streams=1
format_name=wav
format_long_name=WAV / WAVE (Waveform Audio)
start_time=N/A
duration=105.520000
size=1688364.000000
bit_rate=128003.000000

[streams.stream.0]
index=0
codec_name=pcm_mulaw
codec_long_name=PCM mu-law
codec_type=audio
codec_time_base=1/8000
codec_tag_string=[7][0][0][0]
codec_tag=0x0007
sample_rate=8000.000000
channels=2
bits_per_sample=8
avg_frame_rate=0/0
bit_rate=128000.000000
time_base=1/8000
start_time=N/A
duration=105.520000

This file would try to decode for pcm_s8 when i would actually need pcm_s16le. I added a work around in for my project where the bits_per_sample gets update before the check based on the number of channels

678 channels = audio_streams[0]['channels']
679 . if channels > 1:
680 bits_per_sample = bits_per_sample * channels

Let me know if this doesn't make any sense or if you have any questions.