diff options
author | neodarz <neodarz@neodarz.net> | 2017-07-10 18:41:14 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2017-07-10 18:41:14 +0200 |
commit | a1bae3e6c8f81ec4838a0f2c28d1e0b85858a730 (patch) | |
tree | fb0fcb4975d36f52f1f71057c8ec7a979529b243 /convert.py | |
parent | 25ca561cfc9ca92eb3172dd23d0962a8fc9554f4 (diff) | |
download | video_save-a1bae3e6c8f81ec4838a0f2c28d1e0b85858a730.tar.xz video_save-a1bae3e6c8f81ec4838a0f2c28d1e0b85858a730.zip |
Add option for overwrite or not
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+",'(.+)']) |