使用的环境是3.4.1
xvidcore1.1.3
键入:#CC=arm-linux-gcc ./configure --prefix=/usr/local/arm/arm-linux --build=i686-pc-linux --host=arm-linux --target=arm-linux
#make
#make install
在进入example目录
输入
arm-linux-gcc -o xvid_encraw xvid_encraw.c -lc -lm -I../src/ -L../build/generic/=build -lxvidcore
即可生成xvid_encraw
file 这个文件:for linux 2.4.3
x264-20060805-2245:
./configure --prefix=/usr/local/arm/arm-linux --enable-shared --enable-debug
得到的文件,需要修改config.mak
ARCH = ARM
CC=arm-linux-gcc
去掉CFLAGS中 -DHAVE_MMXEXT -DHAVE_SSE2 -DARCH_X86
LDFLAGS中添加 -s
修改Makefile 文件66~68
arm-linux-ar rc
arm-linux-ranlib
然后make && make install
出现错误:
common/cpu.c: In function `x264_cpu_num_processors':
common/cpu.c:172: error: `cpu_set_t' undeclared (first use in this function)
common/cpu.c:172: error: (Each undeclared identifier is reported only once
common/cpu.c:172: error: for each function it appears in.)
common/cpu.c:172: error: parse error before ')' token
make: *** [common/cpu.o] Error 1
解决办法:
在common/cpu.c中找到x264_cpu_num_processors这个函数,在这个函数中有如下代码,功能是得到你的电脑cpu的个数:
#elif defined(SYS_LINUX) || defined(WIN32)
int np;
#if defined(WIN32)
uint32_t p_aff, s_aff;
GetProcessAffinityMask( GetCurrentProcess(), &p_aff, &s_aff );
#else
// uint64_t p_aff;
// sched_getaffinity( 0, sizeof(p_aff), (cpu_set_t*)&p_aff );
#endif
// for( np = 0; p_aff != 0; p_aff >>= 1 )
// np += p_aff&1;
np =1;//此处就是你电脑cpu的个数
return np;
然后重新make,这个问题就解决了。
ffmpeg0.5:
root@ubuntu:/home/thinkpad/tools/ffmpeg-0.5# ./configure --prefix=/usr/local/arm/arm-linux/ --enable-cross-compile --arch=libavcodec/armv4l/ --cross-prefix=/usr/local/arm/3.4.1/bin/arm-linux- --cc=gcc --enable-static --disable-ipv6 --enable-libx264 --enable-gpl --enable-pthreads --target-os=linux --disable-network --enable-swscale --enable-shared --extra-libs=/usr/local/arm/arm-linux/lib/
然后再configure,如果还有错误,如:
ERROR: x264 not found 你在configure时把libx264库加上就可以了:--extra-libs=/usr/local/lib/ 此路径是你的x264的安装路径。
WARNING: Unknown CPU "./libavcodec/armv4l/", ignored.这个错误要将--cpu=libavcodec/armv4l/改成--arch=libavcodec/armv4l/
如果出现如下错误,
/usr/local/arm/2.95.3/bin/arm-linux-gcc is unable to create an executable file.
C compiler test failed.
会发现只要去掉--extra-libs=/usr/local/lib/后,这个错误就没了,但是有ERROR: x264 not found 那个错误,郁闷,怎么解决呢?
......
查看config.log 如下:
gcc /usrlocal/arm/arm-linux/lib/libx264.a -o /tmp/ffconf.** /tmp/
****
/usrlocal/arm/arm-linux/lib/libx264.so could not read symbols : file in wrong format
于是修改--c=/usr/local/arm/3.4.1/bin/arm-linux-gcc 编译再次出现x264找不到,查看log x264.h:no such file or directory
修改:--extra-libs=-L/usr/local/arm/arm-linux/lib/ --extra-ldflags=-L/usr/local/arm/arm-linux/lib/ --extra-cflags=-I/usr/local/arm/arm-linux/include/
报错:libx264 version must be >= 0.99
使用ffmpeg 0.4.9:
./configure --prefix=/usr/local/arm/arm-linux/ --cpu=libavcodec/arm/ --cross-prefix=/usr/local/arm/3.4.1/bin/arm-linux- --cc=gcc --enable-xvid --enable-x264 --enable-gpl --disable-opts --disable-dv1394 --disable-network --enable-shared --extra-libs=-L/usr/local/arm/arm-linux/lib/ --extra-ldflags=-L/usr/local/arm/arm-linux/lib/ --extra-cflags=-I/usr/local/arm/arm-linux/include/
make 的时候错误:
x264.c: In function `X264_init':
x264.c:151: error: structure has no member named `b_cbr'
make[1]: *** [x264.o] Error 1
make[1]: Leaving directory `/home/thinkpad/tools/ffmpeg-0.4.9-p20060302/libavcodec'
make: *** [lib] Error 2
代码不匹配,还是重新下载一个x264:
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20070416-2245.tar.bz2
有人说这样搭配:
Use ffmpeg-0.4.9_p20060816 for x264-svn-20060810 and ffmpeg-0.4.9_p20061016 for此文件是在window下写的,所以在每行后面会加个ctrl+m就是^M,所以后面的sh就变成sh^M当然是没有这个命令的,所以脚本就不能运行了,把^M去掉就应该没问题了。
输入命令:dos2unix configure 把它转化成linux文件。
如果没有dos2unix此命令,可用此方法:
cat ./configure.sh | tr -d ‘/r’ > temp.sh
mv temp.sh configure.sh
报错:You must include stdint.h or inttypes.h before x264.h
是应为在usr/local/include/ 目录存在一个之前编译的x264.h文件,把他酸楚就可以了。
每次configure 之前都要注意 make distclean 清除之前的痕迹