2011年7月28日星期四

Build ffmpeg with libx264

Long time no see, my dear friends !! Lately I am building the ffmpeg for windows with H.264 support. In short, no lousy words :
  • Windows 7 x64 Ultimate
  • MingGW32 ver. 5.1.6 (following shows the MingGW32 system info by uname -a)
$ uname -a
      MINGW32_NT-6.1 LEON-PC 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys
  • Download sources of ffmpeg from air video for they did wonderful job for streaming video over 3G/Wifi to iphone/ipad from its Air Video Server. The version I downloaded is 2.4.5-beta6
  • Then download VLAN's x264 source. Initially, I downloaded the master stable version but I got trouble of "ERROR: libx264 version must be >= 0.99." when configure ffmpeg with x264 enabled.
$ ./configure --prefix=/mingw --enable-pic --enable-gprof --enable-static --enable-shared --enable-strip --enable-win32thread

 [code]enabled libx264 && require2 libx264 "stdint.h x264.h" x264_encoder_encode -lx264 && { check_cpp_condition x264.h "X264_BUILD >= 99" || die "ERROR: libx264 version must be >= 0.99."; }
  • Then I downloaded the source by git as :
git clone git://git.videolan.org/x264.git
  • Then configure again, the configure error of "ERROR: libx264 version must be >= 0.99." is solved.
  • Next, type make, however, got another trouble :
In file included from c:\msys\mingw\bin\../lib/gcc/mingw32/4.5.2-sjlj/../../../../include/pthread.h:288,
from libavcodec/pthread.c:24:
c:\msys\mingw\bin\../lib/gcc/mingw32/4.5.2-sjlj/../../../../include/sche
d.h:152: error: expected ')' before 'pid'
c:\msys\mingw\bin\../lib/gcc/mingw32/4.5.2-sjlj/../../../../include/sche
d.h:154: error: expected ')' before 'pid'
make: *** [libavcodec/pthread.o] Error 1
In sched.h line 116 you'll find:-

#if defined(__MINGW32__) || defined(_UWIN)
#if PTW32_LEVEL >= PTW32_LEVEL_MAX
/* For pid_t */
#  include <sys/types.h>
/* Required by Unix 98 */
#  include <time.h>
#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
#else
typedef int pid_t;
#endif 

Obviously, it is a bug, there is no definition for pid_t when __MINGW32__ is defined but PTW32_LEVEL < PTW32_LEVEL_MAX So, I modified to codes as:

#if defined(__MINGW32__) || defined(_UWIN)

#if PTW32_LEVEL >= PTW32_LEVEL_MAX

/* For pid_t */

#  include <sys/types.h>

/* Required by Unix 98 */

#  include <time.h>

#else /* PTW32_LEVEL < PTW32_LEVEL_MAX */

typedef int pid_t;

#endif

#endif
  • Now, type make again, Bingo! It works and I got ffmpeg.exe and libraries for ffmpeg.

    0 意見:

    最酷的Web相片欣賞工具 CoolIris