Skip to content

Commit

Permalink
allow users to specify the codec for decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaaro authored Apr 5, 2017
1 parent 89e77ba commit ca06334
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pydub/audio_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def from_mono_audiosegments(cls, *mono_segments):
)

@classmethod
def from_file(cls, file, format=None, parameters=None, **kwargs):
def from_file(cls, file, format=None, codec=None, parameters=None, **kwargs):
orig_file = file
file = _fd_or_path_or_tempfile(file, 'rb', tempfile=False)

Expand Down Expand Up @@ -485,6 +485,10 @@ def is_format(f):
if format:
conversion_command += ["-f", format]

if codec:
# force audio decoder
conversion_command += ["-acodec", codec]

conversion_command += [
"-i", input_file.name, # input_file options (filename last)
"-vn", # Drop any video streams if there are any
Expand Down

0 comments on commit ca06334

Please sign in to comment.