Add explicit overwrite option
This commit is contained in:
parent
6cab95e962
commit
a7520a05b8
1 changed files with 5 additions and 2 deletions
7
main.py
7
main.py
|
@ -8,8 +8,11 @@ import os
|
|||
@click.argument('outdir')
|
||||
@click.option('--audio', help="Audio language or stream number")
|
||||
@click.option('--hardcode', help="Hardcode target sub stream (language or stream number)")
|
||||
def main(infile, outdir, hardcode=None, audio='eng'):
|
||||
@click.option('--overwrite/--no-overwrite', default=True)
|
||||
def main(infile, outdir, hardcode=None, audio='eng', overwrite=True):
|
||||
outfile = os.path.join(outdir, os.path.splitext(os.path.split(infile)[1])[0]+'.mp4')
|
||||
if os.path.exists(outfile) and not overwrite:
|
||||
click.abort(0)
|
||||
probe = ffmpeg.probe(infile)
|
||||
|
||||
audio_streams, sub_streams = [], []
|
||||
|
@ -44,7 +47,7 @@ def main(infile, outdir, hardcode=None, audio='eng'):
|
|||
else:
|
||||
video = raw.video
|
||||
|
||||
ffmpeg.output(video, raw[audio_index], outfile, acodec='aac', vcodec='libx264', crf='18', preset='slow').run()
|
||||
ffmpeg.output(video, raw[audio_index], outfile, acodec='aac', vcodec='libx264', crf='18', preset='slow').run(overwrite_output=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue