資源簡(jiǎn)介
結(jié)合網(wǎng)友的反饋,修改了頭文件和庫(kù)文件路徑,解決了不能編譯的問(wèn)題
修改output-example,將H.264,AAC幀保存到mp4容器中
參考鏈接:
http://blog.csdn.net/ajaxhe/article/details/7603333

代碼片段和文件信息
/*
?*?Libavformat?API?example:?Output?a?media?file?in?any?supported
?*?libavformat?format.?The?default?codecs?are?used.
?*
?*?Copyright?(c)?2003?Fabrice?Bellard
?*
?*?Permission?is?hereby?granted?free?of?charge?to?any?person?obtaining?a?copy
?*?of?this?software?and?associated?documentation?files?(the?“Software“)?to?deal
?*?in?the?Software?without?restriction?including?without?limitation?the?rights
?*?to?use?copy?modify?merge?publish?distribute?sublicense?and/or?sell
?*?copies?of?the?Software?and?to?permit?persons?to?whom?the?Software?is
?*?furnished?to?do?so?subject?to?the?following?conditions:
?*
?*?The?above?copyright?notice?and?this?permission?notice?shall?be?included?in
?*?all?copies?or?substantial?portions?of?the?Software.
?*
?*?THE?SOFTWARE?IS?PROVIDED?“AS?IS“?WITHOUT?WARRANTY?OF?ANY?KIND?EXPRESS?OR
?*?IMPLIED?INCLUDING?BUT?NOT?LIMITED?TO?THE?WARRANTIES?OF?MERCHANTABILITY
?*?FITNESS?FOR?A?PARTICULAR?PURPOSE?AND?NONINFRINGEMENT.?IN?NO?EVENT?SHALL
?*?THE?AUTHORS?OR?COPYRIGHT?HOLDERS?BE?LIABLE?FOR?ANY?CLAIM?DAMAGES?OR?OTHER
?*?LIABILITY?WHETHER?IN?AN?ACTION?OF?CONTRACT?TORT?OR?OTHERWISE?ARISING?FROM
?*?OUT?OF?OR?IN?CONNECTION?WITH?THE?SOFTWARE?OR?THE?USE?OR?OTHER?DEALINGS?IN
?*?THE?SOFTWARE.
?*/
#include?
#include?
#include?
#include?
//#include?
#include?
#ifndef?M_PI
#define?M_PI?3.14159265358979323846
#endif
extern?“C“{
#include?
#include?
};
#undef?exit
/*?5?seconds?stream?duration?*/
#define?STREAM_DURATION???5.0
#define?STREAM_frame_RATE?25?/*?25?images/s?*/
#define?STREAM_NB_frameS??((int)(STREAM_DURATION?*?STREAM_frame_RATE))
#define?STREAM_PIX_FMT?PIX_FMT_YUV420P?/*?default?pix_fmt?*/
static?int?sws_flags?=?SWS_BICUBIC;
/**************************************************************/
/*?audio?output?*/
float?t?tincr?tincr2;
int16_t?*samples;
uint8_t?*audio_outbuf;
int?audio_outbuf_size;
int?audio_input_frame_size;
/*
?*?add?an?audio?output?stream
?*/
static?AVStream?*add_audio_stream(AVFormatContext?*oc?int?codec_id)
{
????AVCodecContext?*c;
????AVStream?*st;
????st?=?av_new_stream(oc?1);
????if?(!st)?{
????????fprintf(stderr?“Could?not?alloc?stream\n“);
????????exit(1);
????}
????c?=?st->codec;
????c->codec_id?=?(CodecID)codec_id;
c->codec_type?=?AVMEDIA_TYPE_AUDIO;
????/*?put?sample?parameters?*/
c->sample_fmt?=?AV_SAMPLE_FMT_S16;
????c->sample_rate?=?8000;
????c->channels?=?1;
c->bit_rate?=?16000;
//?some?formats?want?stream?headers?to?be?separate
if(!strcmp(oc->oformat->name?“mp4“)?||?!strcmp(oc->oformat->name?“mov“)?||?!strcmp(oc->oformat->name?“3gp“))
c->flags?|=?CODEC_FLAG_GLOBAL_HEADER;
????return?st;
}
static?void?open_audio(AVFormatContext?*oc?AVStream?*st)
{
????AVCodecContext?*c;
????AVCodec?*codec;
????c?=?st->codec;
????/*?find?the?audio?encoder?*/
????codec?=?avcodec_fin
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???12463104??2011-06-24?02:20??output-example\Debug\avcodec-53.dll
?????文件??????55296??2011-06-24?02:20??output-example\Debug\avdevice-53.dll
?????文件?????798720??2011-06-24?02:20??output-example\Debug\avfilter-2.dll
?????文件????1296384??2011-06-24?02:20??output-example\Debug\avformat-53.dll
?????文件?????133120??2011-06-24?02:20??output-example\Debug\avutil-51.dll
?????文件????????664??2012-03-16?19:53??output-example\Debug\output-example.exp
?????文件???????1868??2012-03-16?19:53??output-example\Debug\output-example.lib
?????文件?????233984??2011-06-24?02:20??output-example\Debug\swscale-2.dll
?????文件?????????91??2012-03-11?10:32??output-example\include\inttypes.h
?????文件?????139382??2011-06-24?02:20??output-example\include\libavcodec\avcodec.h
?????文件???????2913??2011-06-24?02:20??output-example\include\libavcodec\avfft.h
?????文件???????1802??2011-06-24?02:20??output-example\include\libavcodec\dxva2.h
?????文件????????267??2011-06-24?02:20??output-example\include\libavcodec\opt.h
?????文件???????3895??2011-06-24?02:20??output-example\include\libavcodec\vaapi.h
?????文件???????2848??2011-06-24?02:20??output-example\include\libavcodec\vdpau.h
?????文件???????2655??2011-06-24?02:20??output-example\include\libavcodec\version.h
?????文件???????5796??2011-06-24?02:20??output-example\include\libavcodec\xvmc.h
?????文件???????2056??2011-06-24?02:20??output-example\include\libavdevice\avdevice.h
?????文件???????2364??2011-06-24?02:20??output-example\include\libavfilter\avcodec.h
?????文件??????35514??2011-06-24?02:20??output-example\include\libavfilter\avfilter.h
?????文件???????4748??2011-06-24?02:20??output-example\include\libavfilter\avfiltergraph.h
?????文件???????1592??2011-06-24?02:20??output-example\include\libavfilter\vsink_buffer.h
?????文件???????1600??2011-06-24?02:20??output-example\include\libavfilter\vsrc_buffer.h
?????文件??????59748??2011-06-24?02:20??output-example\include\libavformat\avformat.h
?????文件??????24719??2011-06-24?02:20??output-example\include\libavformat\avio.h
?????文件???????2994??2011-06-24?02:20??output-example\include\libavformat\version.h
?????文件???????1438??2011-06-24?02:20??output-example\include\libavutil\adler32.h
?????文件???????1635??2011-06-24?02:20??output-example\include\libavutil\aes.h
?????文件???????3079??2011-06-24?02:20??output-example\include\libavutil\attributes.h
?????文件???????4256??2011-06-24?02:20??output-example\include\libavutil\audioconvert.h
............此處省略76個(gè)文件信息
評(píng)論
共有 條評(píng)論