{"id":70,"date":"2010-12-08T22:55:16","date_gmt":"2010-12-08T21:55:16","guid":{"rendered":"http:\/\/www.idoru.be\/notes\/?p=70"},"modified":"2010-12-08T23:30:35","modified_gmt":"2010-12-08T22:30:35","slug":"fast-and-reliable-way-to-encode-theora-ogg-videos-using-ffmpeg-libtheora-and-liboggz","status":"publish","type":"post","link":"http:\/\/www.idoru.be\/notes\/fast-and-reliable-way-to-encode-theora-ogg-videos-using-ffmpeg-libtheora-and-liboggz\/","title":{"rendered":"Fast and reliable way to encode Theora Ogg videos using ffmpeg, libtheora, and liboggz"},"content":{"rendered":"<p>if this doesn&#8217;t work for you:<em><br \/>\nffmpeg2theora in.mov -o out.ogv<br \/>\n<\/em>or<em><br \/>\nffmpeg2theora in.mov -v 8 -o out.ogv<br \/>\n<\/em>(To solve the video artefacts)<em><br \/>\n<\/em><br \/>\nTry the following:<\/p>\n<p>from <a href=\"http:\/\/blog.archive.org\/2008\/11\/25\/fast-and-reliable-way-to-encode-theora-ogg-videos-using-ffmpeg-libtheora-and-liboggz\/\">tracey jaquith at archive.org<\/a><\/p>\n<p>use ffmpeg to turn any video to \u201crawvideo\u201d.<br \/>\npipe its output to *another* ffmpeg to turn the video to \u201cyuv4mpegpipe\u201d.<br \/>\npipe its output to the libtheora tool.<br \/>\nfor videos with audio, ffmpeg create a vorbis audio .ogg file.<br \/>\nadd tasty metadata (with liboggz utils).<br \/>\ncombine the video and audio ogg files to an .ogv output!<\/p>\n<h3>Detailed example:<\/h3>\n<p>Video:<br \/>\nffmpeg -an -deinterlace  -s 400\u00d7300 -r 20.00 -i videofile.avi  -vcodec rawvideo -pix_fmt yuv420p -f rawvideo \u2013  | \u00a0ffmpeg -an -f  rawvideo   -s 400\u00d7300 -r 20.00 -i \u2013 -f yuv4mpegpipe \u2013  |  \u00a0libtheora-1.0\/lt-encoder_example \u2013video-rate-target 512k \u2013 -o tmp_video.ogv<\/p>\n<p><em>Why the double pipe above? Some videos could not go directly to   yuv4mpegpipe format such that libtheora (or ffmpeg2theora) would work   all the time.<\/em><\/p>\n<p><em>We convert to yuv420p in the rawvideo step because ffmpeg2theora has  (i  think) some known issues of not handling all yuv422 video inputs (i   found at least a few videos that did this).<\/em><\/p>\n<p>Audio:<br \/>\nffmpeg -y -i videofile.avi -vn -acodec libvorbis -ac 2 -ab 128k -ar 44100 tmp_audio.ogg<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #000000;\"> <\/span><\/p>\n<p><em>We do the vorbis audio outside of libtheora (or ffmpeg2theora) to avoid any issues with Audio\/Video sync.<\/em><br \/>\nAnnotate:<br \/>\noggz-comment tmp_audio.ogg -o tmp_audio_annotated.ogg TITLE=\u201da title\u201d   ARTIST=\u201dan artist\u201d   LICENSE=\u201dhttp:\/\/creativecommons.org\/licenses\/publicdomain\/\u201d DATE=\u201d2010\u2033   ORGANIZATION=\u201dan organisation name\u201d    LOCATION=http:\/\/someurl<\/p>\n<p><em>We add the metadata to the audio vorbis ogg because adding it to the   video ogv file wound up making the first video frame not a keyframe (!)<\/em><br \/>\nMerge:<br \/>\noggzmerge tmp_video.ogv tmp_audio_annotated.ogg -o out_videofile.ogv<\/p>\n<p>rm tmp_video.ogv tmp_audio.ogg tmp_audio_annotated.ogg<br \/>\nThis will end up working in <strong>Firefox 3.1 and greater \u2014 the new HTML \u201cvideo\u201d tag:<\/strong><\/p>\n<p><code>&lt;video controls=\u201dtrue\u201d autoplay=\u201dtrue\u201d src=\u201dhttp:\/\/somevideo.ogv\u201d&gt; &lt;\/video&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>if this doesn&#8217;t work for you: ffmpeg2theora in.mov -o out.ogv or ffmpeg2theora in.mov -v 8 -o out.ogv (To solve the video artefacts) Try the following: from tracey jaquith at archive.org use ffmpeg to turn any video to \u201crawvideo\u201d. pipe its output to *another* ffmpeg to turn the video to \u201cyuv4mpegpipe\u201d. pipe its output to the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-howto"],"_links":{"self":[{"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":13,"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":72,"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/posts\/70\/revisions\/72"}],"wp:attachment":[{"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.idoru.be\/notes\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}