Windows下Qt5,FFMpeg编译

1 篇文章 0 订阅

1. 下载安装Qt5.4.1windows mingw安装包

http://download.qt.io/official_releases/qt/5.4/5.4.1/qt-opensource-windows-x86-mingw491_opengl-5.4.1.exe
2. 下载msys,并安装。

http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe

3. 启动MSYS,cp /etc/fstate.sample /etc/fstate

4. 编译/etc/fstate, 把文件中mingw的位置指向Qt5.4.1\Tools\mingw491_32 下。

5. 下载FFMPEG并解压

http://www.ffmpeg.org/releases/ffmpeg-2.2.tar.gz

6. 修改FFmepg中的Configure文件, 把所有的pr命令注释掉。

7. 执行.  ./configure --disable-yasm --enable-shared  --enable-static  --prefix=/installdir

大功告成


Windows下在QT中使用FFMPEG时

1.在工程目录下建立ffmpeg文件夹。

拷贝ffmpeg的所有头文件到$$PWD/ffmpeg/include下。

拷贝ffmpeg编译好的lib*.dll.a 到$$PWD/ffmpeg/lib下,并重命名为lib*.a

拷贝ffmpeg编译好的*.dll 到Qt5.4.1\5.4\mingw491_32\bin 目录下,方便运行时找到可用的动态库。或者把ffmpe dll所在的位置加入到QtCreator->项目->运行->Build Environment->PATH下。

2.在.pro中加入下面内容

DEFINES += __STDC_LIMIT_MACROS
DEFINES += __STDC_CONSTANT_MACROS
DEFINES += __STDC_FORMAT_MACROS
INCLUDEPATH += $$PWD/ffmpeg/include
LIBS += -L$$PWD/ffmpeg/lib -lavcodec -lavfilter -lavformat -lavutil -lswresample -lswscale



编译FFMPEG需要使用第三方库时,比如faac, x264时,

 使用export CPPFLAGS=-I/g/workspace/Mp4v2Test/aacd/faac-1.28/build/include/ 制定第三方库的头文件位置

使用 export LDFLAGS=-L/g/workspace/Mp4v2Test/aacd/faac-1.28/build/lib/ 指定第三方库的库文件位置。

$ ./configure --disable-yasm --enable-shared  --enable-static  --prefix=/g/workspace/ffmpeg-2.2/build/ --enable-libfaac --enable-nonfree


FFMPEG使用native aac encode

    /** Save the encoder context for easiert access later. */
    *output_codec_context = stream->codec;
 
    /**
     * Set the basic encoder parameters.
     * The input file's sample rate is used to avoid a sample rate conversion.
     */
    (*output_codec_context)->channels       = OUTPUT_CHANNELS;
    (*output_codec_context)->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
    (*output_codec_context)->sample_rate    = input_codec_context->sample_rate;
    (*output_codec_context)->sample_fmt     = AV_SAMPLE_FMT_FLTP; //native encode只支持这一种采样率,所以转换时有可能丢失数据
    (*output_codec_context)->bit_rate       = OUTPUT_BIT_RATE;
 
    /**
     * Some container formats (like MP4) require global headers to be present
     * Mark the encoder so that it behaves accordingly.
     */
    if ((*output_format_context)->oformat->flags & AVFMT_GLOBALHEADER)
        (*output_codec_context)->flags |= CODEC_FLAG_GLOBAL_HEADER;
 
 
    av_dict_set(&opts, "strict", "experimental", 0);
    /** Open the encoder for the audio stream to use it later. */
    error = avcodec_open2(*output_codec_context, output_codec, &opts);
//    av_dict_free(&opts);
    if (error < 0) {
        fprintf(stderr, "Could not open output codec (error '%s')\n",
                get_error_text(error));
        goto cleanup;
    }
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值