Various useful command lines when you are doign stuff with videos on linux.

To combine several videos into one:

mencoder -ovc copy -o new-output.avi ../intro/intro.avi ../test/build.avi ../outro/outro.avi

Combine video and sound from separate files:

ffmpeg -i no-sound-video.avi -i sound.mp3 -acodec copy -vcodec copy movie-sound.avi

The special vcodec and acodec value copy just copies the raw video data from one stream to the other. This means you need to have your video and sound in the final format/encoding already. You can use other codecs to do reencoding too.

Take a pile of images and make a movie from them:

ffmpeg -r 14 -f image2 -i ux15_%04d.jpg -pass 1/2 -vcodec mpeg4 -b 700k -author "Tim Head" -vtag xvid intro.avi

Again the -r parameter sets the frame rate. This will combine all jpgs named: ux15_0000.jpg, ux15_0001.jpg, ux15_0002.jpg, ... into a mpeg4 encoded file called intro.avi

Strip the audio from a video file, this case a flv but hsould work with all of them:

ffmpeg -i input.flv -f mp3 -vn -acodec copy output.mp3

Make a video file from a single frame:

ffmpeg -loop_input -vframes <number_of_frames> -i <input_file> <output_file> 

In two pass encoding you do not need the output file generated in the first pass (I think). To output to /dev/null instead of disc:

ffmpeg -f image2 -i ux15_%04d.jpg -pass 1 -vcodec mpeg4 -b 700k -author "Tim Head" -vtag xvid -f avi - > /dev/null

The - symbol says output to a pipe and we then just use plain output redirection to stop it from filling up the console. As ffmpeg can not guess your output format from the filename anymore you need to specify it with -f avi or what ever your choice is.

Parameter tweaking for mpeg4 output according to the ffmpeg faq:

ffmpeg -f image2 -i ux15_%04d.jpg -mbd rd -flags +4mv+trell+aic -cmp 2 -subcmp 2 -g 300  -pass 1/2 -vcodec mpeg4 -b 800k -author "Tim Head" -vtag xvid outro.avi

VideoEncoding (last edited 2008-08-12 10:13:45 by TimHead)