欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[ffmpeg]记录一下编译ffmpeg过程中的踩坑

程序员文章站 2022-07-01 09:29:09
...

 编译环境win10 64位,目标是编译出32位可以进行视频音频压制操作的ffmpeg。

操作过程和网上大部分博客描述相同,本篇特别将踩坑部分记录下来

 

1.编译lame3.99.5出错,在点击make后出现如下错误

make[3]: *** [xmm_quantize_sub.lo] Error 1
make[3]: Leaving directory '/c/Users/saghul/work/MINGW-packages/mingw-w64-lame/src/build-i686-w64-mingw32/libmp3lame/vector'
Makefile:547: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/c/Users/saghul/work/MINGW-packages/mingw-w64-lame/src/build-i686-w64-mingw32/libmp3lame'
Makefile:349: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/c/Users/saghul/work/MINGW-packages/mingw-w64-lame/src/build-i686-w64-mingw32'
Makefile:276: recipe for target 'all' failed
make: *** [all] Error 2

 解决方法:直接删除 configure 文件中 xmmintrin.h

 

2编译xvid过程,make之后出错

如果make时出现:cc1.exe: error: unrecognized command line option '-mno-cygwin' 错误,请在./configure后make之前修改xvidcore\build\generic里的 platform.inc文件,直接删除里面的“-mno-cygwin”。

这里参考了http://blog.csdn.net/xi52qian/article/details/10122731

 

3.编译faac过程中出错

make[3]: *** [3gp.o] Error 1
make[3]: Leaving directory `/d/ffmpeg/faac-1.28/common/mp4v2'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/d/ffmpeg/faac-1.28/common'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/d/ffmpeg/faac-1.28'
make: *** [all] Error 2

 新建一个文件faac-1.28.diff,打开,把下面的内容复制上去

diff -urN faac-1.28.orig/common/mp4v2/mpeg4ip_win32.h faac-1.28/common/mp4v2/mpeg4ip_win32.h
--- faac-1.28.orig/common/mp4v2/mpeg4ip_win32.h	Sun Jan 25 10:14:34 2009
+++ faac-1.28/common/mp4v2/mpeg4ip_win32.h	Wed Feb 11 11:38:32 2009
@@ -42,26 +42,39 @@
 #include <stdlib.h>
 #include <time.h>
 #include <limits.h>
+#include <ctype.h>
 
 #ifndef inline
 #define inline __inline
 #endif
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
 typedef unsigned __int64 uint64_t;
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int16 uint16_t;
 typedef unsigned __int8 uint8_t;
-typedef unsigned __int64 u_int64_t;
-typedef unsigned __int32 u_int32_t;
-typedef unsigned __int16 u_int16_t;
-typedef unsigned __int8 u_int8_t;
 typedef signed __int64 int64_t;
 typedef signed __int32 int32_t;
 typedef signed __int16 int16_t;
 typedef signed __int8  int8_t;
+#endif
+typedef unsigned __int64 u_int64_t;
+#ifndef HAVE_U_INT32_T
+#define HAVE_U_INT32_T
+typedef unsigned __int32 u_int32_t;
+#endif
+#ifndef HAVE_U_INT16_T
+#define HAVE_U_INT16_T
+typedef unsigned __int16 u_int16_t;
+#endif
+typedef unsigned __int8 u_int8_t;
 typedef unsigned short in_port_t;
 typedef int socklen_t;
-typedef int ssize_t;
+/*typedef int ssize_t;*/
 typedef unsigned int uint;
+/*
 static inline int snprintf(char *buffer, size_t count,
 			  const char *format, ...) {
   va_list ap;
@@ -75,11 +88,14 @@
   }
   return ret;
 }
+*/
 #define strncasecmp _strnicmp
 #define strcasecmp _stricmp
 #define localtime_r(a,b) localtime_s(b,a)
+/*
 #define printf printf_s
 #define fprintf fprintf_s
+*/
 
 #include <io.h>
 #include <fcntl.h>
@@ -124,8 +140,13 @@
 #define U64F  "I64u"
 #define X64F "I64x"
 
+#if defined(__WINDOWS__) && !defined(__MINGW32__)
 #define TO_D64(a) (a##I64)
 #define TO_U64(a) (a##UI64)
+#else
+#define TO_D64(a) (a##LL)
+#define TO_U64(a) (a##ULL)
+#endif
 
 #define LOG_EMERG 0
 #define LOG_ALERT 1
diff -urN faac-1.28.orig/frontend/Makefile.am faac-1.28/frontend/Makefile.am
--- faac-1.28.orig/frontend/Makefile.am	Tue Dec 16 09:56:00 2008
+++ faac-1.28/frontend/Makefile.am	Wed Feb 11 12:29:18 2009
@@ -5,7 +5,7 @@
 
 if WITH_MP4V2
 INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/common/mp4v2
-LDADD = $(top_builddir)/libfaac/libfaac.la $(top_srcdir)/common/mp4v2/libmp4v2.a -lm -lstdc++
+LDADD = $(top_builddir)/libfaac/libfaac.la $(top_srcdir)/common/mp4v2/libmp4v2.a -lm -lstdc++ -lws2_32
 else
 INCLUDES = -I$(top_srcdir)/include 
 LDADD = $(top_builddir)/libfaac/libfaac.la -lm

 保存,在执行$./bootstrap之前首先执行  $ patch -p1 < faac-1.28.diff

4.编译完成之后编码速度慢的问题

在第一遍编译完成后,尝试进行视频压制时出现了速度特别慢的问题。speed只能达到0.15左右,但是官网下载的share版本却能达到0.7。压制时提示libx264 using cpu capabilities none

用了很多办法,比如用最新版的yasm重新编译等等都没能解决。

最终解决办法是在编译x264的时候,网上大部分给出的config是$./configure --enable-shared --disable-asm

在这里把 --disable-asm去掉,重新编译一个libx264之后,覆盖到ffmpeg的bin目录下,重新运行之后速度就上去了

相关标签: ffmpeg