Video Convert via the command line

Published by

Posted on August 27, 2008

Ubuntu Howto
https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide

Lame mp3 Library
download: http://sourceforge.net/projects/lame

then compile and install:

$ ./configure
$ make
$ make install
Place program in a folder in the classpath, or create symbolic link in usr/bin (or else in classpath) to point to the installation of lame. You can type the following to test install was succesful:

$ lame –help
[edit]Ffmpeg

[edit]Install
website: http://ffmpeg.sourceforge.net/

1) The CVS server has been retired, ffmpeg now require you to install subversion (“apt-get install subversion” on debian) and use that:

$ svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
2) configure, compile and install:

$ ./configure –enable-libmp3lame –enable-gpl –enable-shared –enable-libfaad
$ make
$ make install
The –enable-libfaad option requires that libfaad has already been installed. This is a library for decoding mpeg4 audio (mp4a). If you don’t mind not having the ability to upload mpeg 4 audio then you won’t need it, but if you do want to be able to upload videos with mp4a encoding you’ll have to struggle to get the faad libraries installed.

NB: Some (older?) versions of ffmpeg used “–enable-faad” rather than “–enable-libfaad”, so if it doesn’t work, try the other option.

At the time of writing, I still can’t figure how how to do that on either Debian or OS X.

[edit]Pitfalls
Options with configure should work fine. You won’t need ffserver, so can add –disable-ffserver.

if you have problems and need to install again, try

$ make clean
then repeat step (2)

[edit]ffmpeg: error while loading shared libraries: libavformat.so: cannot open shared object file: No such file or directory
If the libavformat.so is installed in /usr/local/lib you may need to update /etc/ld.so.conf: add the line /usr/local/lib then type

$ ldconfig
You can also try a complete rebuild with:

$ ./configure options –prefix=/usr
This should place the ffmpeg executable where it can find the .so file, which is in /usr/local/lib

The second technique may be less invasive.

Note: also the lame library might give the same problem, but the ‘–prefix’ method might not fix, so update that ld.so.conf file.

[edit]Running ffmpeg
Gemin-i Plus uses the following script to convert to .FLV flash video format. Try from the command line to see if it works. inputfile.mov is a .mov file on your server, outputfile.flv is the name you’re giving to the converted file.

$ ffmpeg -i inputfile.mov -f flv -r 30 -y outputfile.flv
The above command produced slow movies on two installs. Try:

$ ffmpeg -i source.mov -ar 22050 -b 200 -r 12 -f flv -s 640×480 destination.flv
This will resize to 640×480.

For thumbnails, try:

$ ffmpeg -i source.avi -an -ss 00:00:03 -an -r 1 -s 300×200 -vframes 1 -y -pix_fmt rgb24 destination%d.jpg
You will get a file called destination1.jpg, which will show a scene three seconds into the movie you have to remove the 1 yourself, or write a script. There’s a theoretical possibility of getting more than one destination file, numbered 2 upwards.

The output filename MUST include %d or you will get the error below. The %d will turn into a number 1 once processed. unable for find a suitable output format for destination1.jpg

=================
Error
/usr/include/linux/videodev.h:56: error: syntax error before “ulong”
/usr/include/linux/videodev.h:72: error: syntax error before ‘}’ token
libavdevice/v4l.c: In function `grab_read_header’:

you will need to update the linux-headers or disable the demuxer –disable-demuxer=v4l during the ./configure process
===============
error
unable to install ffplay

make ffplay fails due to missing xorg-x11 headers andf libs and SDL

yum install SDL or *http://www.libsdl.org/index.php

Yum install xorg-x11

 

 

—————————————————————————–

 

examples

Video convert Examples

dv/mov to mp4/mov using avconv
vconv -i infile.mov -b 1000k -b:a 192k -r 65535/2733 -strict experimental outfile.mp4

From mp4 to webm(html5)
avconv -i Eric_Marners_The_Soul_of_Love_EPK.mp4 -f webm Eric_Marners_The_Soul_of_Love_EPK.webm

avi to webm using ffmpeg
ffmpeg -i film001.avi webm out.webm
mencoder dv to avi
mencoder infile.dv -mf fps=25 -o outfile.avi -ovc lavc -lavcopts vcodec=mpeg4 -oac mp3lame

mp3 to ogg
ffmpeg -i Bmore-Swagger.mp3 libvorbis -ab 6400 Bmore-Swagger.ogg
bitrate
-b 3900k > good quality

example
ffmpeg -i film001.avi -c:v libvpx -f webm -b 3900k out.webm


About the Author