Skip to content

Commit

Permalink
Removed Hz from audio_fps match in ffmpeg_parse_infos (#665)
Browse files Browse the repository at this point in the history
* removed Hz from audio_fps match in ffmpeg_parse_infos

* added more tests for ffmpeg reader
  • Loading branch information
qmac authored and tburrows13 committed Apr 23, 2018
1 parent a354ba3 commit 956c462
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 956c462

Please sign in to comment.