5

My requirement is to get iphone camera feed, encode it into H264 format and send it to server. In search, I found encoding part is possible with ffmpeg lib with x264 (libx264). But now the next task is to send the encoded data to Wowza server using rtsp.

Please share some code or useful document if anyone is aware about this.

There is one another library for encoding purpose live555. But I am not sure it can send the data to server using rtsp.

Santhosh
  • 28,097
  • 9
  • 82
  • 87
Vishal Lohia
  • 61
  • 1
  • 4

4 Answers4

4

Actualy I made an iOS streaming app (with wowza as streaming server)

I believe you can stream video only with FFmpeg with rtsp protocol although FFmpeg don't fully support it

However with ffmpeg you can get a valid SDP and pass it to wowza using RTCP protocol - ANNOUNCE OPTION SETUP RECORD -

I didn't use FFmpeg for encoding but if you can get the raw H264 data you can packetize it to make a valid RTP packet using rfc6184

edit : here is a sample to connect wowza :

    NSString* response = [NSString stringWithFormat:@"ANNOUNCE %@ RTSP/1.0\r\n",self->addr];
    response = [response stringByAppendingFormat:@"CSeq: %d\r\n",self->cseq];
    response = [response stringByAppendingFormat:@"Content-Type: application/sdp\r\nContent-Length: %d\r\n\r\n", [self->sdp length] ];
    response = [response stringByAppendingString:self->sdp];
    NSString* result = [self sendAndRecvData:response];

where sendAndRecvData is a tcp socket bound to wowza_ip:1935

you can use the same kind of code for SETUP, which will send back RTP (+RTCP) ports where you should send your datas

Community
  • 1
  • 1
HaneTV
  • 916
  • 1
  • 7
  • 24
  • Can you describe bit more how to create connection with wowza server and create the packets kind of stuff. With FFMPEG it is very hard to find the functions and sequence to calling functions. It is really messed up. – Vishal Lohia Aug 01 '13 at 12:08
  • you can find an rtp packetizer in libavformat/rtpenc.c source. For the wowza connection part, you can begin with a static sdp file in the /content directory, and look for RTCP announce protocol. I'm still a beginer so my code is very messy, I reversed Wirecast protocol to make it works – HaneTV Aug 01 '13 at 12:47
  • sry for double post : here is [my related wowza post on their forum](http://www.wowza.com/forums/showthread.php?29806-RTP-RTSP-streaming-is-there-a-way-to-transmit-sdp) – HaneTV Aug 01 '13 at 12:56
  • Hane, I am facing problem to understand how to create packets, and send the data to server. I have even compile various other libraries like live555 and cURL but again stuck at initial point how to proceed. – Vishal Lohia Aug 12 '13 at 09:40
  • Do you mean video rtp packets ? – HaneTV Aug 12 '13 at 10:42
  • yes, how to create packets from encoded data and how to send these to wowza server using rtsp. – Vishal Lohia Aug 13 '13 at 05:52
  • [rfc 3984](http://www.ietf.org/rfc/rfc3984.txt) may helps you to create a h264 rtp packetizer. All you need is to create a 12 bytes header for your encoded data and send it to wowza (udp). FFmpeg should give you an SDP file that you need to put in wowza content folder. According to your SDP file, Wowza will listen specified ports. Your project is not an easy one and if you begin with RTSP protocol you can read "RTP Audio and Video for the internet" by Colin Perkins. – HaneTV Aug 13 '13 at 08:02
  • Hane, do you have any idea about rtsp tunneling over http. I understood this point as we can send the data to server http post by sending first the options, describe, setup formats of rtsp into http body. Please correct me on this. – Vishal Lohia Aug 15 '13 at 16:49
  • I don't know much about this, I believe [spydroid](https://code.google.com/p/spydroid-ipcamera/) is using http tunneling. I will edit my 1st answer – HaneTV Aug 16 '13 at 07:52
  • Hi Hane, As per your code snippet in the above thread, I am able to send the initial commands to wowza and getting the RTSP OK responses. Now my next job is to send the encoded video data to wowza. For this I am creating two udp socket connection with ports which I am getting in SETUP response. I am sending directly video data in udp socket. Can you tell me, if there is any specific udp packet structure in which I need to send the data. Write Now I am facing error : WARN server comment - RTPDePacketizerBase.checkRTCPSSRC: ssrc error: 0:2e345555 – Vishal Lohia Aug 28 '13 at 12:08
  • hi, as I said you should read rfc 3984 and "RTP Audio and Video for the internet" by Colin Perkins – HaneTV Aug 29 '13 at 08:01
  • Thanks Hane I first go through this document and then come back to you – Vishal Lohia Aug 29 '13 at 11:10
  • Hane, I gone through the rfc3984 doc, but it is very hard to think and understand this in programming paradigm. But I found "Geraint Davies" blog http://www.gdcl.co.uk/2013/02/20/iOS-Video-Encoding.html where he has provided sample code with H264 encoding and NALU classes. Now I uses these class to send the packet to wowza but still I am facing error RTPDePacketizerBase.checkRTCPSSRC: ssrc error: 0:2e345555. Does such kind of error is due to bad packet creation or something else.. – Vishal Lohia Sep 02 '13 at 15:22
  • I don't know how do you make your packets, the error seems to be related to your ssrc field. Is it the same in rtp packets and rtcp ones ? – HaneTV Sep 03 '13 at 07:35
  • value to ssrc variable is initialize as : _ssrc = random(); – Vishal Lohia Sep 03 '13 at 14:15
  • Correction in above comment value to ssrc variable is initialize as : _ssrc = random() and in header packet we write _ssrc as : tonet_long(packet + 8, _ssrc) and in rtcp packet tonet_long(buf+4, _ssrc) – Vishal Lohia Sep 03 '13 at 14:32
  • Hi Hane,
    I am getting some logs on wowza as
    RTSPRequestAdapter.getAuthenticationHandler: Unknown method: 0
    RTSPRequestAdapter.service: Unknown method: unknown
    – Vishal Lohia Sep 05 '13 at 15:01
1

Your using live555 , you can use a live 555 server living on the device to send both audio and video, this will give you rtsp+rtcp stream to wowza, for announce and record live 555 has an unsupported dss module.

Michelle Cannon
  • 1,341
  • 8
  • 8
  • can you provide some code snippet for that or some document which describe the classes and functions needs to be used to make connection, and stream publishing – Vishal Lohia Aug 12 '13 at 09:43
  • Michelle, I compiled the live555, But when I used it in XCode project then it start giving errors. Code is not able to unnderstand c++ class types. Can you tell me about the settings I need to do when I use live555 for iOS. – Vishal Lohia Aug 18 '13 at 14:23
  • if you contact me directly I can help you, but it will take much more time then I have this minute, sorry – Michelle Cannon Aug 18 '13 at 18:36
0

Wowza has an iPhone app called GoCoder which will send a live encoded stream to a Wowza server.

Barlas Apaydin
  • 7,233
  • 11
  • 55
  • 86
Scott
  • 1
  • can we send the iphone live camera stream to wowza using http live streaming and for this what kind of settings we need to do on server side. – Vishal Lohia Aug 12 '13 at 09:45
0

You can stream directly to a Wowza server using RTMP instead of RTSP. The ffmpeg command is something like:

ffmpeg -re -i localFile.mp4 -c copy -f flv rtmp://server/live/streamName

As long as you specify your output format as flv and the output destination as rtmp://xxx then you should be OK.

Source: ffmpeg streaming