add AV1 support (although it's so slow it has no practical use)

This commit is contained in:
Martin Sekera 2019-03-19 16:35:01 +01:00
parent e94c3d166f
commit 59d61e5f3e
2 changed files with 14 additions and 7 deletions

View file

@ -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 <M>opus<.>, <M>vorbis<.>, <M>pcm<.>, <M>copy<.> or <M>drop<.>.", str, ["opus"], abbr="a", count=1)
main.add_option("audio-quality", "Audio encoding quality with <M>-1<.> being the worst and <M>10<.> being the best. Ignored by <W>--<g>audio<.> <m>opus<.>.", float, [4], abbr="q", count=1)
main.add_option("video", "Video codec to use, either <M>vp9<.>, <M>x265<.>, <M>x264<.>, <M>copy<.> or <M>drop<.>.", str, ["vp9"], abbr="v", count=1)
main.add_option("video", "Video codec to use, either <M>av1<.>, <M>vp9<.>, <M>x265<.>, <M>x264<.>, <M>copy<.> or <M>drop<.>.", str, ["vp9"], abbr="v", count=1)
main.add_option("video-preset", "Video encoding preset to use by <W>--<g>video<.> <m>x264<.> and <m>x265<.>.", str, ["slow"], abbr="P", count=1)
main.add_option("video-quality", "Video encoding quality (CRF). Use <M>0<.>-<M>51<.> for <W>--<g>video<.> <m>x264<.> and <m>x265<.> (<M>0<.> being lossless, <M>18<.>-<M>28<.> is reasonable) and <M>0<.>-<M>63<.> for <W>--<g>video<.> <m>vp9<.> (<M>0<.> being highest, <M>15<.>-<M>35<.> typical, and <M>31<.> recommended for HD video).", float, [31], abbr="Q", count=1)
main.add_option("video-quality", "Video encoding quality (CRF). Use <M>0<.>-<M>51<.> for <W>--<g>video<.> <m>x264<.> and <m>x265<.> (<M>0<.> being lossless, <M>18<.>-<M>28<.> is reasonable) and <M>0<.>-<M>63<.> for <W>--<g>video<.> <m>av1<.> or <m>vp9<.> (<M>0<.> being highest, <M>15<.>-<M>35<.> typical, and <M>31<.> recommended for HD video).", float, [31], abbr="Q", count=1)
main.add_option("container", "The initial container type. Either <M>mkv<.> or <M>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. "<M>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", ["<W>vp9<.>: <W>--<g>video<.> <M>vp9<.> <W>--<g>video-quality<.> <M>31<.> <W>--<g>audio<.> <M>opus<.> (this is the default and should provide best overall results)", "<W>x264<.>: <W>--<g>video<.> <M>x264<.> <W>--<g>video-preset<.> <M>slow<.> <W>--<g>video-quality<.> <M>22<.>", "<W>x265<.>: <W>--<g>video<.> <M>x265<.> <W>--<g>video-preset<.> <M>medium<.> <W>--<g>video-quality<.> <M>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

View file

@ -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))