Friday, June 27, 2008

Using libx264 codec with ffmpeg

This is the information about the input file :

$ ./ffmpeg.exe -i input.avi

Duration: 01:47:20.81, start: 0.000000, bitrate: 909 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 560x304 [PAR 1:1 DAR 35:19], 23.98 tb(r)

Stream #0.1: Audio: mp3, 48000 Hz, stereo, 32 kb/s

$./ffmpeg.exe -i input.avi -ss 0 -t 20 -vcodec libx264 out.mpg

then I tried to play out.mpg with VLC, but it only played the audio only.
Winamp, Windows Media player couldn't even play it.
Uploading to Youtube : Failed (invalid file format)
Used as a source file to a videoDisplay object in Adobe Flex,
: unable to play the file.
Uploading to Vimeo : There was a problem converting this video. Please contact vimeo help !

Thursday, June 26, 2008

Building ffmpeg with libx264/h.264/x264 on Cygwin(Wiindows XP)

I am assuming here that you already have a build setup for ffmpeg
under Cygwin and looking for how to add x264 codec to it.
If you are new to ffmpeg build under cygwin, you might want to check this.

Now, you need to do this :
1. Install git for cygwin
2. $ git clone git://

Go inside the x264 folder and
remove these from the file "configure" :
"-mno-cygwin" (source)


In my case it complained that nasm is missing, so I
downloaded and installed it for cygwin.

It will generate x264.h and libx264.a, which you have
to copy to /usr/include/ and /user/lib/ respectively.

Then inside the ffmpeg source folder :
./configure --disable-static --enable-shared --enable-memalign-hack --enable-libx264 --enable-gpl


and that should be it.


PS : Earlier I downloaded the x264 source code from here :

As it turned out, the version that is here and the version
that was expected by ffmpeg source code was different,
since after building x264 when I tried to build ffmpeg, I got these errors :

libavcodec/libx264.c: In function `X264_init':
libavcodec/libx264.c:151: error: structure has no member named `i_rc_method'

After which I tried to fetch some older versions from the SVN repository,
but for some reason it asked my username and password :

svn merge -rHEAD:280 x264.h
Authentication realm: df754926-b1dd-0310-bc7b-ec298dee348c
password for 'LENOVO':

It was then that I switched to the git repository of VLC.

Blog Archive