91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

本例子實現了推送本地視頻至流媒體服務器(以RTMP為例)。 是使用FFmpeg進行流媒體推送最簡單的教程。 解決方案包含2個項目: simplest_ffmpeg_streamer: 將本地視頻文件推送至流媒體服務器。 simplest_ffmpeg_receiver: 將流媒體數據保存成本地文件。

資源截圖

代碼片段和文件信息

/**
?*?最簡單的基于FFmpeg的收流器(接收RTMP)
?*?Simplest?FFmpeg?Receiver?(Receive?RTMP)
?*?
?*?雷霄驊?Lei?Xiaohua
?*?leixiaohua1020@126.com
?*?中國傳媒大學/數字電視技術
?*?Communication?University?of?China?/?Digital?TV?Technology
?*?http://blog.csdn.net/leixiaohua1020
?*?
?*?本例子將流媒體數據(以RTMP為例)保存成本地文件。
?*?是使用FFmpeg進行流媒體接收最簡單的教程。
?*
?*?This?example?saves?streaming?media?data?(Use?RTMP?as?example)
?*?as?a?local?file.
?*?It‘s?the?simplest?FFmpeg?stream?receiver.
?*?
?*/

#include?

#define?__STDC_CONSTANT_MACROS

#ifdef?_WIN32
//Windows
extern?“C“
{
#include?“libavformat/avformat.h“
#include?“libavutil/mathematics.h“
#include?“libavutil/time.h“
};
#else
//Linux...
#ifdef?__cplusplus
extern?“C“
{
#endif
#include?
#include?
#include?
#ifdef?__cplusplus
};
#endif
#endif

//‘1‘:?Use?H.264?Bitstream?Filter?
#define?USE_H264BSF?0

int?main(int?argc?char*?argv[])
{
AVOutputFormat?*ofmt?=?NULL;
//Input?AVFormatContext?and?Output?AVFormatContext
AVFormatContext?*ifmt_ctx?=?NULL?*ofmt_ctx?=?NULL;
AVPacket?pkt;
const?char?*in_filename?*out_filename;
int?ret?i;
int?videoindex=-1;
int?frame_index=0;
in_filename??=?“rtmp://live.hkstv.hk.lxdns.com/live/hks“;
//in_filename??=?“rtp://233.233.233.233:6666“;
//out_filename?=?“receive.ts“;
//out_filename?=?“receive.mkv“;
out_filename?=?“receive.flv“;

av_register_all();
//Network
avformat_network_init();
//Input
if?((ret?=?avformat_open_input(&ifmt_ctx?in_filename?0?0))? printf(?“Could?not?open?input?file.“);
goto?end;
}
if?((ret?=?avformat_find_stream_info(ifmt_ctx?0))? printf(?“Failed?to?retrieve?input?stream?information“);
goto?end;
}

for(i=0;?inb_streams;?i++)?
if(ifmt_ctx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO){
videoindex=i;
break;
}

av_dump_format(ifmt_ctx?0?in_filename?0);

//Output
avformat_alloc_output_context2(&ofmt_ctx?NULL?NULL?out_filename);?//RTMP

if?(!ofmt_ctx)?{
printf(?“Could?not?create?output?context\n“);
ret?=?AVERROR_UNKNOWN;
goto?end;
}
ofmt?=?ofmt_ctx->oformat;
for?(i?=?0;?i?nb_streams;?i++)?{
//Create?output?AVStream?according?to?input?AVStream
AVStream?*in_stream?=?ifmt_ctx->streams[i];
AVStream?*out_stream?=?avformat_new_stream(ofmt_ctx?in_stream->codec->codec);
if?(!out_stream)?{
printf(?“Failed?allocating?output?stream\n“);
ret?=?AVERROR_UNKNOWN;
goto?end;
}
//Copy?the?settings?of?AVCodecContext
ret?=?avcodec_copy_context(out_stream->codec?in_stream->codec);
if?(ret? printf(?“Failed?to?copy?context?from?input?to?output?stream?codec?context\n“);
goto?end;
}
out_stream->codec->codec_tag?=?0;
if?(ofmt_ctx->oformat->flags?&?AVFMT_GLOBALHEADER)
out_stream->codec->flags?|=?CODEC_FLAG_GLOBAL_HEADER;
}
//Dump?Format------------------
av_dump_format(ofmt_ctx?0?out_filename?1

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????????34??2015-07-14?11:17??.gitignore
?????文件?????????907??2015-07-14?11:17??ReadMe.txt
?????目錄???????????0??2015-07-14?11:17??simplest_ffmpeg_receiver\
?????文件??????????75??2015-07-14?11:17??simplest_ffmpeg_receiver\.gitignore
?????文件?????????539??2015-07-14?11:17??simplest_ffmpeg_receiver\ReadMe.txt
?????文件????18936320??2015-07-14?11:17??simplest_ffmpeg_receiver\avcodec-55.dll
?????文件?????1340928??2015-07-14?11:17??simplest_ffmpeg_receiver\avdevice-55.dll
?????文件?????2034688??2015-07-14?11:17??simplest_ffmpeg_receiver\avfilter-4.dll
?????文件?????5342720??2015-07-14?11:17??simplest_ffmpeg_receiver\avformat-55.dll
?????文件??????418304??2015-07-14?11:17??simplest_ffmpeg_receiver\avutil-52.dll
?????文件?????????647??2015-07-14?11:17??simplest_ffmpeg_receiver\compile_cl.bat
?????文件?????????460??2015-07-14?11:17??simplest_ffmpeg_receiver\compile_gcc.sh
?????文件?????????467??2015-07-14?11:17??simplest_ffmpeg_receiver\compile_mingw.sh
?????目錄???????????0??2015-07-14?11:17??simplest_ffmpeg_receiver\include\
?????文件????????8264??2015-07-14?11:17??simplest_ffmpeg_receiver\include\_mingw.h
?????文件????????6002??2015-07-14?11:17??simplest_ffmpeg_receiver\include\inttypes.h
?????目錄???????????0??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\
?????文件??????180728??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\avcodec.h
?????文件????????3229??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\avfft.h
?????文件????????2488??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\dxva2.h
?????文件???????11053??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\old_codec_ids.h
?????文件????????4180??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\vaapi.h
?????文件????????4262??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\vda.h
?????文件????????6415??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\vdpau.h
?????文件????????5759??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\version.h
?????文件????????6232??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavcodec\xvmc.h
?????目錄???????????0??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavdevice\
?????文件???????17129??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavdevice\avdevice.h
?????文件????????1911??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavdevice\version.h
?????目錄???????????0??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavfilter\
?????文件????????3412??2015-07-14?11:17??simplest_ffmpeg_receiver\include\libavfilter\asrc_abuffer.h
............此處省略221個文件信息

評論

共有 條評論