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.1Toolsmingw491_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.15.4mingw491_32bin 目录下,方便运行时找到可用的动态库。或者把ffmpe dll所在的位置加入到QtCreator->项目->运行->Build Environment->PATH下。
2.在.pro中加入下面内容
1DEFINES += __STDC_LIMIT_MACROS
1DEFINES += __STDC_CONSTANT_MACROS
1DEFINES += __STDC_FORMAT_MACROS
1INCLUDEPATH += $$PWD/ffmpeg/include
1LIBS += -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
1
2/** Save the encoder context for easiert access later. */
1
2*output_codec_context = stream->codec;
1
1
2/**
1
2* Set the basic encoder parameters.
1
2* The input file's sample rate is used to avoid a sample rate conversion.
1
2*/
1
2
3(*output_codec_context)->channels = OUTPUT_CHANNELS;
1
2(*output_codec_context)->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
1
2
3(*output_codec_context)->sample_rate = input_codec_context->sample_rate;
1
2
3(*output_codec_context)->sample_fmt = AV_SAMPLE_FMT_FLTP; //native encode只支持这一种采样率,所以转换时有可能丢失数据
1
2
3(*output_codec_context)->bit_rate = OUTPUT_BIT_RATE;
1
1
2/**
1
2* Some container formats (like MP4) require global headers to be present
1
2* Mark the encoder so that it behaves accordingly.
1
2*/
1
2if ((*output_format_context)->oformat->flags & AVFMT_GLOBALHEADER)
1
2(*output_codec_context)->flags |= CODEC_FLAG_GLOBAL_HEADER;
1
1
1
2av_dict_set(&opts, "strict", "experimental", 0);
1
2/** Open the encoder for the audio stream to use it later. */
1
2error = avcodec_open2(*output_codec_context, output_codec, &opts);
1
2// av_dict_free(&opts);
1
2if (error < 0) {
1
2fprintf(stderr, "Could not open output codec (error '%s')n",
1
2get_error_text(error));
1
2goto cleanup;
1
2}
1
最后
以上就是标致水池最近收集整理的关于Windows下Qt5,FFMpeg编译的全部内容,更多相关Windows下Qt5内容请搜索靠谱客的其他文章。
发表评论 取消回复