我的ffmpeg SDK完成了:ffmpeg最新…

来源:互联网 发布:失落沙洲知乎 编辑:程序博客网 时间:2024/06/06 07:29
我的ffmpeg SDK完成了:ffmpeg最新的,支持X264/lame
   - 拔剑

今天抽了点功夫,利用在MinGW/msys下编译的ffmpeg包做了个ffmpeg的SDK, 支持Visual C++开发。

一、组成:
   1)提供相关头文件, 
            x264.h, x264_config.h
            libavformat/xxx.h .....xxxx.h
            libavcodec/xxxx.h ....xxxx.h
            ....
   2)提供了相关的lib文件,放在一个目录里面
   3)提供了相关的DLL文件,也在一个目录里面
   以上文件不过是从MinGW/msys的/usr/local/include ,/usr/local/lib, /usr/local/bin 
    (afterrun make install for each of x264,ffmpeg,lame)

   如何在MinGW/msys环境下编译ffmpeg,并集成mp3,x264编解码,参以前文章。

二、注意事项
   1)由于用了较新的ffmpeg版本,和较为流行的ffmpegSDK有些接口上的差异,因此用老的例子程序
      需要做少量的修改,否则老代码会有错误爆出,如:
         guess_format          -> av_guess_format
         CODEC_TYPE_VIDEO         -> AVMEDIA_TYPE_VIDEO
         PKT_FLAG_KEY             ->AV_PKT_FLAG_KEY;
         CODEC_TYPE_AUDIO         -> AVMEDIA_TYPE_AUDIO
         av_alloc_format_context()  ->avformat_alloc_context();
          ...
   2)在缺省工程里面,把Additionalinclude的路径都加上,如 
         ./include
         ./include/libavformat/
         ./include/libavcodec/
         ./SDL_SDK/include
          ...
   3)在缺省工程中,需要把库文件指定
         Additionallib dir: xxxxx, SDL_SDK\lib
         Additionaldependencies: libavformat.lib, libavcodec.lib, libavutil.lib,...
                              SDL.lib,SDLmain.lib  
   4)在原始文件中,缺乏stdint.h,inttype.h, 这两个文件在MinGW/msys中可以找到,实在没有,
    在Linux/G++源代码或者网上代码估计都可以。网上有别人做好的或者放好的可下载。google即得。
   5)典型问题一:errorC3861:\’UINT64_C\’:identifier not found
     解决方法:  在common.h的头部添加
             #ifndef INT64_C
             #   ifdefined(__GNUC__)
             #      define INT64_C(c)    (c ## LL)
             #      define UINT64_C(c)   (c ## ULL)
             #  else
             #      define INT64_C(c)    (c ## i64)
             #      define UINT64_C(c)   (c ## ui64)
             #  endif
             #endif
   6)典型问题二,编译通过,链接错误
    解决办法,如果是cpp文件确认采用如下方式调用发ffmpeg的头文件
          extern "C"{
              #include"avformat.h"
          }
   原因,C++调用C库必须如此。
  7)老代码拷到C++工程中后一大堆类型不匹配的问题,如
1>.\avcodec_example.cpp(73): error C2440: '=' : cannot convert from 'int' to'CodecID'
1>.\avcodec_example.cpp(110) : error C2440: '=' :cannot convert from 'void *' to 'uint8_t 1>.\avcodec_example.cpp(129) : error C2440: '=' :cannot convert from 'void *' to 'int16_t*'
    
   解决方法很简单,直接类型强制转换。这些代码在c程序中不抱错的原因是,C的类型检测没有C++严厉。
   
        int i =malloc(4);  // OK in C, Error inC++
  8)运行的问题, 需要把一大堆DLL放在系统目录,或者EXE文件所在目录。
  9)集成SDL,可以直接选用网上的现成Windows开发包:
       SDL-devel-1.2.14-VC8.zip (VisualC++ 2005 Service Pack 1)
        编译时出现问题:
     1>MSVCRTD.lib(MSVCR90D.dll) :error LNK2005: _isspace already defined in LIBCMTD.lib(_ctype.obj)   
     1>MSVCRTD.lib(MSVCR90D.dll) :error LNK2005: _fprintf already defined in LIBCMTD.lib(fprintf.obj)   
     1>MSVCRTD.lib(MSVCR90D.dll) :error LNK2005: ___iob_func already defined inLIBCMTD.lib(_file.obj)   
     1>MSVCRTD.lib(MSVCR90D.dll) :error LNK2005: _fopen already defined inLIBCMTD.lib(fopen.obj)
     解决办法:
             : 下载的包采用了动态连接(C/C++库的方法),主程序选用"Use MFC in shared DLL", Pass
                Somebody said to directly disable some lib, that could cause more errors!

        I also tried using MinGW to build source code, currently cannot pass. will try later.

  10)其余问题,目前没有。

我的相关垃圾:
  
我的ffmpeg SDK完成了:ffmpeg最新的,支持X264/lame 
(
   ffmpeg:集成lame/X264
   集成ffmpeg/x264:ERROR: libx264 not found的问题
     Build X264/ffMpeg under MinGW/MSYS
     采用ffmpeg静态库连接的视频应用工程调试 
      

0 0
原创粉丝点击