5

I have a set of AVI videos (lossless video streams; no audio) and my goal is to convert them to AV1 lossless using FFmpeg.

FFmpeg (with librav1e, libaom-av1 and libsvtav1 included) runs fine on my Windows 8.1 machine and I'm able to convert the videos to H.264, H.265 and VP9 (all lossless) using the Commands section from AV1 vs VP9 vs AVC (h.264) vs HEVC (h.265): Part I - Lossless.

But I'm confused with the command line parameters for AV1 on that page. I also don't know how to transform AV1 options described on ffmpeg Documentation into a FFmpeg command line (and couldn't find any tutorial).

I've also checked libaom AV1 Encoding Guide, The Rebel Alliance's AV1 Video Codec Encoding Guide and others but they don't mention AV1 lossless at all.

Could you please provide an example FFmpeg command line for one or more encoders (librav1e, libaom-av1, libsvtav1)?

4
  • If AV1 video is made up of a bunch of AVIF images, I wouldn't necessarily expect smaller video file sizes for lossless AV1 videos, because I certainly don't see smaller file sizes for AVIF images when they're lossless. I concluded this using Squoosh. That said, lossy AVIF images are the smallest I've seen at the quality they offer. Therefore I expect lossy AV1 video to be the best quality for the file size when it comes to lossy video (but not the smallest for lossless video, currenlty).
    – LonnieBest
    Mar 6, 2021 at 2:24
  • @LonnieBest It's not like that. AV1 lossless simply outputs the smallest files I've seen, compared to H.264, H.265, VP9. Mar 12, 2021 at 7:31
  • Are you absolutely sure the files you produced were lossless? For example, ffmpeg rejected the --lossless=1 argument when I tried the answer you provided below.
    – LonnieBest
    Mar 14, 2021 at 18:19
  • 1
    @LonnieBest Put the --lossless=1 to aomenc, not to ffmpeg. Mar 15, 2021 at 8:05

3 Answers 3

7

With FFmpeg itself:

ffmpeg -i movie.avi -c:v libaom-av1 -aom-params lossless=1  "av1losslessmovie.mp4"
6
  • 2
    It does not matter... AVI is just a container. They are all supported by ffmpeg. AV1 is video stream inside AVI container. Mar 21, 2021 at 1:07
  • 1
    Thanks, @ВалерийЗаподовников. It seemed it would work. But the output has a green color instead of black. FFmpeg (latest version) also refuses -aom-params lossless=1:threads=4, claiming that threads is an unknown parameter. Do you know how to resolve it? Mar 21, 2021 at 20:56
  • 1
    --threads 6 -aom-params lossless=1, not what you used. That are standard libavcodec options, not aom specific. aomenc --help will show what are specific to aom-params options. Mar 21, 2021 at 21:07
  • 1
    As to green color what is the matrix on input file? If it is Identity matrix (so RGB) you should add the matrix you need with -pixel_format yuv444p -color_primaries 1 -color_trc 1 -colorspace 1 becuase of this bug: trac.ffmpeg.org/ticket/9132#comment:5 Mar 21, 2021 at 21:13
  • 1
    Just FYI you can now use just -crf 0 after it was fixed in github.com/FFmpeg/FFmpeg/commit/… Mar 28, 2021 at 16:00
3

I've done some research and a lot of test runs and this is the result:

ffmpeg -hide_banner -i input.avi -f yuv4mpegpipe -pix_fmt yuv444p temp.y4m
aomenc --lossless=1 --threads=4 -o output.webm temp.y4m

It's damn slow and it uses a standalone aomenc (not aomenc in ffmpeg as I originally wanted) but it works and it outputs much smaller files than H.264, H.265 or VP9 formats.

Optionally I use this afterwards to change the container:

ffmpeg -hide_banner -i output.webm -c:v copy output.mkv

rav1e and SVT-AV1 currently don't support lossless (although it's requested: 1, 2).

1
  • I've learnt that the conversion isn't completely lossless if the source isn't yuv444p. But at least it doesn't introduce any artifacts. So the result is perfect for my use case. May 17, 2021 at 12:56
0

If you have FFmpeg>4.4, you can simply use the -crf 0 argument

ffmpeg -i input.mp4 -c:v libaom-av1 -crf 0 av1_test.mkv

according to FFmpeg Docs


Use Валерий Заподовников's answer if you have <4.4 FFmpeg installed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .