AV1 Community

148 readers
6 users here now

All things relating to the AV1 video codec.

founded 1 year ago
MODERATORS
26
27
 
 

Encoder

  • Improve the tradeoffs for the random access mode across presets MR-M13:
  • Quality improvements across all presets and metrics ranging from 0.3% to 4.5% in BD-rate (!2129)
  • Spacing between presets [M1-M6] has been adjusted to account for the tradeoff improvements achieved
  • As a user guidance when comparing v1.7 vs v1.6 in a convexhull encoding setup:
  • v1.7.0 M2 is now at similar quality levels as v1.6.0 M1 while being ~50% faster
  • v1.7.0 M3 is now at similar quality levels as v1.6.0 M2 while being ~50% faster
  • v1.7.0 M4 is now at similar quality levels as v1.6.0 M3 while being ~40% faster
  • v1.7.0 M5 is now at similar quality levels as v1.6.0 M4 while being ~30% faster
  • v1.7.0 M6 is now at similar quality levels as v1.6.0 M5 while being ~25% faster
  • Added an experimental tune SSIM mode yielding ~3-4% additional SSIM BD-rate gains (!2109)

Build, cleanup and bug fixes

  • Various cleanups and functional bug fixes
  • Fix build conflict with libaom
28
 
 

I have been encoding some videos in AV1 lately and I thought I'd share my technique for those who may wish to do some AV1 on their own without having a messy setup. I think this is a pretty clean way, ultimately, to use Av1an's Docker image.

A forewarning: AV1 can be pretty to slow encode with. I've been doing it with DVDs where the 640x480 resolution of the video means a frame can be processed relatively quickly, but videos in 1920x1080 or 4k resolutions might be pretty intense where the encode speed only ends up being a frame a second.

Forewarning pt. 2: Something I learned that I CANNOT rely on is trying a faster encode speed to guesstimate the resulting file size and picture quality and then really maximize my results by lowering the encode speed. My observation has been that a slower encode speed will in fact improve the picture quality (and file size), such that I cannot be sure what something will look like without just encoding a very short sample at a slow speed. OK. Let's begin.

Operating System & Environment

I am using Fedora Linux 38. I'd like to use the Av1an package but that only has an official Arch release. I definitely don't want to spend time compiling this myself, so I will use the official Docker image instead. And I won't use Docker, actually, but Podman. I also use the Fish Shell. Its syntax is very slightly different from Bash's.

Now, Fedora users may know about SELinux. And something that kept happening to me was the security context of some of the files I'm shuffling around my hard drives would end up being not correct, making Podman incapable of seeing the files I'm trying to use. So instead of fixing the context per file (annoying) I just temporarily disabled SELinux.

sudo setenforce Permissive

Container image

From here things are pretty straightforward. I'll pull the docker image, which has a full Av1an setup ready to go.

podman pull docker.io/masterofzen/av1an:master

One little note is that you should use the master tag. A confusing thing about this image is that the latest tag is the old python version, and we want the current Rust version.

Executing Av1an

Now, navigate to whatever directory your source video is in. In my case, I losslessly encoded the DVDs with Handbrake into h264 and passed through the audio/chapter markers, etc. This gave me a good source to work with, even though it was a little bloated in file size. I don't think Av1an accepts MPEG-2, which is why I did that.

First I'll explain what the Podman command is doing for those who aren't familiar with Docker/Podman, and then I'll give a full working example.

podman run -v "$(pwd)":/videos:z --userns=keep-id -it --rm docker.io/masterofzen/av1an:master -i sourcevideo.mp4 -s scenes.csv --pix-format yuv420p10le -o output.webm -v "--VIDEO_OPTIONS" --keep -a "--AUDIO_OPTIONS"

  • podman run - Execute a container
  • -v "$(pwd)":/videos:z - Mount the present working directory as /videos in the container, and the :z is an SELinux labeling thing that can be dropped for non-SELinux users.
  • --userns=keep-id - This flag helps keep the user id and group ids consistent between the host and container so that they don't get mangled. Your output file will belong to your user.
  • -it - Execute the command in a visible shell session
  • --rm - Remove the container (not the image, the container) when the command is done executing.

