From 59d61e5f3e5b4f1bf09e1d4cac29178483ef87f3 Mon Sep 17 00:00:00 2001 From: Martin Sekera Date: Tue, 19 Mar 2019 16:35:01 +0100 Subject: [PATCH] add AV1 support (although it's so slow it has no practical use) --- over-video.py | 15 +++++++++++---- version.py | 6 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/over-video.py b/over-video.py index e059d19..ebecb76 100755 --- a/over-video.py +++ b/over-video.py @@ -31,6 +31,7 @@ command.sub_pcm = Command("-codec:a", "pcm_s16le", "NORMALIZE") command.sub_x264 = Command("PIXFMT", "-codec:v", "libx264", "-preset", "PRESET", "-crf", "QUALITY", "-profile:v", "high", "-level", "4.2", "VFILTER") command.sub_x265 = Command("-codec:v", "libx265", "-preset", "PRESET", "-crf", "QUALITY", "VFILTER") command.sub_vp9 = Command("-codec:v", "libvpx-vp9", "-crf", "QUALITY", "-b:v", "0", "VFILTER") +command.sub_av1 = Command("-strict", "experimental", "-codec:v", "libaom-av1", "-crf", "QUALITY", "-b:v", "0", "VFILTER") command.sub_normalize = Command("-filter:a", "LOUDNORM_INCANTATION", "-ar", "48k") command.sub_vfilter = Command("-filter:v", "ARGS") command.force_yuv420p = Command("-pix_fmt", "yuv420p") @@ -43,9 +44,9 @@ if __name__ == "__main__": main = over.app.Main("over-video", version.str, "AO-JSL", features={"config_file": True}) main.add_option("audio", "Audio codec to use, either opus<.>, vorbis<.>, pcm<.>, copy<.> or drop<.>.", str, ["opus"], abbr="a", count=1) main.add_option("audio-quality", "Audio encoding quality with -1<.> being the worst and 10<.> being the best. Ignored by --audio<.> opus<.>.", float, [4], abbr="q", count=1) - main.add_option("video", "Video codec to use, either vp9<.>, x265<.>, x264<.>, copy<.> or drop<.>.", str, ["vp9"], abbr="v", count=1) + main.add_option("video", "Video codec to use, either av1<.>, vp9<.>, x265<.>, x264<.>, copy<.> or drop<.>.", str, ["vp9"], abbr="v", count=1) main.add_option("video-preset", "Video encoding preset to use by --video<.> x264<.> and x265<.>.", str, ["slow"], abbr="P", count=1) - main.add_option("video-quality", "Video encoding quality (CRF). Use 0<.>-51<.> for --video<.> x264<.> and x265<.> (0<.> being lossless, 18<.>-28<.> is reasonable) and 0<.>-63<.> for --video<.> vp9<.> (0<.> being highest, 15<.>-35<.> typical, and 31<.> recommended for HD video).", float, [31], abbr="Q", count=1) + main.add_option("video-quality", "Video encoding quality (CRF). Use 0<.>-51<.> for --video<.> x264<.> and x265<.> (0<.> being lossless, 18<.>-28<.> is reasonable) and 0<.>-63<.> for --video<.> av1<.> or vp9<.> (0<.> being highest, 15<.>-35<.> typical, and 31<.> recommended for HD video).", float, [31], abbr="Q", count=1) main.add_option("container", "The initial container type. Either mkv<.> or webm<.> (or anything else supported by ffmpeg).", str, ["webm"], count=1) main.add_option("normalize", "Normalize the audio track without clipping. May use dynamic range compression.", bool, [True], abbr="n") 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) @@ -60,7 +61,7 @@ if __name__ == "__main__": main.add_doc("Description", ["A video converter meant to coerce all video formats into one format with properly normalized audio. It can also be used to extract audio from video files, resizing, or very basic cutting."]) main.add_doc("Known good encoder settings", ["vp9<.>: --video<.> vp9<.> --video-quality<.> 31<.> --audio<.> opus<.> (this is the default and should provide best overall results)", "x264<.>: --video<.> x264<.> --video-preset<.> slow<.> --video-quality<.> 22<.>", "x265<.>: --video<.> x265<.> --video-preset<.> medium<.> --video-quality<.> 20<.>"]) - main.add_doc("Performance", ["Good bitstreams take obscene amounts of CPU time to produce. See /doc/codec-comparison.tsv for a table of various configs encoding a 1080p video."]) + main.add_doc("Performance", ["Good bitstreams take obscene amounts of CPU time to produce. See /doc/codec-comparison.tsv for a table of various configs encoding a 1080p video.", "AV1 is currently unusable due to the amount of time it takes to produce a single frame."]) main.setup() @@ -115,7 +116,7 @@ if __name__ == "__main__": if main.cfg.audio not in ("drop", "copy", "pcm", "vorbis", "opus", "mp3"): raise ValueError("unknown audio codec: %s" %(main.cfg.audio)) - if main.cfg.video not in ("drop", "copy", "x264", "x265", "vp9"): + if main.cfg.video not in ("drop", "copy", "x264", "x265", "vp9", "av1"): raise ValueError("unknown video codec: %s" %(main.cfg.video)) if not main.targets: @@ -362,6 +363,12 @@ if __name__ == "__main__": command.sub_vp9.VFILTER = info.vfilter_command encode_cmd.VIDEO = command.sub_vp9 + elif main.cfg.video == "av1": + command.sub_av1.reset() + command.sub_av1.QUALITY = main.cfg.video_quality + command.sub_av1.VFILTER = info.vfilter_command + + encode_cmd.VIDEO = command.sub_av1 elif main.cfg.video == "x264": command.sub_x264.reset() command.sub_x264.QUALITY = main.cfg.video_quality diff --git a/version.py b/version.py index 5ec5269..c381d45 100644 --- a/version.py +++ b/version.py @@ -2,7 +2,7 @@ # encoding: utf-8 major = 1 # VERSION_MAJOR_IDENTIFIER -minor = 112 # VERSION_MINOR_IDENTIFIER -# VERSION_LAST_MM 1.112 -patch = 2 # VERSION_PATCH_IDENTIFIER +minor = 113 # VERSION_MINOR_IDENTIFIER +# VERSION_LAST_MM 1.113 +patch = 0 # VERSION_PATCH_IDENTIFIER str = ".".join(str(v) for v in (major, minor, patch))