Linux基于Live555 获取rstp实时H264视频流并转发
来源:互联网 发布:如何编写一个软件 编辑:程序博客网 时间:2024/06/06 03:21
Linux基于Live555获取rstp实时264视频流并转发
1、编译生成库
从官网上下载,下载地址:http://www.live555.com/liveMedia/public/,选择live555-latest.tar.gz下载
下载的为2017.10.28版
解压:tar xzf live555-latest.tar.gz
修改权限: chmod+777 live -R
修改交叉编译工具 :cp config.armlinux cpconfig.arm
vi config.arm
CROSS_COMPILE?= arm-buildroot-linux-uclibcgnueabi-
生成Makefile: ./genMakefiles arm
make
生成mediaServer/live555MediaServer
使用 H.264文件测试 :live555MediaServer test.264
获取IP错误一直为127.0.1.1或0.0.0.0
而机器IP为 127.0.0.1 & 192.168.55.3
内核不支持端口复用需要注释掉groupsock/GroupsockHelper.cppSO_REUSEPORT
参考:
Rtsp server 创建过程分析
https://www.cnblogs.com/dchipnau/p/5458943.html
windows 本地获取实例
http://blog.csdn.net/xiejiashu/article/details/8269873
2、添加获取实时帧类
创建会话
ServerMediaSession* DynamicRTSPServer::lookupServerMediaSession(char const* streamName, Boolean isFirstLookupInSession) { // Next, check whether we already have a "ServerMediaSession" for this file: ServerMediaSession* sms = RTSPServer::lookupServerMediaSession(streamName); Boolean smsExists = sms != NULL; if (sms == NULL) { sms = createNewSMS(envir(), streamName, NULL); addServerMediaSession(sms); } return sms;}#define NEW_SMS(description) do {\char const* descStr = description\ ", streamed by the LIVE555 Media Server";\sms = ServerMediaSession::createNew(env, fileName, fileName, descStr);\} while(0)static ServerMediaSession* createNewSMS(UsageEnvironment& env,char const* fileName, FILE* /*fid*/) { printf("filename =%s\n",fileName); if(fileName == NULL) return NULL; // Use the file name extension to determine the type of "ServerMediaSession": char const* h264 = strcasestr(fileName, "-stream"); ServerMediaSession* sms = NULL; Boolean const reuseSource = True; sms->addSubsession(H264LiveVideoServerMediaSubsession::createNew(env, fileName, reuseSource)); return sms;}
获取video
FramedSource* H264LiveVideoServerMediaSubsession::createNewStreamSource(unsigned /*clientSessionId*/, unsigned& estBitrate) { estBitrate = 500; // kbps, estimate // Create the video source: H264LiveVideoSource* liveSource = H264LiveVideoSource::createNew(envir(), fChanID); if (liveSource == NULL) return NULL; // Create a framer for the Video Elementary Stream: return H264VideoStreamFramer::createNew(envir(), liveSource);}RTPSink* H264LiveVideoServerMediaSubsession::createNewRTPSink(Groupsock* rtpGroupsock,unsigned char rtpPayloadTypeIfDynamic,FramedSource* /*inputSource*/) {return H264VideoRTPSink::createNew(envir(), rtpGroupsock, rtpPayloadTypeIfDynamic);}
void H264LiveVideoSource::doGetNextFrame() { int ret; fFrameSize = 0; ret = tend_CamVideo_hal_captureFrame(TEND_STREAMID_LIVE, pLiveVideoFrameBuf); if(ret == 0) { fFrameSize = pLiveVideoFrameBuf->buf_used;if(fFrameSize > fMaxSize){fFrameSize = fMaxSize;int frBufUsedBytes = fMaxSize;fNumTruncatedBytes = pLiveVideoFrameBuf->buf_used - frBufUsedBytes;LOGD("Truncat %d bytes\n",fNumTruncatedBytes);memmove(fTo,pLiveVideoFrameBuf->buf,frBufUsedBytes);memmove(fTruncatedBytes,pLiveVideoFrameBuf->buf + frBufUsedBytes,fNumTruncatedBytes);fTruncatedBytesNum = fNumTruncatedBytes;}else{if(fTruncatedBytesNum > 0){memmove(fTo,fTruncatedBytes,fTruncatedBytesNum);memmove(fTo + fTruncatedBytesNum,pLiveVideoFrameBuf->buf,pLiveVideoFrameBuf->buf_used);fFrameSize += fTruncatedBytesNum;LOGD("send last truncted %d bytes\n",fTruncatedBytesNum);fTruncatedBytesNum = 0;}else{memmove(fTo,pLiveVideoFrameBuf->buf,pLiveVideoFrameBuf->buf_used);}} tend_CamVideo_hal_releaseFrame(TEND_STREAMID_LIVE); } else { handleClosure(); return; }fDurationInMicroseconds = 1000000 / 20;if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0) { // This is the first frame, so use the current time: gettimeofday(&fPresentationTime, NULL);} else { // Increment by the play time of the previous frame: unsigned uSeconds = fPresentationTime.tv_usec + fDurationInMicroseconds; fPresentationTime.tv_sec += uSeconds/1000000; fPresentationTime.tv_usec = uSeconds%1000000;} FramedSource::afterGetting(this);}
编译通过nfs运行
VLC播放
源码下载地址:
http://download.csdn.net/download/xwu122930/10158177
- Linux基于Live555 获取rstp实时H264视频流并转发
- live555+MediaCodec实现获取并解码RTSP视频(H264)
- h264移动流媒体服务器-实时流直播(基于live555)
- live555 实时音视频(H264 & PCMA)
- 基于live555实现实时视频监控
- 基于live555的实时视频直播
- 基于live555实现实时视频监控
- OpenCV实时美颜摄像并生成H264视频流
- OpenCV实时美颜摄像并生成H264视频流
- OpenCV实时美颜摄像并生成H264视频流
- OpenCV实时美颜摄像并生成H264视频流
- live555 RTSPServer 如何实现转发实时流
- Live555转发DVB实时流数据
- 关于视频流live555和h264
- 分享基于Live555开发的 H264视频直播流媒体项目
- 采用live555 转发音视频复合流
- live555接收实时视频流+ffmpeg解
- Windows下利用live555实现H264实时流RTSP发送
- linux任务定时器crontab
- Java——处理HTTP请求时,Web容器做了什么?
- 03_c++程序结构
- spring boot 分层demo(二)
- java8新特性---Optional类
- Linux基于Live555 获取rstp实时H264视频流并转发
- 初识云计算
- JavaScript中的Number类型、String类型、Global对象、Math对象总结
- C# 从数据库中读取数据(ExecuteReader)
- React3 生命周期函数
- nginx优化的一些建议
- Spring学习笔记-MVC模块
- 验证多个手机号、固定电话,电话之间用英文逗号隔开
- 为了下载一个技术文档