[FFmpeg-user] formula for transcoding to ogv, shrinking an mkv

Lou lou at lrcd.com
Fri Jan 18 21:41:34 CET 2013


On Mon, 14 Jan 2013 11:52:27 -0600 (CST)
James Miller <gajs-f0el at dea.spamcon.org> wrote:

> I do some screencasting, that involves both video and audio capture, using 
> ffmpeg's x11grab. At the same time, I have upload limits at the site where 
> I wish to host these screencasts. On doing some reading and making a few 
> consultations, I decided I should record my screencasts in a lossless 
> format, then convert and shrink the resulting files prior to uploading.

A good idea.

> I'd like to try and develop a similar formula for converting and shrinking
> to ogv. The following incantation, which I developed by trial and error, 
> gives a result close to what I need:
> 
> ffmpeg -i infile.mkv -acodec libvorbis -ab 48k -ac 2 -vcodec libtheora 
> -preset slow -wpredp 0 -crf 22 -threads 0 outfile.ogv

Note that libvorbis will ignore "-preset slow -wpredp 0 -crf 22". These
appear to be libx264 options. libvpx can also has a -crf option, but it
does not work like -crf with libx264... So it appears that you're using
the default settings for libtheora which is probably -b:v 200k.

> But that results in a file about one-sixth the size of the lossless 
> original, while I'd like to make the outfile size more like one tenth. Can 
> anyone offer suggestions on yet further shrinking the resulting ogv file?

You have two main options for controlling video output size or quality:
using -b:v or -qscale:v. These are mutually exclusive and have
different uses. If you have a specific output file size that you're
targeting then use -b:v. This is an example where I wanted to make the
output file be about half the file size of the input. It worked, but it
looked bad because the input's encoder did a good job at its given
bitrate (and not all encoders are equal):

ffmpeg -i in.mkv -c:v libtheora -c:a libvorbis -b:v 1911k -b:a 128k
out.ogv

It may not be exact, but using -b:v should provide and output close to
your desired file size. Doing this in two passes may provide a better
looking video and the output file size will be the same, but it will
take almost twice as long to encode. See the x264 guide that Liam
linked to for a two-pass example that you can adapt for libtheora and a
method to determine what -b:v to use.

You can use -qscale:v if you don't care about output file size and just
want to apply a "constant quality" to the whole video(s). Some people
equate this with -crf with x264 but it's not quite the same. For
examples on that see:

High quality ogv files - possible?
http://avp.stackexchange.com/a/4230/1760


More information about the ffmpeg-user mailing list