qn1532684965

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965  发布于  2020-04-02 09:26:31
采纳率 0%
11个问答
3505

hi3519 rtsp_server问题交流

 
此贴用于大家一起交流3519实现rtsp_server功能的问题交流,共同进步
个人也是初学者,在群里下了好多代码,也看了好多帖子。
刚开始是下载了live555进行测试,实现vlc去播放一个视频文件,整了好久才实现,但是效果很差,对live555继续搞下去的信心受打击了
后来在群里发现有分享rtsp_server代码的大神,就下载了一些,自己编译后去搞,目前也是碰到一些问题。希望有大神给与解答
我来回答
回答19个
时间排序
认可量排序

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-04-02 09:32:14
认可0
目前我的代码是基于这位大神的代码进行开发的,
以下是相关帖子网站:[url]http://bbs.ebaina.com/forum.php?mod=viewthread&tid=10950&highlight=RTSP[/url]
开发完后基本功能是可以实现,图还是很流畅,唯一的问题就是延时很大,帖子里也有类似同学提到这个问题,未见相关答案。
我的理解:这位大神的处理是基于h264的编码去做处理的,我正在考虑用H265的去编码传输,看是否会效果好些;另外海思自己提供的测试IPC的工具可以测试rtsp开流(同事提供,但是没有相关代码),发现4K的h265编码效果延时很小,所以证明和网络,硬件等外部环境无关,我们可以用软件代码实现功能,但是具体怎么实现要自己去钻研了,如果有海思demo的相关代码参考实现那就更好了。
各位大神有什么建议呢?欢迎发言

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-04-07 15:03:39
认可0
大家的4K 编码的rtsp开流的延时有多大?我的有3-5秒?不知道还能不能改进

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-04-09 15:35:38
认可0
发现获取编码流的超时时间由超时2秒改为超时1秒,延时时间有很大改善

qn1534216564

0个粉丝

4

问答

0

专栏

0

资料

qn1534216564 2020-04-14 11:07:45
认可0
优化到两三百毫秒是你的目标

qn1564384748

0个粉丝

0

问答

0

专栏

0

资料

qn1564384748 2020-04-14 14:59:21
认可0
我现在也遇到这个问题,我是720P的H264的编码,用VLC播放有一秒多的延时,不知楼主这个问题解决了没有

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-04-14 21:37:21
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=156743&ptid=79705]qn1564384748 发表于 2020-4-14 14:59[/url]
我现在也遇到这个问题,我是720P的H264的编码,用VLC播放有一秒多的延时,不知楼主这个问题解决了没有[/quote]

你VLC配置了超时时间多少??

fengsheng

0个粉丝

4

问答

0

专栏

0

资料

fengsheng 2020-04-14 22:29:06
认可0
2s左右正常吧

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-04-15 09:03:07
认可1
[quote][url=forum.php?mod=redirect&goto=findpost&pid=156689&ptid=79705]qn1534216564 发表于 2020-4-14 11:07[/url]
优化到两三百毫秒是你的目标[/quote]

这个有点难啊

qn1582609407

0个粉丝

4

问答

0

专栏

0

资料

qn1582609407 2020-04-15 09:39:23
认可0
VLC看流本来就有很大延时,大概两秒以上,这跟你的程序无关的

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-04-15 09:56:22
认可0
那那个软件测试rtsp流会更好些,至少排除软件的问题

david

31个粉丝

368

问答

253

专栏

229

资料

david 2020-04-15 11:13:14
认可0
优化到 100ms时你的目标,兄弟不能放低标准:hug:

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-04-18 08:51:42
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=156787&ptid=79705]david 发表于 2020-4-15 11:13[/url]
优化到 100ms时你的目标,兄弟不能放低标准[/quote]

现在优化到差不多1秒左右了
因为忙就不再继续搞了  领导让做这个就是为了调节视频效果  
感觉编码读帧超时时间也会影响播放延时效果 目前我设置的超时时间是1秒  后续有时间再把超时时间减小些试试是否可以再减小延时时间

qn1534216564

0个粉丝

4

问答

0

专栏

0

资料

qn1534216564 2020-04-27 10:29:28
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=156780&ptid=79705]qn1532684965 发表于 2020-4-15 09:03[/url]
这个有点难啊[/quote]

1秒左右说明你没有优化到位

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-04-27 11:44:50
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=157414&ptid=79705]qn1534216564 发表于 2020-4-27 10:29[/url]
1秒左右说明你没有优化到位[/quote]

:lol 嗯 知道  大神有什么建议

qn1585904579

0个粉丝

2

问答

0

专栏

0

资料

qn1585904579 2020-06-15 18:49:25
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=156282&ptid=79705]qn1532684965 发表于 2020-4-2 09:32[/url]
目前我的代码是基于这位大神的代码进行开发的,
以下是相关帖子网站:http://bbs.ebaina.com/forum.php?mo ...[/quote]

大佬,加一下vx,问一些问题

Chenw_Fly

0个粉丝

2

