diff --git a/pandora_client/extract.py b/pandora_client/extract.py index b243329..0ab4ddd 100644 --- a/pandora_client/extract.py +++ b/pandora_client/extract.py @@ -292,7 +292,8 @@ def video_cmd(video, target, profile, info): return cmd def video(video, target, profile, info): - cmd = video_cmd(video, target, profile, info) + enc_target = target if target.endswith('.mp4') else target + '.tmp.webm' + cmd = video_cmd(video, enc_target, profile, info) profile, format = profile.split('.') #r = run_command(cmd, -1) p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) @@ -306,11 +307,17 @@ def video(video, target, profile, info): stderr=subprocess.STDOUT) p.communicate() os.unlink("%s.mp4" % target) + elif r == 0 and target != enc_target: + shutil.move(enc_target, target) print 'Input:\t', video print 'Output:\t', target except KeyboardInterrupt: p.kill() r = 1 + if os.path.exists(enc_target): + print "\n\ncleanup unfinished encoding:\nremoving", enc_target + print "\n" + os.unlink(enc_target) if os.path.exists(target): print "\n\ncleanup unfinished encoding:\nremoving", target print "\n"