There is a counterpart for this page at [[WebM]] for VP8/WebM. What are the different ways (Ogg) Theora video can be encoded when using the command-line? There are apparently several different ways, of which I want to try to document here. <> == MPlayer and YUV == Bernhard Rosenkraenzer [[http://lists.mplayerhq.hu/pipermail/mplayer-users/2003-May/033491.html|provided the following script]] for encoding Theora via MPlayer. MPlayer is used to output both audio and video into lossless formats (PCM and YUV respectively), which are then fed into the reference Theora encoder. The below script has been modified to run on Debian. This is probably most suitable for headless servers. Also, MPlayer's output quality is excellent (it also has the most sophisticated output filters), so it may also yield the best-looking output. {{{#!highlight sh #!/bin/sh # Theora encoder -- encodes any video file playable by mplayer to Theora # (c) 2003 Ark Linux, written by Bernhard Rosenkraenzer # # Released under the GNU GPL v2 or if, and only if, the GPL v2 is ruled # invalid in a court of law, any subsequent version of the GPL. # # theora-encoder [-a x] [-A x] [-v x] [-V x] [-o x] [-aa x] [-va x] [-aspect x] file # -a Set audio quality (-1 [worst] to 10 [best]) # -A Set audio bitrate (not recommended, use -a instead) # -v Set video quality (0 [worst] to 10 [best]) # -V Set video bitrate (not recommended, use -v instead) # -o Set output filename # -aa Pass an argument to the audio decoder [mplayer] unchanged # -va Pass an argument to the video decoder [mplayer] unchanged # (e.g. to use mplayer's deinterlacer: # theora-encoder -o test.ogg -va -vop -va pp=lb test.avi # -aspect Set the aspect ratio of the input file (usually # autodetected) # file input file name # ARGS="" AUDIO="" VIDEO="" while [ "`echo $1 |cut -b1`" = "-" ]; do case $1 in -a|--audio-quality) shift ARGS="$ARGS -a $1" ;; -A|--audio-bitrate) shift ARGS="$ARGS -A $1" ;; -v|--video-quality) shift ARGS="$ARGS -v $1" ;; -V|--video-bitrate) shift ARGS="$ARGS -V $1" ;; -o|--output) shift DEST="$1" if [ "`echo $DEST |cut -b1`" != "/" ]; then DEST="`pwd`/$DEST" fi DEST="\"$DEST\"" ARGS="$ARGS -o $DEST" ;; -aa|--audio-arg) # Pass an argument to the audio decoder shift AUDIO="$AUDIO \"$1\"" ;; -va|--video-arg) # Pass an argument to the video decoder shift VIDEO="$VIDEO \"$1\"" ;; -aspect) # Aspect ratio of input file shift VIDEO="$VIDEO -aspect \"$1\"" ;; *) echo "WARNING: Unknown option $1 ignored!" >&2 esac shift done if [ -z "$1" -o "$#" != "1" ]; then cat >&2 <$DIR/run.sh <mplayer-audio.log & mplayer -vo yuv4mpeg -ao null -nosound $VIDEO $SRC &>mplayer-video.log & theora_encoder_example $ARGS stream.wav stream.yuv rm -rf $DIR EOF chmod +x $DIR/run.sh exec $DIR/run.sh }}} == MEncoder == MEncoder does not support the Ogg as a container to which you can encode. However, if you use a different container, recent versions of mencoder (need to find the minimum SVN revision/version) should work with libtheora (given support is compiled in). Something along the lines of should work: {{{ mencoder -ovc lavc -oac lavc -of lavf -lavfopts format=matroska -lavcopts acodec=vorbis:vcodec=libtheora input.avi -o output.mkv }}} However, this does not appear to work on Debian 6.0 (Squeeze). == ffmpeg2theora == [[http://v2v.cc/~j/ffmpeg2theora/|ffmpeg2theora]], obviously based on ffmpeg, is another Theora popular encoder. == VLC == VLC can either be used as a GUI encoder, or via the command-line: {{{#!highlight sh vlc foo.avi --sout-theora-quality=5 --sout-vorbis-quality=1 \ --sout="#transcode{vcodec=theo,vb=800,scale=1,deinterlace=0,\ acodec=vorb,ab=128,channels=2,samplerate=44100}:standard{access=file,\ mux=ogg,dst='foo.ogv'}" }}} Source: [[http://jimmac.musichall.cz/log/?p=901|How to get your clips on the web]] == GStreamer == {{{#!highlight sh gst-launch-0.10 filesrc location=/path/to/video/file.ext ! decodebin name=dbin dbin. ! queue ! ffmpegcolorspace ! theoraenc quality=32 ! queue ! mux. dbin. ! queue ! audioconvert ! vorbisenc quality=0.2 ! queue ! mux. oggmux name=mux ! progressreport ! filesink location=/output/path.ogv }}} Source: [[http://jimmac.musichall.cz/log/?p=901|How to get your clips on the web]] == Other information == More useful information on these pages: * [[http://wiki.xiph.org/index.php/VP3_to_Theora|VP3 to Theora]]: good tips on converting any format to Theora All-in-one GUI programs: * [[http://oggconvert.tristanb.net/|OggConvert]]: GNOME-based utility that uses GStreamer and enables easy conversion to Theora, Dirac, VP8/WebM, and Vorbis