Converting videos with ffmpeg to webm format under Ubuntu 14.04.

I just love ffmpeg, because it is so easy to use and scriptable.

Install FFMPEG on Ubuntu 14.04


sudo apt-add-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg

Convert a video to webm


ffmpeg -i video.avi -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis -q:a 6 -threads 4 video.webm

  • Adjust Video Quality (target bitrate) with -b:v , e.g. for 700kbit/s use -b:v 700k
  • NEVER omit the bitrate, it will use a very low bitrate by default which results in piss poor quality
  • Adjust audiobitrate using the quality indicator -q:a 6 is about 100-128 kbit/s, which was perfect for me

RTFM

ffmpeg has some brief and good tutorials on their site, definitively have a look at them:
https://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide
https://trac.ffmpeg.org/wiki/Encode/VP8

Interlaced Video

To convert interlaced video, add the yadif filter to deinterlace before encoding.

ffmpeg -i video.mpg -vf yadif -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis -q:a 6 -threads 4 video.webm

A shell script

Encodes any video in webm with 1000kbit/s average video bitrate and approx. 100-120 kbit/s audio.

Usage: ./encode2webm.sh foobar.avi

Result: foobar.webm

encode2webm.sh

#!/bin/bash

ffmpeg -i $1 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis -q:a 6 -threads 4 ${1%.*}.webm
pixelstats trackingpixel

Leave a comment

Your comment

Time limit is exhausted. Please reload the CAPTCHA.