資源簡介
用ffmpeg代碼進行轉碼,音頻進行了重采樣
代碼片段和文件信息
//?convertVideo.cpp?:?定義控制臺應用程序的入口點。
//
#include?“stdafx.h“
#include?
#include?
#include?
using?namespace?std;
extern?“C“??
{??
#define?__STDC_CONSTANT_MACROS
#define?__STDC_FORMAT_MACROS
#include?“libavcodec/avcodec.h“??
#include?“libavformat/avformat.h“??
#include?“libavfilter/avfiltergraph.h“???
#include?“libavfilter/buffersink.h“??
#include?“libavfilter/buffersrc.h“??
#include?“libavutil/avutil.h“??
#include?“libavutil/opt.h“??
#include?“libavutil/pixdesc.h“?
#include?“libavutil/imgutils.h“
#include?“libavutil/avassert.h“
#include?“libavutil/channel_layout.h“
#include?“libavutil/opt.h“
#include?“libavutil/mathematics.h“
#include?“libswscale/swscale.h“
#include?“libswresample/swresample.h“
#include?“libavutil/audio_fifo.h“
};?
bool?muxer(string?outVideoPathstring?outAudioPath);
#define?SWR_CH_MAX?32
SwrContext*?initSwr(SwrContext*?pSwrCtx?AVFormatContext?*in_fmt_ctx?AVFormatContext?*out_fmt_ctx?int?audio_index)
{
if?(out_fmt_ctx->streams[0]->codec->channels?!=?in_fmt_ctx->streams[audio_index]->codec->channels??
????????||?out_fmt_ctx->streams[0]->codec->sample_rate?!=?in_fmt_ctx->streams[audio_index]->codec->sample_rate??
||?out_fmt_ctx->streams[0]->codec->sample_fmt?!=?in_fmt_ctx->streams[audio_index]->codec->sample_fmt?||?true?)??
????{??
????????if?(?NULL?==?pSwrCtx?)???
????????{??
????????????pSwrCtx?=?swr_alloc();??
????????}??
#if?LIBSWRESAMPLE_VERSION_MINOR?>=?17????//?根據版本不同,選用適當函數??
????????av_opt_set_int(pSwrCtx?“ich“?in_fmt_ctx->streams[audio_index]->codec->channels?0);??
????????av_opt_set_int(pSwrCtx?“och“?out_fmt_ctx->streams[0]->codec->channels?0);??
????????av_opt_set_int(pSwrCtx?“in_sample_rate“??in_fmt_ctx->streams[audio_index]->codec->sample_rate?0);??
????????av_opt_set_int(pSwrCtx?“out_sample_rate“??out_fmt_ctx->streams[0]->codec->sample_rate?0);??
????????av_opt_set_sample_fmt(pSwrCtx?“in_sample_fmt“?in_fmt_ctx->streams[audio_index]->codec->sample_fmt?0);??
????????av_opt_set_sample_fmt(pSwrCtx?“out_sample_fmt“?out_fmt_ctx->streams[0]->codec->sample_fmt?0);??
??
#else??
????????pSwrCtx?=?swr_alloc_set_opts(pSwrCtx??
????????????out_fmt_ctx->streams[0]->codec->channel_layout???
????????????out_fmt_ctx->streams[0]->codec->sample_fmt???
????????????in_fmt_ctx->streams[audio_index]->codec->sample_rate??
????????????in_fmt_ctx->streams[audio_index]->codec->channel_layout?>?0??in_fmt_ctx->streams[audio_index]->codec->channel_layout?:?AV_CH_LAYOUT_STEREO???
????????????in_fmt_ctx->streams[audio_index]->codec->sample_fmt???
????????????in_fmt_ctx->streams[audio_index]->codec->sample_rate??
????????????0?NULL);??
#endif??
????????swr_init(pSwrCtx);
return?pSwrCtx;
????}
return?NULL;
}
void?setup_array(uint8_t*?out[SWR_CH_MAX]?AVframe*?in_frame?int?format?int?samples)
{
if?(av_sample_fmt_is_planar((AVSampleFormat)format))?
{
int?i;
int?plane_size?=?av_get_bytes_per_sample((AVSampleF
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-06-15?17:47??TestForConvertVideo\
?????目錄???????????0??2015-05-20?15:24??TestForConvertVideo\Debug\
?????文件???????70144??2015-05-25?17:29??TestForConvertVideo\Debug\TestForConvertVideo.exe
?????文件??????578992??2015-05-25?17:29??TestForConvertVideo\Debug\TestForConvertVideo.ilk
?????文件??????961536??2015-05-25?17:29??TestForConvertVideo\Debug\TestForConvertVideo.pdb
?????目錄???????????0??2015-06-15?17:46??TestForConvertVideo\ipch\
?????目錄???????????0??2015-06-15?17:47??TestForConvertVideo\ipch\testforconvertvideo-2fd58473\
?????目錄???????????0??2015-05-20?14:39??TestForConvertVideo\TestForConvertVideo\
?????文件?????????924??2015-05-19?10:37??TestForConvertVideo\TestForConvertVideo.sln
?????文件???????31232??2015-06-15?17:47??TestForConvertVideo\TestForConvertVideo.suo
?????文件????18936320??2014-05-06?10:08??TestForConvertVideo\TestForConvertVideo\avcodec-55.dll
?????文件?????1340928??2014-05-06?10:08??TestForConvertVideo\TestForConvertVideo\avdevice-55.dll
?????文件?????2034688??2014-05-06?10:08??TestForConvertVideo\TestForConvertVideo\avfilter-4.dll
?????文件?????5342720??2014-05-06?10:08??TestForConvertVideo\TestForConvertVideo\avformat-55.dll
?????文件??????418304??2014-05-06?10:08??TestForConvertVideo\TestForConvertVideo\avutil-52.dll
?????文件???????28536??2015-05-27?17:25??TestForConvertVideo\TestForConvertVideo\convertVideo.cpp
?????文件?????1709108??2014-01-05?12:46??TestForConvertVideo\TestForConvertVideo\cuc_ieschool.ts
?????目錄???????????0??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\
?????文件????????1698??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\cl.command.1.tlog
?????文件???????23138??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\CL.read.1.tlog
?????文件????????4924??2015-05-25?17:28??TestForConvertVideo\TestForConvertVideo\Debug\CL.read.2.tlog
?????文件????????1874??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\CL.write.1.tlog
?????文件??????145813??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\convertVideo.obj
?????文件???????????2??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\li
?????文件???????????2??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\li
?????文件???????????2??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\li
?????文件???????????2??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\li
?????文件???????????2??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\li
?????文件???????????2??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\li
?????文件???????????2??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\li
?????文件???????????2??2015-05-25?17:29??TestForConvertVideo\TestForConvertVideo\Debug\li
............此處省略142個文件信息
評論
共有 條評論