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

AudioFileClip bombs on file read #158

Closed
ryanfox opened this issue Apr 15, 2015 · 7 comments · Fixed by #188
Closed

AudioFileClip bombs on file read #158

ryanfox opened this issue Apr 15, 2015 · 7 comments · Fixed by #188

Comments

@ryanfox
Copy link
Collaborator

ryanfox commented Apr 15, 2015

Related: #157

I am trying to create an AudioFileClip from an mp3 file like so:

clip = AudioFileClip('myaudio.mp3')

On line 275 of ffmpeg_reader.py, it looks like whether a file is video or not is determined by whether there is the string " Video: " anywhere in the result from ffmpeg. At least in my case, this is throwing false positives. This is the string that triggers it for me:

u'    Stream #0:1: Video: png, 90k tbr, 90k tbn, 90k tbc'

I think the "video" is the album artwork. Anyway, this causes ffmpeg_reader to think it's a video file instead of audio, and try to extract video dimensions. Needless to say, those don't exist, and it throws an exception when it can't find them.

I am only interested in the audio data, not the png, whatever that is. Is there a way to make ffmpeg_reader a little smarter about what kind of file it's looking at?

@Zulko
Copy link
Owner

Zulko commented Apr 15, 2015

This case is supposed to work. What's the error message exactly ?

@ryanfox
Copy link
Collaborator Author

ryanfox commented Apr 15, 2015

MoviePy error: failed to read video dimensions in file 'myaudio.mp3'.
Here are the file infos returned by ffmpeg:

And then a list of the information returned by ffmpeg. I don't have the exact information available right now, I can get that later if it would be useful.

@Zulko
Copy link
Owner

Zulko commented Apr 20, 2015

Can you send a link to a file that doesn't work ?

@ryanfox
Copy link
Collaborator Author

ryanfox commented Apr 20, 2015

Here it is: http://traffic.libsyn.com/geeknights/20150414.mp3 Warning: it's a 64mb file.

Also, I looked at the console printout a little more carefully. It prints an error about "failed to read video dimensions" but doesn't crash there. Later on, in line 305:

float(line[match.start():match.end()].split(' ')[1])

match is None, so that line throws an error.
This is the value in line:

u'    Stream #0:1: Video: png, 90k tbr, 90k tbn, 90k tbc'

@kerier
Copy link

kerier commented Jul 15, 2015

I have encounter the same issue, AudioFileClip can't read mp3 file, but when i put a video file, it works fine! It's a very weird problem.

here is my code:
audio = AudioFileClip("test.mp3")

here is the except:
Traceback (most recent call last):
File "testanimation.py", line 5, in
audio = AudioFileClip("test.mp3")
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.2.11-py2.7.egg/moviepy/audio/io/AudioFileClip.py", line 63, in init
buffersize=buffersize))
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.2.11-py2.7.egg/moviepy/audio/io/readers.py", line 56, in init
infos = ffmpeg_parse_infos(filename)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.2.11-py2.7.egg/moviepy/video/io/ffmpeg_reader.py", line 305, in ffmpeg_parse_infos
result['video_fps'] = float(line[match.start():match.end()].split(' ')[1])
AttributeError: 'NoneType' object has no attribute 'start'

@ryanfox
Copy link
Collaborator Author

ryanfox commented Jul 16, 2015

I can take a crack at resolving this @Zulko, if you wouldn't mind. If you're processing an audio file, there won't necessarily be video data, but there may be. So in that case, it's not the end of the world (and worth crashing over) if there isn't a preview image or what have you.

@Zulko
Copy link
Owner

Zulko commented Jul 17, 2015

Thanks ! I'd be happy to review your PR.

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

Successfully merging a pull request may close this issue.

3 participants