question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1

See original GitHub issue

I’m having trouble getting pydub to work. The error message is listed below. I’ve reported the issue in detail on StackOverflow: here. I think this is an issue with ffmpeg, but honestly, I cant tell whether avlib or ffmpeg are running here. Is there a way to determine which library is being used?

In[5]: pydub.AudioSegment.from_file(".../sensorlog_2017-02-03_12-50-25-345_Dev26c5_Loc27_TypeAUDIO.m4a", "aac")
Traceback (most recent call last):
  File "...anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-5-607e3f2a62c3>", line 1, in <module>
    pydub.AudioSegment.from_file(".../sensorlog_2017-02-03_12-50-25-345_Dev26c5_Loc27_ActvEatingAT-DrinkingAT_TypeAUDIO.m4a", "aac")
  File ".../anaconda2/lib/python2.7/site-packages/pydub/audio_segment.py", line 472, in from_file
    raise CouldntDecodeError("Decoding failed. ffmpeg returned error code: {0}\n\nOutput from ffmpeg/avlib:\n\n{1}".format(p.returncode, p_err))
CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1
Output from ffmpeg/avlib:
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[aac @ 0x7f8485002e00] channel element 3.14 is not allocated
[aac @ 0x7f8485002e00] Sample rate index in program config element does not match the sample rate index configured by the container.
[aac @ 0x7f8485002e00] decode_pce: Input buffer exhausted before END element found
[aac @ 0x7f8485002e00] More than one AAC RDB per ADTS frame is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[aac @ 0x7f8485002e00] channel element 2.9 is not allocated
[aac @ 0x7f8485002200] decoding for stream 0 failed
[aac @ 0x7f8485002200] Estimating duration from bitrate, this may be inaccurate
[aac @ 0x7f8485002200] Could not find codec parameters for stream 0 (Audio: aac (LC), 4.0, fltp, 213 kb/s): unspecified sample rate
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, aac, from '/var/folders/cm/1r6x6rbj7hn_51qvfjzj7nx80000gn/T/tmpZyPq5d':
  Duration: 00:00:00.57, bitrate: 213 kb/s
    Stream #0:0: Audio: aac (LC), 4.0, fltp, 213 kb/s
[abuffer @ 0x7f8484d01480] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
    Last message repeated 3 times
[abuffer @ 0x7f8484d01480] Error setting option time_base to value 1/0.
[graph 0 input from stream 0:0 @ 0x7f8484d01580] Error applying options to the filter.
Error opening filters!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
jiaarocommented, Feb 4, 2017

You can manually assign to AudioSegment.converter the path to the binary if you like:

from pydub import AudioSegment
from pydub.utils import which

AudioSegment.converter = which("ffmpeg")

Also… I was able to decode your file using “mp4” as the format:

sound = AudioSegment.from_file("./sensorlog.m4a", format="mp4")

the file does seem to contain AAC audio, but the container format is mpeg4

In [1]: from pydub.utils import mediainfo
In [2]: mediainfo("./sensorlog.m4a")
Out[2]:
{u'DISPOSITION': {u'attached_pic': u'0',
  u'clean_effects': u'0',
  u'comment': u'0',
  u'default': u'1',
  u'dub': u'0',
  u'forced': u'0',
  u'hearing_impaired': u'0',
  u'karaoke': u'0',
  u'lyrics': u'0',
  u'original': u'0',
  u'timed_thumbnails': u'0',
  u'visual_impaired': u'0'},
 u'TAG': {u'com.android.version': u'7.0',
  u'compatible_brands': u'isommp42',
  u'creation_time': u'2017-02-03T20:50:33.000000Z',
  u'handler_name': u'SoundHandle',
  u'language': u'eng',
  u'major_brand': u'mp42',
  u'minor_version': u'0'},
 u'avg_frame_rate': u'0/0',
 u'bit_rate': u'15539',
 u'bits_per_raw_sample': u'N/A',
 u'bits_per_sample': u'0',
 u'channel_layout': u'mono',
 u'channels': u'1',
 u'codec_long_name': u'AAC (Advanced Audio Coding)',
 u'codec_name': u'aac',
 u'codec_tag': u'0x6134706d',
 u'codec_tag_string': u'mp4a',
 u'codec_time_base': u'1/8000',
 u'codec_type': u'audio',
 u'duration': u'7.808000',
 u'duration_ts': u'62464',
 u'filename': u'/Users/jiaaro/Downloads/sensorlog_2017-02-03_12-50-25-345_Dev26c5_Loc27_ActvAppTesting_TypeAUDIO.m4a',
 u'format_long_name': u'QuickTime / MOV',
 u'format_name': u'mov,mp4,m4a,3gp,3g2,mj2',
 u'id': u'N/A',
 u'index': u'0',
 u'max_bit_rate': u'12200',
 u'nb_frames': u'61',
 u'nb_programs': u'0',
 u'nb_read_frames': u'N/A',
 u'nb_read_packets': u'N/A',
 u'nb_streams': u'1',
 u'probe_score': u'100',
 u'profile': u'LC',
 u'r_frame_rate': u'0/0',
 u'sample_fmt': u'fltp',
 u'sample_rate': u'8000',
 u'size': u'15167',
 u'start_pts': u'0',
 u'start_time': u'0.000000',
 u'time_base': u'1/8000'}
0reactions
kevinashawcommented, Feb 4, 2017

Okay, nevermind. Although the project default interpreter had been set properly, the run configuration has overridden the default setting and was using a completely different Python 2.7 instance. Sigh. Well, I learned more about python source and module directories. Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

CouldntDecodeError: Decoding failed. ffmpeg returned ...
I am using python= 3.9 , pydub=0.25.1 , audiosegment=0.23.0 . Thanks in advance for the help. Below is the error shown on the...
Read more >
Decoding failed. ffmpeg returned error code: 1 : r/learnpython
pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1. This code works on a 30 second wav file but not on a 10 ...
Read more >
How to use the pydub.exceptions.CouldntDecodeError ...
Use Snyk Code to scan source code in minutes - no build needed - and fix issues ... 0: raise CouldntDecodeError( "Decoding failed....
Read more >
Decoding failed. ffmpeg returned error code: 69
1 , audiosegment=0.23.0 . Thanks in advance for the help. Below is the error shown on the console. CouldntDecodeError Traceback (most recent call...
Read more >
Python报错-pydub.exceptions.CouldntDecodeError ...
Python报错-pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1. zkw_1998 于 2020-04-27 10:18:06 发布 2975 收藏.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found