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.

twix
  • 11
  • 1
  • 4

1 Answers1

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.

Community
  • 1
  • 1
Aki
  • 3,709
  • 2
  • 29
  • 37
  • 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 ??? – twix Feb 22 '13 at 17:11
  • 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. – Aki Feb 22 '13 at 17:41
  • 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 – twix Feb 22 '13 at 21:14
  • ya I forgot to tell you that we r not allowed to use RTP/RTSP modules we have to make our own. – twix Feb 22 '13 at 22:57
  • 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'); }); – twix Feb 22 '13 at 22:58