{"id":750,"date":"2019-11-23T06:17:33","date_gmt":"2019-11-23T06:17:33","guid":{"rendered":"http:\/\/blogs.gentoo.org\/lu_zero\/?p=750"},"modified":"2019-11-23T06:17:33","modified_gmt":"2019-11-23T06:17:33","slug":"rav1e-0-1-0-made-in-tokyo","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/lu_zero\/2019\/11\/23\/rav1e-0-1-0-made-in-tokyo\/","title":{"rendered":"rav1e-0.1.0 Made in Tokyo"},"content":{"rendered":"<h2>Intro<\/h2>\n<blockquote><p><a href=\"https:\/\/aomedia.org\/av1-features\/\">AV1<\/a> is a modern video codec brought to you by an alliance of <a href=\"https:\/\/aomedia.org\/membership\/members\/\">many<\/a> different bigger and smaller players in the multimedia field.<br \/>\nI&#8217;m part of the <a href=\"https:\/\/videolan.org\">VideoLan<\/a> organization and I spent quite a bit of time on this codec lately.<\/p><\/blockquote>\n<hr>\n<blockquote><p><a href=\"https:\/\/github.com\/xiph\/rav1e\/\">rav1e<\/a>: The safest and fastest AV1 encoder, built by many volunteers and Mozilla\/Xiph developers.<br \/>\nIt is written in <a href=\"https:\/\/rustlang.org\">rust<\/a> and strives to provide good speed, quality and stay maintainable.<\/p><\/blockquote>\n<hr>\n<h2>Made in Tokyo<\/h2>\n<p>The first <a href=\"https:\/\/github.com\/xiph\/rav1e\/releases\/tag\/0.1.0\">official release<\/a> of <a href=\"https:\/\/github.com\/xiph\/rav1e\/\">rav1e<\/a> happened during the <a href=\"https:\/\/www.videolan.org\/videolan\/events\/vdd19\/\">Video Dev Days 2019<\/a> in Tokyo.<br \/>\nSince it was originally presented during <a href=\"https:\/\/www.videolan.org\/videolan\/events\/vdd17\/\">Video Dev Days 2017<\/a> it felt the right thing to do.<\/p>\n<h2>What is inside<\/h2>\n<p>Since <a href=\"https:\/\/dev.to\/luzero\/using-rav1e-from-your-own-code-2ie0\">last time<\/a> I blogged about it, there are few changes:<\/p>\n<h3>crav1e is no more<\/h3>\n<p>The <code>C-API<\/code> now is part of rav1e itself and everything is built by <a href=\"https:\/\/crates.io\/crates\/cargo-c\">cargo-c<\/a>.<\/p>\n<div class=\"codehilite\">\n<pre>cargo install cargo-c\ncargo cinstall --destdir<span class=\"o\">=<\/span>\/tmp\/staging\nsudo cp \/tmp\/staging\/* \/\n<\/pre>\n<\/div>\n<p>Thats&#8217;s all you need to use <code>rav1e<\/code> from C.<\/p>\n<h3>New API features<\/h3>\n<h4>Keyframe placement<\/h4>\n<p>The rust API now let you override the keyframe placement<\/p>\n<div class=\"codehilite\">\n<pre>  <span class=\"kd\">let<\/span> <span class=\"n\">cfg<\/span> <span class=\"o\">=<\/span> <span class=\"n\">Config<\/span>::<span class=\"n\">default<\/span><span class=\"p\">();<\/span>\n  <span class=\"kd\">let<\/span> <span class=\"k\">mut<\/span> <span class=\"n\">ctx<\/span>: <span class=\"nc\">Context<\/span><span class=\"o\">&lt;<\/span><span class=\"kt\">u8<\/span><span class=\"o\">&gt;<\/span> <span class=\"o\">=<\/span> <span class=\"n\">cfg<\/span><span class=\"p\">.<\/span><span class=\"n\">new_context<\/span><span class=\"p\">().<\/span><span class=\"n\">unwrap<\/span><span class=\"p\">();<\/span>\n  <span class=\"kd\">let<\/span> <span class=\"n\">f1<\/span> <span class=\"o\">=<\/span> <span class=\"n\">ctx<\/span><span class=\"p\">.<\/span><span class=\"n\">new_frame<\/span><span class=\"p\">();<\/span>\n  <span class=\"kd\">let<\/span> <span class=\"n\">f2<\/span> <span class=\"o\">=<\/span> <span class=\"n\">f1<\/span><span class=\"p\">.<\/span><span class=\"n\">clone<\/span><span class=\"p\">();<\/span>\n  <span class=\"kd\">let<\/span> <span class=\"n\">info<\/span> <span class=\"o\">=<\/span> <span class=\"n\">FrameParameters<\/span> <span class=\"p\">{<\/span>\n    <span class=\"n\">frame_type_override<\/span>: <span class=\"nc\">FrameTypeOverride<\/span>::<span class=\"n\">Key<\/span>\n<span class=\"p\">};<\/span>\n\n  <span class=\"c1\">\/\/ Send the plain frame data<\/span>\n  <span class=\"n\">ctx<\/span><span class=\"p\">.<\/span><span class=\"n\">send_frame<\/span><span class=\"p\">(<\/span><span class=\"n\">f1<\/span><span class=\"p\">)<\/span><span class=\"o\">?<\/span><span class=\"p\">;<\/span>\n  <span class=\"c1\">\/\/ Send the data and the per-frame parameters<\/span>\n  <span class=\"c1\">\/\/ In this case the frame is forced to be a keyframe.<\/span>\n  <span class=\"n\">ctx<\/span><span class=\"p\">.<\/span><span class=\"n\">send_frame<\/span><span class=\"p\">((<\/span><span class=\"n\">f2<\/span><span class=\"p\">,<\/span> <span class=\"n\">info<\/span><span class=\"p\">))<\/span><span class=\"o\">?<\/span><span class=\"p\">;<\/span>\n  <span class=\"c1\">\/\/ Flush the encoder, it is equivalent to a call to `flush()`<\/span>\n  <span class=\"n\">ctx<\/span><span class=\"p\">.<\/span><span class=\"n\">send_frame<\/span><span class=\"p\">(<\/span><span class=\"nb\">None<\/span><span class=\"p\">)<\/span><span class=\"o\">?<\/span><span class=\"p\">;<\/span>\n<\/pre>\n<\/div>\n<h4>Multipass rate control<\/h4>\n<p>It is possible to use <code>Context::twopass_out()<\/code> to feed back the rate control information that <code>Context::twopass_in()<\/code> can produce.<\/p>\n<p>The API is intentionally opaque to the point you deal with pre-serialized data and not structured information.<\/p>\n<h4>Config validation<\/h4>\n<p>We added <code>Config::validate()<\/code> to make sure the settings are correct and return a detailed error (<code>InvalidConfig<\/code>) if that&#8217;s not the case.<\/p>\n<h3>Speed<\/h3>\n<p>We overall made it a lot faster:<\/p>\n<div class=\"codehilite\">\n<pre><span class=\"mi\">15<\/span><span class=\"o\">:<\/span><span class=\"mi\">23<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">koda<\/span><span class=\"o\">&gt;<\/span> <span class=\"n\">hey<\/span> <span class=\"n\">guys<\/span><span class=\"o\">,<\/span> <span class=\"n\">did<\/span> <span class=\"n\">an<\/span> <span class=\"n\">encode<\/span> <span class=\"k\">with<\/span> <span class=\"n\">the<\/span> <span class=\"k\">new<\/span> <span class=\"mf\">0.1<\/span><span class=\"o\">.<\/span><span class=\"mi\">0<\/span><span class=\"o\">,<\/span> <span class=\"mi\">20<\/span> <span class=\"n\">hours<\/span> <span class=\"k\">for<\/span> <span class=\"mi\">8<\/span> <span class=\"n\">minutes<\/span><span class=\"o\">,<\/span> <span class=\"n\">down<\/span> <span class=\"n\">from<\/span> <span class=\"mi\">32<\/span> <span class=\"n\">hours<\/span> <span class=\"n\">using<\/span> <span class=\"n\">a<\/span> <span class=\"n\">two<\/span> <span class=\"n\">month<\/span> <span class=\"n\">old<\/span> <span class=\"n\">build<\/span>\n<span class=\"mi\">15<\/span><span class=\"o\">:<\/span><span class=\"mi\">23<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">koda<\/span><span class=\"o\">&gt;<\/span> <span class=\"n\">congrats<\/span> <span class=\"o\">(<\/span><span class=\"n\">and<\/span> <span class=\"n\">thanks<\/span><span class=\"o\">)<\/span> <span class=\"k\">for<\/span> <span class=\"n\">making<\/span> <span class=\"n\">these<\/span> <span class=\"n\">speed<\/span> <span class=\"n\">improvements<\/span>\n<\/pre>\n<\/div>\n<p>And we are still working to speed it up a lot. The current weekly snapshot is an additional 20-25% faster compared to 0.1.0.<\/p>\n<p><strong>NOTE<\/strong>: <code>rav1e<\/code> is still resources conscious, so it will not use all the threads and memory available. This makes it good if you want to encode multiple videos in parallel, but we will work on adding additional parallelism so even the single-video scenario is covered better.<\/p>\n<h2>What&#8217;s next<\/h2>\n<p>Ideally a <code>0.2.0<\/code> will appear the early December, it will contain many speed improvements, lots of bugfixes (in particular docs.rs will serve the documentation) and possibly a large boost in single-pass quality if what Tim and Guillaume are working on will land in time.<\/p>\n<p>For those that want to try it in Gentoo a <a href=\"https:\/\/packages.gentoo.org\/packages\/media-video\/rav1e\">live package is available<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Intro AV1 is a modern video codec brought to you by an alliance of many different bigger and smaller players in the multimedia field. I&#8217;m part of the VideoLan organization and I spent quite a bit of time on this codec lately. rav1e: The safest and fastest AV1 encoder, built by many volunteers and Mozilla\/Xiph &hellip; <a href=\"https:\/\/blogs.gentoo.org\/lu_zero\/2019\/11\/23\/rav1e-0-1-0-made-in-tokyo\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">rav1e-0.1.0 Made in Tokyo<\/span><\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1aGWH-c6","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/750"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/comments?post=750"}],"version-history":[{"count":1,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/750\/revisions"}],"predecessor-version":[{"id":751,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/750\/revisions\/751"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/media?parent=750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/categories?post=750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/tags?post=750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}