资源简介
rtmpdump实现rtmp视频拉流存储的demo程序
代码片段和文件信息
#include
#include
#include
#include “librtmp/rtmp_sys.h“
#include “librtmp/log.h“
#define SAVE_FILE_NAME “receive.flv“
#define RTMP_SERVER_URL “rtmp://172.16.1.65:1935/vod/mp4:sample.mp4“
int InitSockets()
{
/*
WORD version;
WSADATA wsaData;
version = MAKEWORD(1 1);
return (WSAStartup(version &wsaData) == 0);
*/
return 0;
}
void CleanupSockets()
{
//WSACleanup();
}
int main(int argc char* argv[])
{
InitSockets();
//double duration=-1;
int nRead;
//is live stream ?
int bLiveStream=1;
int bufsize=1024*1024*10;
char *buf=(char*)malloc(bufsize);
memset(buf0bufsize);
long countbufsize=0;
FILE *fp=fopen(SAVE_FILE_NAME“wb“);
if (!fp){
RTMP_LogPrintf(“Open File Error.\n“);
CleanupSockets();
return -1;
}
/* set log level */
//RTMP_LogLevel loglvl=RTMP_LOGDEBUG;
//RTMP_LogSetLevel(loglvl);
RTMP *rtmp=RTMP_Alloc();
RTMP_Init(rtmp);
//set connection timeoutdefault 30s
rtmp->link.timeout=10;
if(!RTMP_SetupURL(rtmpRTMP_SERVER_URL))
{
RTMP_Log(RTMP_LOGERROR“SetupURL Err\n“);
RTMP_Free(rtmp);
CleanupSockets();
return -1;
}
if (bLiveStream){
rtmp->link.lFlags|=RTMP_LF_LIVE;
}
//1hour
RTMP_SetBufferMS(rtmp 3600*1000);
if(!RTMP_Connect(rtmpNULL)){
RTMP_Log(RTMP_LOGERROR“Connect Err\n“);
RTMP_Free(rtmp);
CleanupSockets();
return -1;
}
if(!RTMP_ConnectStream(rtmp0)){
RTMP_Log(RTMP_LOGERROR“ConnectStream Err\n“);
RTMP_Close(rtmp);
RTMP_Free(rtmp);
CleanupSockets();
return -1;
}
while(nRead=RTMP_Read(rtmpbufbufsize)){
fwrite(buf1nReadfp);
countbufsize+=nRead;
RTMP_LogPrintf(“Receive: %5dByte Total: %5.2fkB\n“nReadcountbufsize*1.0/1024);
}
if(fp)
fclose(fp);
if(buf){
free(buf);
}
if(rtmp){
RTMP_Close(rtmp);
RTMP_Free(rtmp);
CleanupSockets();
rtmp=NULL;
}
return 0;
}
- 上一篇:玫瑰图制作教程
- 下一篇:mentohust_0.3.4-1-2_i386
相关资源
- 使用nginx与nginx-rtmp-module搭建流媒体服
- rtmp 协议规范 中文版
- video-js rtmp播放 swf文件低延迟自编译文
- eWebEditor7.0破解版,实现粘贴图片自
-
flvpla
yer.swf下载88617 - Centos 搭建crtmpserver流媒体服务器
- flvmdi flv文件修复工具
-
flvpla
yer.swf - RTSPVGA录制,以及推流小工具
- flv视频播放插件js
- 两个rtmp直播流播放器
- FLV协议pdf
- windows下搭建基于nginx的rtmp服务器
- nginx-rtmp-win32搭建流媒体服务器,支持
-
Windows环境下用jwpla
yer+Nginx搭建视频 - Windows下编译Nginx并添加模块.docx
- nginx-1.17.9.zip
- vue播放rtmp视频流
- videojs压缩包
- 集成了nginx-http-flv-module 1.2.7模块的6
- rtsp推流rtmp(命令行+demo+nginxconf+flvj
- videoJs5.20.4最后一版支撑flash播放rtmp视
- 基于RTMP协议的Flash流媒体网页播放器
- videojs播放rtmp视频
- flv.js和flv.min.js和基本使用demo(附带
- nginx 带 rtmp 完整模块 nginx-rtmp.zip
-
ijkpla
yer源码编译so库,支持rtsp、r - nginx-http-flv-module.zip
- 带nginx-rtmp-module模块的Nginx
- nginx-rtmp-module搭建RTMP+HLS流媒体服务器
评论
共有 条评论