gists/music_sync/convert.py

11 lines
341 B
Python
Raw Permalink Normal View History

2014-04-27 15:34:09 -07:00
import subprocess as sp
2014-04-28 19:31:24 -07:00
import os
2014-04-27 15:34:09 -07:00
2014-04-28 19:31:24 -07:00
def ogg(fin, fout):
p1 = sp.Popen(["ffmpeg", "-loglevel", "error", "-i", fin, "-f", "flac", "-"], stdout=sp.PIPE)
p2 = sp.Popen(["oggenc", "-Q", "-q", "5", "-", "-o", fout], stdin=p1.stdout, stdout=sp.PIPE)
2014-04-27 15:34:09 -07:00
p1.stdout.close()
2014-04-28 19:31:24 -07:00
p2.communicate()
ret = p1.poll() or p2.poll()
return ret