公司需要做网络视频传输的相关项目,初步选定用这么几个东西FFMPEG,ORTP,Live555这么几个东东。研究了也有一个月了,把一些心得写出来,这篇文章主要介绍FFMPEG在windows上的编译。
四 编译步骤
1 安装 mingw 和 msys
执行下载文件:mingw-get-inst-20120426.exe,
在第3步选择“Download latest repository catalogues”
选择安装路径:D:\Files\MinGW
在“Select Components”步骤中选择:
√ C Compiler (默认且一定选择)
√ C++ Compiler
√ MSYS Basic System(选择此项将会安装msys,msys则不需要另外安装)
√ MinGW Developer ToolKit
等待安装完成!(需要等待一定的时间,因为安装过程需要下载文件,可想而知,网速越快,安装越快)
安装完成后,在D:\Files\MinGW目录下可以看到 msys 文件夹,msys也已经安装。
2 配置 msys.bat 批处理文件
为了方便VS2010调用ffmpeg的动态库,可以通过配置让ffmpeg编译时产生windows下调用dll对应的lib,当然,如果你没有这个需要,那么就可以省略以下处理,直接进入步骤3。
进入:D:\Files\MinGW\msys\1.0\文件夹,使用UltraEdit打开msys.bat文件,在文件的最最前面加入如下一行:
1 call "D:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" 2 @echo off 3 rem Copyright (C): 2001, 2002, 2003, 2004, 2005 Earnie Boyd 4 rem mailto:[email protected] 5 rem This file is part of Minimal SYStem 6 rem http://www.mingw.org/msys.shtml 7 rem 8 rem File: msys.bat 9 rem Revision: 2.4 10 rem Revision Date: December 8th, 2005 11 rem ember to set the "Start in:" field of the shortcut. 12 rem A value similar to C:\msys\1.0\bin is what the "Start in:" field needs 13 rem to represent.
1 #ifndef _INTTYPES_H_ALL_ 2 #define _INTTYPES_H_ALL_ 3 4 // _INTTYPES_H_SYS_: 编译器是否提供了<inttypes.h> 5 #undef _INTTYPES_H_SYS_ 6 #if defined(__GNUC__) // GCC. 7 #define _INTTYPES_H_SYS_ 8 #elif defined(_MSC_VER) // MSVC. VC2010仍不支持. 9 #elif defined(__BORLANDC__) // BCB. BCB6仍不支持. 10 #else 11 #define _INTTYPES_H_SYS_ // 假设其他编译器支持C99. 12 #endif // _INTTYPES_H_SYS_ 13 14 15 #ifdef _INTTYPES_H_SYS_ 16 // 使用编译器提供的<inttypes.h> 17 #include <inttypes.h> 18 #else 19 // 采用自定义的inttypes.h. 参考了 msinttypes: http://code.google.com/p/msinttypes/ 20 21 #ifndef _MSC_INTTYPES_H_ // [ 22 #define _MSC_INTTYPES_H_ 23 24 #include "stdint.h" 25 26 // 7.8 Format conversion of integer types 27 28 typedef struct { 29 intmax_t quot; 30 intmax_t rem; 31 } imaxdiv_t; 32 33 // 7.8.1 Macros for format specifiers 34 35 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 36 37 // The fprintf macros for signed integers are: 38 #define PRId8 "d" 39 #define PRIi8 "i" 40 #define PRIdLEAST8 "d" 41 #define PRIiLEAST8 "i" 42 #define PRIdFAST8 "d" 43 #define PRIiFAST8 "i" 44 45 #define PRId16 "hd" 46 #define PRIi16 "hi" 47 #define PRIdLEAST16 "hd" 48 #define PRIiLEAST16 "hi" 49 #define PRIdFAST16 "hd" 50 #define PRIiFAST16 "hi" 51 52 #if defined(_MSC_VER) && _MSC_VER<=1200 // VC6 53 #define PRId32 "d" 54 #define PRIi32 "i" 55 #define PRIdLEAST32 "d" 56 #define PRIiLEAST32 "i" 57 #define PRIdFAST32 "d" 58 #define PRIiFAST32 "i" 59 #else 60 #define PRId32 "I32d" 61 #define PRIi32 "I32i" 62 #define PRIdLEAST32 "I32d" 63 #define PRIiLEAST32 "I32i" 64 #define PRIdFAST32 "I32d" 65 #define PRIiFAST32 "I32i" 66 #endif 67 68 #define PRId64 "I64d" 69 #define PRIi64 "I64i" 70 #define PRIdLEAST64 "I64d" 71 #define PRIiLEAST64 "I64i" 72 #define PRIdFAST64 "I64d" 73 #define PRIiFAST64 "I64i" 74 75 #define PRIdMAX "I64d" 76 #define PRIiMAX "I64i" 77 78 #define PRIdPTR "Id" 79 #define PRIiPTR "Ii" 80 81 // The fprintf macros for unsigned integers are: 82 #define PRIo8 "o" 83 #define PRIu8 "u" 84 #define PRIx8 "x" 85 #define PRIX8 "X" 86 #define PRIoLEAST8 "o" 87 #define PRIuLEAST8 "u" 88 #define PRIxLEAST8 "x" 89 #define PRIXLEAST8 "X" 90 #define PRIoFAST8 "o" 91 #define PRIuFAST8 "u" 92 #define PRIxFAST8 "x" 93 #define PRIXFAST8 "X" 94 95 #define PRIo16 "ho" 96 #define PRIu16 "hu" 97 #define PRIx16 "hx" 98 #define PRIX16 "hX" 99 #define PRIoLEAST16 "ho" 100 #define PRIuLEAST16 "hu" 101 #define PRIxLEAST16 "hx" 102 #define PRIXLEAST16 "hX" 103 #define PRIoFAST16 "ho" 104 #define PRIuFAST16 "hu" 105 #define PRIxFAST16 "hx" 106 #define PRIXFAST16 "hX" 107 108 #if defined(_MSC_VER) && _MSC_VER<=1200 // VC6 109 #define PRIo32 "o" 110 #define PRIu32 "u" 111 #define PRIx32 "x" 112 #define PRIX32 "X" 113 #define PRIoLEAST32 "o" 114 #define PRIuLEAST32 "u" 115 #define PRIxLEAST32 "x" 116 #define PRIXLEAST32 "X" 117 #define PRIoFAST32 "o" 118 #define PRIuFAST32 "u" 119 #define PRIxFAST32 "x" 120 #define PRIXFAST32 "X" 121 #else 122 #define PRIo32 "I32o" 123 #define PRIu32 "I32u" 124 #define PRIx32 "I32x" 125 #define PRIX32 "I32X" 126 #define PRIoLEAST32 "I32o" 127 #define PRIuLEAST32 "I32u" 128 #define PRIxLEAST32 "I32x" 129 #define PRIXLEAST32 "I32X" 130 #define PRIoFAST32 "I32o" 131 #define PRIuFAST32 "I32u" 132 #define PRIxFAST32 "I32x" 133 #define PRIXFAST32 "I32X" 134 #endif 135 136 #define PRIo64 "I64o" 137 #define PRIu64 "I64u" 138 #define PRIx64 "I64x" 139 #define PRIX64 "I64X" 140 #define PRIoLEAST64 "I64o" 141 #define PRIuLEAST64 "I64u" 142 #define PRIxLEAST64 "I64x" 143 #define PRIXLEAST64 "I64X" 144 #define PRIoFAST64 "I64o" 145 #define PRIuFAST64 "I64u" 146 #define PRIxFAST64 "I64x" 147 #define PRIXFAST64 "I64X" 148 149 #define PRIoMAX "I64o" 150 #define PRIuMAX "I64u" 151 #define PRIxMAX "I64x" 152 #define PRIXMAX "I64X" 153 154 #define PRIoPTR "Io" 155 #define PRIuPTR "Iu" 156 #define PRIxPTR "Ix" 157 #define PRIXPTR "IX" 158 159 // The fscanf macros for signed integers are: 160 #define SCNd8 "d" 161 #define SCNi8 "i" 162 #define SCNdLEAST8 "d" 163 #define SCNiLEAST8 "i" 164 #define SCNdFAST8 "d" 165 #define SCNiFAST8 "i" 166 167 #define SCNd16 "hd" 168 #define SCNi16 "hi" 169 #define SCNdLEAST16 "hd" 170 #define SCNiLEAST16 "hi" 171 #define SCNdFAST16 "hd" 172 #define SCNiFAST16 "hi" 173 174 #define SCNd32 "ld" 175 #define SCNi32 "li" 176 #define SCNdLEAST32 "ld" 177 #define SCNiLEAST32 "li" 178 #define SCNdFAST32 "ld" 179 #define SCNiFAST32 "li" 180 181 #define SCNd64 "I64d" 182 #define SCNi64 "I64i" 183 #define SCNdLEAST64 "I64d" 184 #define SCNiLEAST64 "I64i" 185 #define SCNdFAST64 "I64d" 186 #define SCNiFAST64 "I64i" 187 188 #define SCNdMAX "I64d" 189 #define SCNiMAX "I64i" 190 191 #ifdef _WIN64 // [ 192 # define SCNdPTR "I64d" 193 # define SCNiPTR "I64i" 194 #else // _WIN64 ][ 195 # define SCNdPTR "ld" 196 # define SCNiPTR "li" 197 #endif // _WIN64 ] 198 199 // The fscanf macros for unsigned integers are: 200 #define SCNo8 "o" 201 #define SCNu8 "u" 202 #define SCNx8 "x" 203 #define SCNX8 "X" 204 #define SCNoLEAST8 "o" 205 #define SCNuLEAST8 "u" 206 #define SCNxLEAST8 "x" 207 #define SCNXLEAST8 "X" 208 #define SCNoFAST8 "o" 209 #define SCNuFAST8 "u" 210 #define SCNxFAST8 "x" 211 #define SCNXFAST8 "X" 212 213 #define SCNo16 "ho" 214 #define SCNu16 "hu" 215 #define SCNx16 "hx" 216 #define SCNX16 "hX" 217 #define SCNoLEAST16 "ho" 218 #define SCNuLEAST16 "hu" 219 #define SCNxLEAST16 "hx" 220 #define SCNXLEAST16 "hX" 221 #define SCNoFAST16 "ho" 222 #define SCNuFAST16 "hu" 223 #define SCNxFAST16 "hx" 224 #define SCNXFAST16 "hX" 225 226 #define SCNo32 "lo" 227 #define SCNu32 "lu" 228 #define SCNx32 "lx" 229 #define SCNX32 "lX" 230 #define SCNoLEAST32 "lo" 231 #define SCNuLEAST32 "lu" 232 #define SCNxLEAST32 "lx" 233 #define SCNXLEAST32 "lX" 234 #define SCNoFAST32 "lo" 235 #define SCNuFAST32 "lu" 236 #define SCNxFAST32 "lx" 237 #define SCNXFAST32 "lX" 238 239 #define SCNo64 "I64o" 240 #define SCNu64 "I64u" 241 #define SCNx64 "I64x" 242 #define SCNX64 "I64X" 243 #define SCNoLEAST64 "I64o" 244 #define SCNuLEAST64 "I64u" 245 #define SCNxLEAST64 "I64x" 246 #define SCNXLEAST64 "I64X" 247 #define SCNoFAST64 "I64o" 248 #define SCNuFAST64 "I64u" 249 #define SCNxFAST64 "I64x" 250 #define SCNXFAST64 "I64X" 251 252 #define SCNoMAX "I64o" 253 #define SCNuMAX "I64u" 254 #define SCNxMAX "I64x" 255 #define SCNXMAX "I64X" 256 257 #ifdef _WIN64 // [ 258 # define SCNoPTR "I64o" 259 # define SCNuPTR "I64u" 260 # define SCNxPTR "I64x" 261 # define SCNXPTR "I64X" 262 #else // _WIN64 ][ 263 # define SCNoPTR "lo" 264 # define SCNuPTR "lu" 265 # define SCNxPTR "lx" 266 # define SCNXPTR "lX" 267 #endif // _WIN64 ] 268 269 #endif // __STDC_FORMAT_MACROS ] 270 271 // 7.8.2 Functions for greatest-width integer types 272 273 // 7.8.2.1 The imaxabs function 274 #define imaxabs _abs64 275 276 // 7.8.2.2 The imaxdiv function 277 278 #ifdef _MSC_VER 279 // This is modified version of div() function from Microsoft's div.c found 280 // in %MSVC.NET%\crt\src\div.c 281 #ifdef STATIC_IMAXDIV // [ 282 static 283 #else // STATIC_IMAXDIV ][ 284 _inline 285 #endif // STATIC_IMAXDIV ] 286 imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) 287 { 288 imaxdiv_t result; 289 290 result.quot = numer / denom; 291 result.rem = numer % denom; 292 293 if (numer < 0 && result.rem > 0) { 294 // did division wrong; must fix up 295 ++result.quot; 296 result.rem -= denom; 297 } 298 299 return result; 300 } 301 #endif // #ifdef _MSC_VER 302 303 // 7.8.2.3 The strtoimax and strtoumax functions 304 #define strtoimax _strtoi64 305 #define strtoumax _strtoui64 306 307 // 7.8.2.4 The wcstoimax and wcstoumax functions 308 #define wcstoimax _wcstoi64 309 #define wcstoumax _wcstoui64 310 311 312 #endif // _MSC_INTTYPES_H_ ] 313 314 #endif // #ifdef _INTTYPES_H_SYS_ 315 316 #endif // #ifndef _INTTYPES_H_ALL_