This tutorial is about transcoding video fom one codec into another using
[url=http://ffmpeg.org/]FFMPEG[/url]
. I got deeper into FFMPEG when I wanted to transcode into FLV (Flash Video) and it works very well. I developed the
[url=http://rivavx.de/?encoder]Riva FLV Encoder[/url]
, a GUI for FFMPEG.
We install the Minimalist GNU for Windows MinGW (Compiler) and MSYS (Minimal SYStem) which is a kind of unix-shell to access the MinGW-commands. Next we download, compile and install Lame, an open-source mp3-codec, with MSYS. Next we install WinCVS and checkout the latest cvs-release of FFMPEG. Finally we compile ffmpeg and I will show a few examples how to work with Flash Video (FLV).
- Download
[url=http://www.mingw.org/]MinGW ” MSYS current releases[/url]
(Window Exe Binaries MSYS-1.0.10.exe & MinGW-3.1.0-1.exe)
HINT: During the Postinstall be sure to set the right path to MinGW with a “/” instead of a Windows-”". If you did it wrong anyway re-install MSYS to the same directory and do the postinstall right (I missed it a few times)
- Download and compile
[url=http://lame.sourceforge.net/download/download.html]Lame[/url]
Extract Lame to your MSYS home-directory
Open MSYS and change to your lame-directory (cd ../lame-XXX)
Enter the following commands:
[b]CODE:[/b]
- ./configure //(takes a few minutes)
- make //(lame is being comiled; takes a few minutes, too)
- make install
After installing you will recognize that there are new directories and files in MSYS/local which we will use while compiling ffmpeg with mp3-support
- Download WinCVS (http://www.wincvs.org) and install it
Open the Command-Line window (CTRL-L) and enter the command:
[b]CODE:[/b]
- cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg
Select “Execute for directory” and browse to you MSYS-Directory and select your home-directory (“home”)
Press “OK” and the current cvs release will be checked out into your home-directory
- Compile FFMPEG
Change the directory in MSYS to your ffmpeg-directory (cd ../ffmpeg)
Enter the command:
[b]CODE:[/b]
- ./configure –enable-memalign-hack –enable-mingw32 –enable-mp3lame –extra-cflags=-I/local/include –extra-ldflags=-L/local/lib
HINT: you can paste into MSYS by pressing your center mouse-button
- “–enabled-memalign-hack” is a Windows hack. Without this option ffmpeg always crashs with the message “removing common factors from framerate” when encoding AVIs.
- “–enable-mingw32″. I see no difference without it but we compile with MinGW and it would not do a harm when ffmpeg knows this
- “–enable-mp3lame”: Enable transcoding audio with the open-source mp3-lame-codec
- “–extra-cflags=-I/local/include –extra-ldflags=-L/local/lib”: The cflags- and ldflags-parameter sets the right path to your lame-installation which you did in step 3.d.
Enter command: make (ffmpeg is being compiled; takes a few minutes)
With “make install” you could now copy the ffmpeg.exe to c:Program Filesffmpeg. But there is no need to.
- Use FFMPEG
Copy your compiled ffmpeg.exe from your MSYS directory to the directory where you like to transcode with ffmpeg
Open the Dos-Shell and change to the directory where you copied the ffmpeg.exe
Copy a test.mpg into your directory and enter the following command:
[b]CODE:[/b]
- ffmpeg -i test.mpg -ab 56 -ar 22050 -b 500 -r 15 -s 320×240 test.flv
Your first FLV should be encoded now
- Render Images from a Video
Enter command:
[b]CODE:[/b]
- ffmpeg -an -y -t 0:0:0.001 -i test.flv -f image2 test%d.jpg
HINT: With -t you set the length of images to be extracted. Above we entered 1 millisecond the extract one image. If you miss this parameter all images of the video will be extracted
[b]ZLib Support[/b] (e.g. for TSCC and Quicktime codecs). This should be compiled into FFMPEG. It is not an explicit compile in the configure statement. Do the following steps and after configure you should see that zlib is “on”.
[url=http://www.gzip.org/zlib]Download[/url]
and compile ZLib
Extract the files to your mysys directory
Change the directory in MSYS to that directory
Enter command ./confugure, make and make install.
[b]CODE:[/b]
- cp /local/lib/libz.a /mingw/lib/.
- cp /local/include/zlib.h /mingw/include/.
- cp /local/include/zconf.h /mingw/include/.
[b]AC3 Support[/b]
Add “–enable-a52 –enable-gpl” to your configure command
[b]3GP Support[/b]
If you want to enable 3GP support you have to add the AMR audio codec. Download the TS26.104
REL-5 V5.1.0 26104-5??.zip
[url=http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series]here[/url]
. Extract the codec into libavcodec/amr_float and add “–enable-amr_nb” to your configure command
[b]XVID Support[/b] (thanks to garvin.thornten at datel.co.uk)
Download and install the codec from
[url=http://www.xlib.org/]www.xlib.org[/url]
(see xvidcore-xxxx/doc/install). Add “–enable-xvid –enable-gpl” to your configure command. When compiling with xvid codec in MinGW or cygwin you will get a “mkstemp” error when compiling “xvidff.c”. To fix this edit “libavcodec/xvidff.c” and add the following after the #includes. This will probably be fixed in a future ffmpeg release: ´
[b]C:[/b]
- /* Added for windows compile —————– */
- #include
-
- int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2); void xvid_correct_framerate(AVCodecContext *avctx);
-
- int mkstemp(char* template)
- {
- char temppath[512];
- if(GetTempPath(512,temppath)!=0)
- {
- if(GetTempFileName(temppath,“fil”,0,template)!=0)
- {
- FILE *pFile;
- pFile=fopen(template,“w+”);
- if(pFile!=NULL)
- return (int)pFile;
- }
- }
- return -1;
- }
- /* ——————————————- */
-
Link about
[url=http://qstream.org/usage.html]qscale[/url]
removed “-f singlejpeg” as its identical to “-f mjpeg”