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

Removed Hz from audio_fps match in ffmpeg_parse_infos #665

Merged
merged 3 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion moviepy/video/io/ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ def get_fps():
line = lines_audio[0]
try:
match = re.search(" [0-9]* Hz", line)
result['audio_fps'] = int(line[match.start()+1:match.end()])
hz_string = line[match.start()+1:match.end()-3] # Removes the 'hz' from the end
result['audio_fps'] = int(hz_string)
except:
result['audio_fps'] = 'unknown'

Expand Down
9 changes: 9 additions & 0 deletions tests/test_ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ def test_ffmpeg_parse_infos():
d=ffmpeg_parse_infos("media/pigs_in_a_polka.gif")
assert d['video_size'] == [314, 273]
assert d['duration'] == 3.0
assert not d['audio_found']

d=ffmpeg_parse_infos("media/video_with_failing_audio.mp4")
assert d['audio_found']
assert d['audio_fps'] == 44100

d=ffmpeg_parse_infos("media/crunching.mp3")
assert d['audio_found']
assert d['audio_fps'] == 48000


if __name__ == '__main__':
Expand Down