The following is a list of FFMPEG, MENCODER and one MPLAYER commands which I have found useful in practice. These have been done based on linux, but can also be replicated on windows. The scenarios are as follows:
I want to export a video for Youtube
ffmpeg -i input_file_name.xxx -vcodec libx264 -vpre slow -crf 22 -threads 0 output_file_name.mkv
I want to make a Youtube ready video from a sequence of frames
Example frame names: image_0001.png, image_0002.png, image_0003.png...
ffmpeg -f image2 -i image_%4d.png -vcodec libx264 -vpre slow -crf 22 -threads 0 output_video.mkv
I have a video and I want to export it to a sequence of frames
Resultant frame names: image_0001.png, image_0002.png, image_0003.png...
ffmpeg -i video.mkv image_%4d.png
I used recordMyDesktop and now I have a .ogv, but its not suitable for editing in Blender - it doesn't scrub and the response is slow.
Use mencoder to convert it to a .mjpeg and scale it down so it's more responsive - effectively creating a proxy.
mencoder -idx infile.ogv -ovc lavc -oac pcm -lavcopts vcodec=mjpeg -vf scale=640:480 -o outfile.avi
I want to record the Desktop to make a tutorial or demonstration:
Record the Desktop with no audio:
ffmpeg -f x11grab -r 1 -s 1280x800 -i :0.0 -vcodec libx264 -vpre lossless_ultrafast -threads 0 output2.mkv
Record the Desktop with audio:
ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 1 -s 1280x800 -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 output2.mkv
-r 1: This is the frame rate, if set to 1 it will record at 1 frame per second. you can append an additional -r 20 before output2.mkv to force playback to 20 frames per second, this will make the playback very fast. Set both of them to -r 20 or -r 25 for more regular playback.
-s 1280x800: My screen space is 1280x800 pixels. set this to the screen space you wish to use, -i :0.0 will be the top left corner.
I need to make a .mov of the recording so my sound buddy can work with it in his native program
ffmpeg -i input.mkv output.mov
I need to extract the audio from a video, use mplayer
mplayer -dumpaudio input.video -dumpfile output.mp3
I need to chop the recording into pieces less than 10mins -but I don't want to re-encode the video- so that Youtube will accept it
I now have the full video recording and an audio track for it. I can't just combine them and upload the video to Youtube because Youtube only allows uploads that are 10minutes or less in length. We need to chop them up. I do not recommend combining the audio to the video and then chopping it into chunks - I have experienced issues. Instead I find it better to chop the audio AND video into separate chunks and then combine those smaller chunks.
ffmpeg -i input.mkv -ss 00:00:00.000 -t 00:10:00.000 -vcodec copy output.mkv
ffmpeg -i input.mkv -ss 00:10:00.000 -t 00:10:00.000 -acodec copy output.mp3
Use these to create a bash script to batch the process:
#first cut video, then cut audio
ffmpeg -i video.mkv -ss 00:00:00.000 -t 00:10:00.000 -vcodec copy 01_output.mkv
ffmpeg -i audio.mp3 -ss 00:10:00.000 -t 00:10:00.000 -acodec copy 01_output.mp3
ffmpeg -i video.mkv -ss 00:10:00.000 -t 00:10:00.000 -vcodec copy 02_output.mkv
ffmpeg -i audio.mp3 -ss 00:10:00.000 -t 00:10:00.000 -acodec copy 02_output.mp3
I also want to crop the video so I don't expose the toolbar and extraneous window bars, use:
ffmpeg -i video.mkv -ss 00:00:00.000 -t 00:10:00.000 -vf crop=width:height:start-x:start-y -vcodec libx264 -vpre slow -crf 22 -threads 0 01_output.mkv
Note that with the crop flag we can no longer use -vcodec copy
-ss hh:mm:ss.xxx, this sets the starting point.
-t hh:mm:ss.xxx, this sets the duration.
Now I need to combine the chopped audio and video files, use mencoder
mencoder video.avi -audiofile audio.mp3 -ovc copy -oac copy -o output.avi
Use this in the bash script above to automatically combine the video and audio as they're chopped, or create a new one and run it:
#combine the video and audio chunks
mencoder 01_output.mkv -audiofile 01_output.mp3 -ovc copy -oac copy -o 01_output.mkv
mencoder 02_output.mkv -audiofile 02_output.mp3 -ovc copy -oac copy -o 02_output.mkv
You should now have chopped up video files with audio that are less than ten minutes long and can be uploaded to Youtube.
If I have a sequence of videos which I need to combine into one video file
If for example you have mutiple shots as videos and you need to combine them into one video.
mencoder -oac copy -ovc copy -idx -o whole.avi part1.avi part2.avi ...
Follow this guide to install ffmpeg on Ubuntu Maverick:
(It worked for me and I can be pretty stupid when it comes to these things)
This is all i'd done to install mencoder and mplayer:
sudo apt-get install mencoder mplayer
If you need codec packs:
sudo apt-get install libxine1-ffmpeg gxine mencoder mpeg2dec vorbis-tools id3v2 mpg321 mpg123 libflac++6 ffmpeg libmp4v2-0 totem-mozilla icedax tagtool easytag id3tool lame nautilus-script-audio-convert libmad0 libjpeg-progs libquicktime1 flac faac faad sox ffmpeg2theora libmpeg2-4 uudeview flac libmpeg3-1 mpeg3-utils mpegdemux liba52-0.7.4-dev
sudo apt-get install gstreamer0.10-ffmpeg gstreamer0.10-fluendo-mp3 gstreamer0.10-gnonlin gstreamer0.10-pitfdll gstreamer0.10-sdl gstreamer0.10-plugins-bad-multiverse gstreamer0.10-schroedinger gstreamer0.10-plugins-ugly-multiverse totem-gstreamer