Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EOFError when loading Mp3 #50

Closed
chrisspen opened this issue Feb 14, 2014 · 7 comments
Closed

EOFError when loading Mp3 #50

chrisspen opened this issue Feb 14, 2014 · 7 comments

Comments

@chrisspen
Copy link

When I try to load audio from an mp3, it throws an EOFError.

>>> from pydub import AudioSegment
>>> audio_fn = 'test.mp3'
>>> audio = AudioSegment.from_mp3(audio_fn)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/project/.env/local/lib/python2.7/site-packages/pydub/audio_segment.py", line 248, in from_mp3
    return cls.from_file(file, 'mp3')
  File "/usr/local/project/.env/local/lib/python2.7/site-packages/pydub/audio_segment.py", line 237, in from_file
    obj = cls.from_wav(output)
  File "/usr/local/project/.env/local/lib/python2.7/site-packages/pydub/audio_segment.py", line 262, in from_wav
    return cls(data=file)
  File "/usr/local/project/.env/local/lib/python2.7/site-packages/pydub/audio_segment.py", line 58, in __init__
    raw = wave.open(StringIO(data), 'rb')
  File "/usr/lib/python2.7/wave.py", line 498, in open
    return Wave_read(f)
  File "/usr/lib/python2.7/wave.py", line 163, in __init__
    self.initfp(f)
  File "/usr/lib/python2.7/wave.py", line 128, in initfp
    self._file = Chunk(file, bigendian = 0)
  File "/usr/lib/python2.7/chunk.py", line 63, in __init__
    raise EOFError
EOFError

The specific file I used is http://gamesplusone.com/thebugle/thebugle035.mp3, which appears to be perfectly valid.

I'm using the current version on PyPI, pydub==0.8.3.

@chrisspen
Copy link
Author

After inspecting the code, this seems to be a problem with the pre-compiled version of ffmpeg in Ubuntu 12.04, which is failing with the error:

ffmpeg: relocation error: ffmpeg: symbol avformat_alloc_output_context2, version LIBAVFORMAT_53 not defined in file libavformat.so.53 with link time reference

After uninstalled the ffmpeg package and compiling it from scratch following https://trac.ffmpeg.org/wiki/UbuntuCompilationGuide, it seems to work fine.

This issue aside, it might be a good idea in audio_segment.py to change:

subprocess.call(ffmpeg_call, stderr=open(os.devnull))

to:

subprocess.call(ffmpeg_call, stderr=sys.stderr)

so the user can see a more direct error message. Not seeing that wasted a lot of my time.

@jiaaro
Copy link
Owner

jiaaro commented Feb 23, 2014

I wonder if there is a good way to make this user configurable. ffmpeg can be quite verbose and most of the time it's not useful information for pydub to output to stderr (showing the progress of the operation).

How would you feel about capturing ffmpeg's stderr and only outputting it to sys.stderr if ffmpeg returns a non-zero (error) status code.

@marcwebbie
Copy link
Contributor

What about logging? if the user is logging her application she will be able to see the log anyway.

@chrisspen
Copy link
Author

Checking the exit code for a non-zero value makes sense.

@Ratnaganadi
Copy link

Hi, I also have a problem with playing an mp3.

from pydub import AudioSegment

u=AudioSegment.from_mp3("yourself.mp3")
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.6-intel/egg/pydub/audio_segment.py", line 297, in from_mp3
File "build/bdist.macosx-10.6-intel/egg/pydub/audio_segment.py", line 284, in from_file
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 493, in call
return Popen(_popenargs, *_kwargs).wait()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in init
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

would anyone help me? Thanks!

@jiaaro
Copy link
Owner

jiaaro commented Mar 4, 2014

@Ratnaganadi It looks like you don't have ffmpeg installed, or if it is installed, pydub can't find it.

@jiaaro
Copy link
Owner

jiaaro commented Mar 4, 2014

@Ratnaganadi You may want to take a look at the Getting ffmpeg set up section of the read me :)

@jiaaro jiaaro closed this as completed May 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants