Skip to content

Commit

Permalink
fix ffmpeg unicode filename handling
Browse files Browse the repository at this point in the history
fixes #241
  • Loading branch information
Sebastian Böck committed Jul 8, 2017
1 parent 622c75e commit a826a41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bug fixes:

* Fix `TransitionModel` number of states when last state is unreachable (#287)
* Fix double beat detections in `BeatTrackingProcessor` (#298)
* Fix more ffmpeg unicode filename handling issues (#305)

API relevant changes:

Expand Down
14 changes: 10 additions & 4 deletions madmom/audio/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

from .signal import Signal

# Python 2/3 string compatibility (like six does it)
try:
string_types = basestring
except NameError:
string_types = str


def _ffmpeg_fmt(dtype):
"""
Expand Down Expand Up @@ -167,7 +173,7 @@ def decode_to_disk(infile, fmt='f32le', sample_rate=None, num_channels=1,
"""
# check input file type
if not isinstance(infile, str):
if not isinstance(infile, string_types):
raise ValueError("only file names are supported as `infile`, not %s."
% infile)
# create temp file if no outfile is given
Expand All @@ -181,7 +187,7 @@ def decode_to_disk(infile, fmt='f32le', sample_rate=None, num_channels=1,
else:
delete_on_fail = False
# check output file type
if not isinstance(outfile, str):
if not isinstance(outfile, string_types):
raise ValueError("only file names are supported as `outfile`, not %s."
% outfile)
# call ffmpeg (throws exception on error)
Expand Down Expand Up @@ -240,7 +246,7 @@ def decode_to_pipe(infile, fmt='f32le', sample_rate=None, num_channels=1,
"""
# check input file type
if not isinstance(infile, (str, Signal)):
if not isinstance(infile, (string_types, Signal)):
raise ValueError("only file names or Signal instances are supported "
"as `infile`, not %s." % infile)
# Note: closing the file-like object only stops decoding because ffmpeg
Expand Down Expand Up @@ -289,7 +295,7 @@ def decode_to_memory(infile, fmt='f32le', sample_rate=None, num_channels=1,
"""
# check input file type
if not isinstance(infile, (str, Signal)):
if not isinstance(infile, (string_types, Signal)):
raise ValueError("only file names or Signal instances are supported "
"as `infile`, not %s." % infile)
# prepare decoding to pipe
Expand Down

0 comments on commit a826a41

Please sign in to comment.