| @@ -31,24 +31,26 @@ def convert(origin, target): | |||||
| cmd = 'ffmpeg -i {0} -c copy {1}'.format(origin, target) | cmd = 'ffmpeg -i {0} -c copy {1}'.format(origin, target) | ||||
| print("cmd:: {0}".format(cmd)) | print("cmd:: {0}".format(cmd)) | ||||
| args = shlex.split(cmd) | args = shlex.split(cmd) | ||||
| # status, output = sp.getstatusoutput(cmd) | |||||
| # print("status:: {0}, output {1}".format(status, output)) | |||||
| proc = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) | |||||
| answer = b'Overwrite ? [y/N]' | |||||
| try: | |||||
| outs, errs = proc.communicate(timeout=300) | |||||
| print(outs, errs) | |||||
| print("answer in outs : {0}".format(answer in outs)) | |||||
| if answer in outs: | |||||
| print('write y') | |||||
| proc.stdin.write(b'y') | |||||
| if proc.returncode == 0: | |||||
| print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| os.remove(origin) | |||||
| else: | |||||
| print("{0} convert fail".format(origin)) | |||||
| except sp.TimeoutExpired: | |||||
| proc.kill() | |||||
| status, output = sp.getstatusoutput(cmd) | |||||
| print("status:: {0}, output {1}".format(status, output)) | |||||
| if status ==0: | |||||
| os.remove(origin) | |||||
| #proc = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) | |||||
| #answer = b'Overwrite ? [y/N]' | |||||
| #try: | |||||
| # outs, errs = proc.communicate() | |||||
| # print(outs, errs) | |||||
| # print("answer in outs : {0}".format(answer in errs)) | |||||
| # if answer in errs: | |||||
| # print('write y') | |||||
| # # proc.stdin.write(b'y') | |||||
| # if proc.returncode == 0: | |||||
| # print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| # os.remove(origin) | |||||
| # else: | |||||
| # print("{0} convert fail".format(origin)) | |||||
| #except sp.TimeoutExpired: | |||||
| # proc.kill() | |||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||