在javascript中实现RTP RTSP [英] RTP RTSP implementation in javascript

查看:906
本文介绍了在javascript中实现RTP RTSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户端程序和一个服务器程序。服务器在我的localhost上,它有我的.mpeg视频。

I have a client program and a server program. The server is on my localhost and it has my .mpeg video.

使用节点JS我应该从服务器流式传输视频。客户端请求消息,例如播放/暂停/恢复/倒带等。所以我想我必须使用RTSP,找出通过RTP发送的内容。但是我不知道从哪里开始。

Using node JS I am supposed to stream a video from a server. The client requests messages, such as play/pause/resume/rewind etc. so I guess I have to use RTSP, to figure out what to send over the RTP. But I don't know from where to start.

到目前为止,我所有的是RegEx来过滤消息,例如在客户端上有像play /这样的按钮暂停/设置等等所以我可以抓住那个文本。我有一个开关。
但是如果我得到设置我应该做什么?

All I have so far is the RegEx to filter the message, for example on the client there are buttons like play/pause/setup etc. so I can grab that text. And I have a switch. But if I get setup what I should I do?

P.S我不允许使用RTSP模块或RTP模块。必须从头开始。

P.S I am not allowed to use RTSP modules or RTP modules. Gotta do it all from scratch.

推荐答案

当通过线路传输mpeg文件时,你必须分别处理RTSP和RTP。 RTSP用于信令,会话建立和启动底层RTP流。如果你需要在node.js中执行此操作,我建议加载一个已经实现RTSP / RTP的库(创建自己的是一个很大的任务,但它是可行的同样)。

When streaming mpeg file over the wire you will have to tackle RTSP and RTP separately. RTSP is used for signaling, session establishing and starting the underlying RTP stream.If you need to do this in node.js, I recommend loading a library that already implements RTSP/RTP(creating your own is quite a undertaking, but it is doable as well).

有关在node.js中加载c ++库的一些信息:如何使用node.js中的C ++库?

Some info on loading c++ libraries in node.js that: How can I use a C++ library from node.js?

所以基本上,从你的mpeg文件,你需要提取原始的h264流。为此我建议ffmpeg或其他一些了解mpeg文件结构的库/代码。然后你需要打包RTP数据包内的编码帧;然后,您将从服务器发送回客户端。然后,客户端将编码的帧解包为实际帧;然后在屏幕上解码/显示它们。

So basically, from you mpeg file, you need to extract raw h264 stream. For this I recommend ffmpeg or some other libraries/code that understands mpeg file structure. Then you need to packetize the encoded frames inside of RTP packets; which you will then send back to the client from the server. The client will then depacketize the encoded frames into actual frame; and then decoded/display them on the screen .

我建议阅读 http://www.ietf.org/rfc/rfc3984.txt 有关打包H264视频的标准方式的信息。

I recommend reading http://www.ietf.org/rfc/rfc3984.txt for info on standard way to packetize H264 video.

这是非常通用的方法,但它给你一个大致的想法。
希望这些信息有所帮助,祝你好运。

This is all very general approach, but it gives you a general idea. Hopefully this info helps, good luck.

这篇关于在javascript中实现RTP RTSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