1
0

Files now successfully transcoded, adding documentation next

This commit is contained in:
Tony Grosinger 2013-05-18 07:44:48 -07:00
parent 0f29bd3b98
commit 494f5eee3b

View File

@ -15,7 +15,12 @@ if not outputDir.endswith("/"):
def extractCurrentDirectory(dir): def extractCurrentDirectory(dir):
return dir.replace(inputDir, "").replace("/", "", 1) return dir.replace(inputDir, "").replace("/", "", 1)
def replace_last(source_string, replace_what, replace_with):
head, sep, tail = source_string.rpartition(replace_what)
return head + replace_with + tail
for root, dirs, files in os.walk(inputDir): for root, dirs, files in os.walk(inputDir):
os.chdir(root)
root = extractCurrentDirectory(root) root = extractCurrentDirectory(root)
# Create the child directory if it doesn't exist so we can put files in it # Create the child directory if it doesn't exist so we can put files in it
@ -24,6 +29,7 @@ for root, dirs, files in os.walk(inputDir):
for name in files: for name in files:
if name.endswith(".flac"): if name.endswith(".flac"):
print("Found File: %s" % name) print("Transcoding File: %s" % name)
command = shlex.split("ffmpeg -i \"%s\" -f ogg -c:a libvorbis -q 8 -map 0:0 \"%s\"" % (os.path.abspath(name), outputDir + root + "/" + name)) output = replace_last((outputDir + root + "/" + name), "flac", "ogg")
command = shlex.split("ffmpeg -i \"%s\" -f ogg -c:a libvorbis -q 8 -map 0:0 \"%s\"" % (name, output))
p = subprocess.call(command) p = subprocess.call(command)