1

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

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.

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 I am not allowed to use RTSP modules or RTP modules. Gotta do it all from scratch.

9
  • 2
    Could you improve that title? It's truly meaningless to me. Commented Feb 15, 2013 at 3:57
  • how do you want me to improve it? Commented Feb 15, 2013 at 4:20
  • What is your problem with your "RTP?RTSP implementation in javascript" Commented Feb 15, 2013 at 4:22
  • I don't know from where to start. I made my server grab requests from the client such as pause,play resume. but when I get these commands what do I do? I have the video.mpeg how do I use the rtp to send it to the client Commented Feb 15, 2013 at 4:27
  • are you using html5 with websocket? Commented Feb 15, 2013 at 4:45

1 Answer 1

3

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).

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

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 .

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.

Sign up to request clarification or add additional context in comments.

5 Comments

we are not using HTTP though or HTML. I have a .exe client... has the following options SETUP PLAY PAUSE TEARDOWN when the client presses SETUP it sends RTSP message to server and I send RTSP message back and I create a socket for that client. and send an RTP message back saying " 200 OK" using UDP packet. now the next step is.. if the client clicks PLAY I need to get the video and chunk it into frames then use RTP to send it. right now this is where I am at. I need to get that .mpeg file which is already compressed and I need to chunk it down I am assuming I gotta use fs ???
I think better understand your setup now. I would definitely recommend http live streaming of your mpeg file. Otherwise, you would have to add RTSP/RTP support to your server; and then you would have to extract audio/video from mpeg file and then stream audio/video in two separate RTP sessions. Hopefully that helps.
I am not allowed to use http though. like in the project description it says the main goal is implementing RTP and RTSP. they made it easier by not including audio. I am stuck with getting byte array out of the video file. I have to read video file as bytes
ya I forgot to tell you that we r not allowed to use RTP/RTSP modules we have to make our own.
right now... this is the code that I have that gets the first 20 bytes of the video var file = fs.createReadStream(myClient.File, {encoding: 'binary', 'bufferSize': 4 * 1024, start: 0, end: 10}); file.on('error', function(err) { console.log('Error '+err); throw err; }); file.on('data', function(data) { console.log('Data '+data); //send 12 bytes of the frame header that contains the time stamps and cc and and P and etc //sock.write("23323"+data); }); file.on('end', function(){ console.log('Finished reading all of the data'); });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.