问答

0

专栏

0

资料

Chenw_Fly 2020-06-16 11:52:38
认可1
live555的效率,还是放弃吧。
可以参照hi3559v200里面,海思自己实现的一个轻量级rtsp server,兼容性不错,效率也高。

qn1532684965

0个粉丝

11

问答

0

专栏

0

资料

qn1532684965 2020-06-28 15:11:35
认可1
[quote][url=forum.php?mod=redirect&goto=findpost&pid=159830&ptid=79705]qn1585904579 发表于 2020-6-15 18:49[/url]
大佬,加一下vx,问一些问题[/quote]

??说不上大佬  一起学习

来自远方

15个粉丝

31

问答

40

专栏

132

资料

来自远方 2020-07-06 19:45:56
认可0
都反反复复

硅天下科技

1个粉丝

38

问答

0

专栏

9

资料

硅天下科技 2020-08-01 18:30:39
认可0
1.1.2.2 测试代码

#include
#include "xop/RtspServer.h"
#include "net/NetInterface.h"
#include "afrtsp.h"

typedef struct tag_AF_RTSP_INFO {
        xop::MediaSessionId SessionId;// 会话句柄
        unsigned int nClients;// 客户端数量
        char rtspUrl[64];
}AF_RTSP_INFO;

static pthread_t g_nThreadID;
static pthread_mutex_t g_Mutex;
static xop::RtspServer *g_pRtspServer = NULL;
static AF_RTSP_INFO g_RtspInfo[4] = { 0 };
static xop::EventLoop *g_pEventLoop = NULL;

static void *AF_RtspThread(void *p)
{
        int clients = 0;
        std::string rtspUrl;

        std::string ip = xop::NetInterface::getLocalIPAddress(); //获取网卡ip地址
        g_pEventLoop = new xop::EventLoop();
        g_pRtspServer = new xop::RtspServer(g_pEventLoop, ip, 554);//创建一个RTSP服务器

        // live通道
        xop::MediaSession *session = xop::MediaSession::createNew("live");
        snprintf(g_RtspInfo[0].rtspUrl, sizeof(g_RtspInfo[0].rtspUrl), "rtsp://%s/%s", ip.c_str(), session->getRtspUrlSuffix().c_str());
        rtspUrl = "rtsp://" + ip + "/" + session->getRtspUrlSuffix();

        // 添加音视频流到媒体会话, track0:h265, track1:aac
        session->addMediaSource(xop::channel_0, xop::H265Source::createNew());
//        session->addMediaSource(xop::channel_1, xop::AACSource::createNew(44100,2));

        // 设置通知回调函数。 在当前会话中, 客户端连接或断开会通过回调函数发起通知
        session->setNotifyCallback([&clients, &rtspUrl](xop::MediaSessionId sessionId, uint32_t numClients) {
                pthread_mutex_lock(&g_Mutex);
                g_RtspInfo[0].nClients = clients = numClients; //获取当前媒体会话客户端数量
                std::cout << "[" << g_RtspInfo[0].rtspUrl << "]" << " Online: " << g_RtspInfo[0].nClients << std::endl;
                pthread_mutex_unlock(&g_Mutex);
        });

        std::cout << "URL: " << g_RtspInfo[0].rtspUrl << std::endl;

        g_RtspInfo[0].SessionId = g_pRtspServer->addMeidaSession(session);

        g_pEventLoop->loop();

        return NULL;
}

int AF_RtspInit()
{
        if (g_pRtspServer != NULL)
                return -1;

        if (g_pEventLoop != NULL)
                return -1;

        pthread_mutex_init(&g_Mutex, NULL);

        return pthread_create(&g_nThreadID, 0, AF_RtspThread, NULL);
}

int AF_RtspExit()
{
        pthread_mutex_destroy(&g_Mutex);
        if (g_pRtspServer != NULL) {
                pthread_join(g_nThreadID, 0);
                // 服务和会话的销毁
               
        }

        return 0;
}

int AF_RtspPush(int nCh, unsigned char *pBuffer, int nLength, int bKey)
{
        if (nCh != 0)//暂时只测试xop::MediaSession live通道
                return 0;

        pthread_mutex_lock(&g_Mutex);
        if (g_RtspInfo[0].nClients > 0) {
                xop::AVFrame videoFrame = { 0 };
                videoFrame.type = bKey ? xop::VIDEO_FRAME_I : xop::VIDEO_FRAME_P;
                videoFrame.size = nLength - 4;               
                videoFrame.timestamp = xop::H265Source::getTimeStamp();
                videoFrame.buffer.reset(new uint8_t[videoFrame.size]);
                memcpy(videoFrame.buffer.get(), pBuffer + 4, videoFrame.size);
                bool bRet = g_pRtspServer->pushFrame(g_RtspInfo[0].SessionId, xop::channel_0, videoFrame);
                if (!bRet) {
                        printf("pushFrame failed\n");
                }
        }
        pthread_mutex_unlock(&g_Mutex);

        return 0;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区