Skip to content

Instantly share code, notes, and snippets.

@diewland
Last active August 7, 2019 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diewland/d8c6c1a9a5c0b9a60fe237ce62c296a2 to your computer and use it in GitHub Desktop.
Save diewland/d8c6c1a9a5c0b9a60fe237ce62c296a2 to your computer and use it in GitHub Desktop.
subprocess in pydub.AudioSegment.from_file
# https://github.com/jiaaro/pydub/blob/master/pydub/audio_segment.py
if filename:
conversion_command += ["-i", filename]
stdin_parameter = None # <------------------------------------------- Look at this line !!
stdin_data = None
else:
if cls.converter == 'ffmpeg':
conversion_command += ["-read_ahead_limit", str(read_ahead_limit),
"-i", "cache:pipe:0"]
else:
conversion_command += ["-i", "-"]
stdin_parameter = subprocess.PIPE
stdin_data = file.read()
...
p = subprocess.Popen(conversion_command, stdin=stdin_parameter, # <------- Yeah! stdin is None
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p_out, p_err = p.communicate(input=stdin_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment