gists/convert.py

13 lines
395 B
Python
Raw Normal View History

2014-04-27 15:34:09 -07:00
import subprocess as sp
import tempfile
def ogg(inf):
_, temppath = tempfile.mkstemp()
p1 = sp.Popen(["ffmpeg", "-loglevel", "warning", "-i", inf, "-f", "flac", "-"], stdout=sp.PIPE)
p2 = sp.Popen(["oggenc", "-Q", "-", "-o", temppath], stdin=p1.stdout, stdout=sp.PIPE)
p1.stdout.close()
_, err = p2.communicate()
if err:
raise Exception(err)
return temppath