Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFmpeg WebM AV1 Support

With FFmpeg how can I use AV1 codec in a webm container?

I get the error:

Only VP8 or VP9 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --

However Wikipedia says WebM supports AV1.

https://en.wikipedia.org/wiki/AV1

AV1 is intended to be able to be used together with the audio format Opus in a future version of the WebM container format for HTML5 web video

Or can FFmpeg simply not encode this new version?


My settings:

ffmpeg -y 

-i "C:\Users\Matt\video.mp4" 

-c:v libaom-av1 -strict experimental 
-cpu-used 1 -crf 28 
-pix_fmt yuv420p 
-map 0:v:0? -map_chapters -1 
-sn 

-c:a libopus 
-map 0:a:0? 

-map_metadata 0 

-f webm 

-threads 0 

"C:\Users\Matt\video.webm"
like image 799
Matt McManis Avatar asked Jul 13 '18 02:07

Matt McManis


People also ask

Does Webm support AV1?

Update, FFmpeg does support AV1 in Webm now!

Does FFmpeg support AV1?

There are currently three AV1 encoders supported by FFmpeg: libaom (invoked with libaom-av1 in FFmpeg), SVT-AV1 ( libsvtav1 ), and rav1e ( librav1e ).

Is AV1 better than h264?

265 and the AV1 codec offer twice as much compression as H. 264. The supreme battle for a video encoder is to keep the bitrate low and the quality high.

Is AV1 better than VP9?

Also, at 1080p, AV1 delivers 47% savings over H. 264 and 21% savings over VP9. At 4K, AV1 delivers 28% savings over VP9. I found these bandwidth savings particularly significant.


2 Answers

ffmpeg currently doesn't support muxing AV1 in WebM. The error you're getting comes from this code:

if (mkv->mode == MODE_WEBM && !(par->codec_id == AV_CODEC_ID_VP8 ||
                                par->codec_id == AV_CODEC_ID_VP9 ||
                                par->codec_id == AV_CODEC_ID_OPUS ||
                                par->codec_id == AV_CODEC_ID_VORBIS ||
                                par->codec_id == AV_CODEC_ID_WEBVTT)) {
    av_log(s, AV_LOG_ERROR,
           "Only VP8 or VP9 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.\n");
    return AVERROR(EINVAL);
}

Note the lack of AV_CODEC_ID_AV1 in the expression.

This isn't too surprising, though. AV1 in Matroska (and therefore WebM) hasn't been finalized yet. If you want to follow progress on AV1 in Matroska (and WebM), follow the discussion here on the IETF CELLAR mailing list.

like image 94
Cornstalks Avatar answered Oct 16 '22 12:10

Cornstalks


Update, FFmpeg does support AV1 in Webm now!

        if (!native_id) {
        av_log(s, AV_LOG_ERROR,
               "Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.\n");
        return AVERROR(EINVAL);
    }

Source code here.

like image 3
Adithyan Ilangovan Avatar answered Oct 16 '22 12:10

Adithyan Ilangovan