Cookbook
From ActiveArchives
[edit] How to I convert to OGG?
[edit] Converting a Video to OGG/Theora
An example of a simple BASH script to transcode a file, using ffmpeg2theora.
The resulting movie uses OGG as the file (or container) format, and the Theora codec for the video data.
#!/bin/bash -x # # makeogv # i=$1 base=`basename $i` o=${base%.*}.ogv # ffmpeg -y -i "$i" -ac 2 -ab 80 -ar 48000 -acodec libvorbis -qscale 9 -r 15 -s 320x240 "$o" ffmpeg2theora -o "$o" --channels=2 --samplerate=48000 -x 320 -y 240 "$i"
[edit] Converting Audio to OGG/Vorbis
Here is an example of using ffmpeg to convert a WAV audio file into OGG/Voribs. Note that OGG is the file or "container" format, and "vorbis" is the actual compression technique (codec) for the audio.
This command uses the -ss and -t options to start at 3 minutes into the file (3*60 seconds), with a duration of 60 seconds.
ffmpeg -i xabier.wav -ss 180 -t 60 -acodec libvorbis -ab 192000 xabier_sample.ogg
[edit] How can I convert my movie into the flash (FLV) format?
An example of a simple BASH script to transcode a file, using ffmpeg.
#!/bin/bash -x # # makeflv # i=$1 base=`basename $i` o=${base%.*}.flv ffmpeg -y -i "$i" -ab 48 -ar 22050 -qscale 9 -r 15 -s 320x240 "$o"
[edit] Editing with mplayer / mencoder
Extracting a clip (cutting)
playing a particular portion in this case endpos determines the total duration of the shot (end position relative to adjusted start position)
mplayer -ss 2:05 -endpos 3 dvgrab-001.avi
Make an edit (extract to new file)
note -oac copy, -ovc copy, KEEP THE ORIGINAL FORMAT (fastest & no recompression/change of data, video quality unchanged) Here, we first make a subdirectory (clips) to hold (& later make selecting) the edits.
mkdir clips mencoder -ss 2:05 -endpos 3 dvgrab-001.avi -oac copy -ovc copy -o clips/01.avi
Make some more clips...
mencoder -ss 4:00 -endpos 3 dvgrab-001.avi -oac copy -ovc copy -o clips/02.avi mencoder -ss 2:00 -endpos 3 dvgrab-001.avi -oac copy -ovc copy -o clips/03.avi
View your "rough cut"...
mplayer clips/*
Try a random edit?
mplayer -shuffle clips/*
(or even ;)
mplayer -flip -shuffle clips/*
PERFORMING the edit
mencoder -oac copy -ovc copy -o edit.avi clips/*
Controlled loop, 2 times:
mencoder -oac copy -ovc copy -o edit2.avi edit.avi edit.avi
Example of "Appending multiple AVI" from net:
As a side-effect, the broken AVI fixer function enables MEncoder to append 2 (or more) AVI files:
cat 1.avi 2.avi | mencoder -noidx -ovc copy -oac copy -o output.avi -
Note: This expects 1.avi and 2.avi to use the same codecs, resolution, stream rate etc, and at least 1.avi must not be broken. You may need to fix your input AVI files first, as described above.
http://web.njit.edu/all_topics/Prog_Lang_Docs/html/mplayer/encoding.html
Compressing to a Flash Video(flv)
ffmpeg -y -i IN.OGG -ab 48 -ar 22050 -qscale 9 -r 15 -s 320x240 OUT.FLV
[edit] Capturing DV format video with dvgrab
dvgrab -format raw[edit] Transcoding to DV
using ffmpeg to go DV (avi)
ffmpeg -y -i dvgrab-001.avi -t 1 -s 640x480 -sameq -vcodec mjpeg -acodec copy dvmjff.avi then the whole movie mencoder -oac pcm -ovc lavc -lavcopts vcodec=mjpeg -o dvgrab0001mjpeg.avi dvgrab-001.avi mencoder -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=600 -o output.avi input.flv
[edit] How do I convert a Movie to Images
[edit] with ffmpeg
ffmpeg -i rearwindow.avi -f image2 -y -r .01 -an rearwindow%06d.jpg
[edit] with mplayer
mplayer -vo png rearwindow.avi
Use sstep to do a time lapse / select one frame per second
mplayer -sstep 25 -vo png rearwindow.avi
(see: mplayer -vo help for other opts)
[edit] How do I convert images to a movie?
Slideshow.py is an example using Python, ImageMagick, and mencoder to convert images into a "slideshow" movie.
[edit] Screen Grabbing
ffmpeg X11 grabbing!
ffmpeg -f x11grab -s cif -i :0.0 /tmp/out.mpg 0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable. ffmpeg -f x11grab -s cif -i :0.0+10,20 /tmp/out.mpg 0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable. 10 is the x−offset and 20 the y−offset for the grabbing.
[edit] How can I make audio files from a DVD?
Recently I wanted to make some individual audio files (MP3's) of audio on an "supplementary" audio track of a DVD.
I used mplayer's -dumpaudio option to select the particular audio track I had in mind:
mplayer -aid 130 -dumpaudio -vo null VTS_01_2.VOB
Then I used ffmpeg to convert the whole thing to mp3 format (this step is necessary only because I didn't figure out how to play the dump file with mplayer -- kind of weird that it doesn't recognize it's own dump format -- probably you can manually instruct it as to the format, but in any case ffmpeg recognizes and converting to mp3 allows mplayer to play it again).
ffmpeg -i stream.dump -ar 192000 stream.mp3
Then I figured out a start and end time using mplayer, subtract start from end to get duration, and plug this into ffmpeg. Apparently ffmpeg (version specific?) doesn't deal with time codes (like 3:18), and so values for start (-ss) and duration (-t) need to be given as seconds (so 3:19 becomes 199).
ffmpeg -i stream.mp3 -ss 44 -t 199 -y -ab 192000 03_NameMe.mp3
[edit] What are other good resources on the web?
- http://commons.wikimedia.org/wiki/Help:Converting_video
- http://internetarchive.wordpress.com/2008/11/25/fast-and-reliable-way-to-encode-theora-ogg-videos-using-ffmpeg-libtheora-and-liboggz/
[edit] Questions that are not on this page, but should be
- How to use the HTML5 <video> tag
- How to create an RSS feed
