From aa564e5eee26567884e7d01fcea4cdc593d2335f Mon Sep 17 00:00:00 2001 From: Martinez Date: Sun, 7 Aug 2016 23:05:58 +0200 Subject: [PATCH] add --cut --- over-video.py | 6 +++++- version.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/over-video.py b/over-video.py index 930d48c..b52f73f 100755 --- a/over-video.py +++ b/over-video.py @@ -23,7 +23,7 @@ X264_BANNED_PIXFMTS = {"bgr24", "yuv422p"} command = over.types.ndict() command.identify = Command("ffprobe", "-v", "quiet", "-print_format", "json", "-show_format", "-show_streams", "INFILE") command.normalize_prepass = Command("ffmpeg", "-i", "INFILE", "-filter:a", "volumedetect", "-f", "null", "/dev/null") -command.encode_generic = Command("ffmpeg", "-i", "INFILE", "MAP", "VIDEO", "AUDIO", "-sn", "OUTFILE") +command.encode_generic = Command("ffmpeg", "CUT_FROM", "-i", "INFILE", "CUT_TO", "MAP", "VIDEO", "AUDIO", "-sn", "OUTFILE") command.sub_vorbis = Command("-codec:a", "libvorbis", "-qscale:a", "QUALITY", "NORMALIZE") command.sub_pcm = Command("-codec:a", "pcm_s16le", "NORMALIZE") command.sub_theora = Command("-codec:v", "libtheora", "-qscale:v", "QUALITY", "VFILTER") @@ -50,6 +50,7 @@ if __name__ == "__main__": main.add_option("normalize-override", "Volume correction to use instead of computing the required value in a (lengthy) pre-pass.", float, [0.0], abbr="N", count=1, in_cfg_file=False) main.add_option("ffmpeg-vfilter", 'Raw ffmpeg -filter:v options, e.g. "scale=1280:trunc(ow/a/2)*2,transpose=dir=1<.>"', str, [""], abbr="F", count=1) main.add_option("ffmpeg-map", "Raw ffmpeg -map<.> options, e.g. --map<.> 0:1<.> --map<.> 0:2<.>. This is a drop-in fix until we get proper stream selection.", str, abbr="M", overwrite=False, count=1) + main.add_option("cut", "Start and end timestamps of the portion to cut out. Uses native ffmpeg -ss<.> and -to<.> format, so it's either seconds from start or [:]:[.<...]<.>. Example: --cut<.> 25 35<.> uses 10 seconds of video starting at 25s, --cut<.> 1:10:45 1:23:54.5<.> uses video from 4245s to 5034.5s.", over.callback.strings, abbr="X", count=2) main.add_option("move-source", "Move source file to this directory after conversion. Use an empty string to disable.", str, ["processed"], count=1) main.add_option("dump-commands", "Print ffmpeg commands that would be executed. If --normalize<.> is in effect, the normalization pre-pass will still be performed so that the proper volume correction can be computed.", bool, [False], abbr="D", in_cfg_file=False) main.add_option("probe", "Print the raw JSON output of ffprobe and exit.", bool, [False], abbr="p", in_cfg_file=False) @@ -292,6 +293,9 @@ if __name__ == "__main__": encode_cmd.INFILE = "file:" + str(files.infile) encode_cmd.OUTFILE = files.tmpfile + encode_cmd.CUT_FROM = ["-ss", main.cfg.cut[0]] if main.cfg.cut else None + encode_cmd.CUT_TO = ["-to", main.cfg.cut[1]] if main.cfg.cut else None + if main.cfg.audio == "copy": encode_cmd.AUDIO = command.sub_copy_audio elif main.cfg.audio == "drop": diff --git a/version.py b/version.py index 979dac3..0abbcdf 100644 --- a/version.py +++ b/version.py @@ -2,7 +2,7 @@ # encoding: utf-8 major = 1 # VERSION_MAJOR_IDENTIFIER -minor = 99 # VERSION_MINOR_IDENTIFIER -# VERSION_LAST_MM 1.99 -patch = 2 # VERSION_PATCH_IDENTIFIER +minor = 100 # VERSION_MINOR_IDENTIFIER +# VERSION_LAST_MM 1.100 +patch = 0 # VERSION_PATCH_IDENTIFIER str = ".".join(str(v) for v in (major, minor, patch))