Created
December 15, 2015 22:25
-
-
Save davetromp/8fbb63e7dfc714668892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the code is explained here: https://youtu.be/Eex4zBc9r7Y | |
import os | |
def main(): | |
files = os.listdir("./") | |
for f in files: | |
if f.lower()[-3:] == "mp4": | |
print "processing", f | |
process(f) | |
def process(f): | |
inFile = f | |
outFile = f[:-3] + "mp3" | |
cmd = "ffmpeg -i {} -vn -ac 2 -ar 44100 -ab 320k -f mp3 {}".format(inFile, outFile) | |
os.popen(cmd) | |
main() |
Works In Windows 10 1909 Build 18363.535 And Python 3.8.1 With Cmd Change
cmd = '''ffmpeg -i "{}" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "{}"'''.format(inFile, outFile)
Many Thanks For The Script
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
De python code executes some command-line script. If a file name has spaces, it should be called within quotes. So try to replace:
cmd = "ffmpeg -i {} -vn -ac 2 -ar 44100 -ab 320k -f mp3 {}".format(inFile, outFile)
with:
cmd = '''ffmpeg -i "{}" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "{}"'''.format(inFile, outFile)