diff options
Diffstat (limited to '')
-rwxr-xr-x | convert.py | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -9,16 +9,24 @@ import pexpect import time import datetime -if len(sys.argv) == 3: - sourcedir = sys.argv[1] - outdir = sys.argv[2] +if len(sys.argv) >= 3 and len(sys.argv) <= 4: + if len(sys.argv) == 3: + sourcedir = sys.argv[1] + outdir = sys.argv[2] + arg = "-n" + else: + sourcedir = sys.argv[2] + outdir = sys.argv[3] + arg = sys.argv[1] if not os.path.isdir(sourcedir): print("No such file or directory: '"+str(sourcedir)+"'") sys.exit() else: print("Simple tool for convert mp4 file to mp3") - print("Usage:\nconvert.py [SOURCE] [DESTINATION]") + print("Usage:\nconvert.py [-n|-y] [SOURCE] [DESTINATION]") + print(" -n ffmpeg: Do not overwrite output files, and exit immediately if a specified output file already exists. (Default option)") + print(" -y ffmpeg: Overwrite output files without asking.") def dirSize(path,ext1,ext2): list_dir = [] @@ -41,7 +49,7 @@ for file in sorted(os.listdir(sourcedir)): print("Converting : "+name) count += 1 #cmd = ["ffmpeg", "-n", "-i", sourcedir+"/"+name+".mp4", "-c:a", "libmp3lame", outdir+"/"+name+".mp3"]² - cmd = "ffmpeg -n -i '"+sourcedir+"/"+name+".mp4' -c:a libmp3lame '"+outdir+"/"+name+".mp3'" + cmd = "ffmpeg "+arg+" -i '"+sourcedir+"/"+name+".mp4' -c:a libmp3lame '"+outdir+"/"+name+".mp3'" thread = pexpect.spawn(cmd) cpl = thread.compile_pattern_list([pexpect.EOF,"frame= *\d+",'(.+)']) |