Final example

The rest of the flags are for Av1an itself, or for the encoders. So here's a full working example of how I used it, to encode with aomenc and Opus for the audio. Av1an uses aomenc by default.

podman run -v "$(pwd)":/videos:z --userns=keep-id -it --rm docker.io/masterofzen/av1an:master -i sourcevideo.mp4 -s scenes.csv --pix-format yuv420p10le -o output.webm -v " --cpu-used=3 --enable-qm=1 --threads=4 -b 10 --end-usage=q --cq-level=28 --lag-in-frames=48 --auto-alt-ref=1 --enable-fwd-kf=1" --keep -a "-c:a libopus -b:a 128k"

I think for an explanation for what individual flags do, and perhaps some guidance on how to use them effectively, I can only refer one to the guide written by Reddit user BlueSwordM https://www.reddit.com/r/AV1/comments/t59j32/encoder_tuning_part_4_a_2nd_generation_guide_to/

29
 
 

Since what happened with Reddit could happen with Discord at any time (corporate greed), I started an AV1 server on Revolt. Please come check it out! Unlike discord, Revolt also supports AV1 video embeds...

30
 
 

some of this information may be out of date

Guide to compiling Av1an on Windows.

Download vapoursynth r57 portable from https://github.com/vapoursynth/vapoursynth/releases it's a 7z file so you should have 7-zip installed

Get Msys2 from https://www.msys2.org/, click on "download the installer" & install it with everything

Close msys2

Open msys2 mingw x64

Commands

  • pacman -Syuu

this updates msys2 packages, write Y when needed and press enter, it will close the window when it finishes so open msys mingw x64 again

  • pacman -S cmake git nasm python3 mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake base-devel mingw-w64-x86_64-ffmpeg mingw-w64-x86_64-rust mingw-w64-x86_64-lld mingw-w64-x86_64-clang mingw-w64-x86_64-make

this will install necessary stuff

Open VapourSynth32-Portable-R57.7z and copy all the libraries from \sdk\lib64 to C:\msys64\mingw64\lib

this downloads the Av1an source

  • cd av1an

this will take the shell to the Av1an folder

This is optional but if you want a bit more of performance,(i'm talking a small bit) go in explorer to C:\msys64\home"your username"\Av1an and open Cargo.toml and edit it with your text editor of choice, i used notepad++ and in the [profile.release] section change lto = "thin" to lto = "fat", i also added opt-level = 3 but that may not be necessary

  • RUSTFLAGS="-C target-cpu=native" cargo build --release

#this compiles it with march native which gives a bit of performance

Profit, the executable should be created in C:\msys64\home"your username"\Av1an\target\release

31
32
 
 

Encoder

  • Improve the tradeoffs for the random access mode across presets M1-M13: (!2120)
  • Speeding up the higher quality presets by 30-40%
  • Improving the BD-rate by 1-4% for the faster presets
  • Improve the tradeoffs for the low delay mode for both screen content and non-screen content encoding modes (!2122, !2118)
  • Add a toggle to remove the legacy one-frame buffer at the input of the pipeline allowing the low delay mode to operate at sub-frame processing latencies
  • Add a new API allowing the user to specify quantization offsets for a region of interest per frame

Build, cleanup and bug fixes

  • Various cleanups and functional bug fixes
  • Fix the startup minigop size BD-rate loss
  • Add ability to run the ci-testing offline
33
 
 

Hi everyone,

Montec, admin of the AV1 discord & moderator of the AV1 subreddit, has decided to join the Reddit blackout following Reddit's predatory API changes. I created this Lemmy community to help continue to foster AV1 community engagement as the Reddit blackout continues, and potentially create a new home for AV1 discussion. Reddit/Discord AV1 Community mods will be given mod here if they ask.Here's a link to the AV1 discord (30 day exp): https://discord.gg/2nqdkAMN4

Thanks, gb80