H264 Codec Integration for iOS in WebRTC

3,581 views
Skip to first unread message

Alexandre Ohayon

unread,
Apr 17, 2014, 9:47:12 AM4/17/14
to discuss...@googlegroups.com
Hi everyone,

I'm currently trying to implement the support of H264 in webRTC for iOS. For my use, I'm focusing on decoding a H264 stream. I know it's pretty hard, but I might help many people.

From what I read, I see now 3 possible solutions to the problem:
- implementing directly the H264 in the webRTC framework for iOS (using what as been done for VP8 and do an analog implementation), and then recompile the WebRTC libs. This might use FFMPEG libs compiled for iOS. It still looks very complicated.
- using VIEExternalCodec (http://www.webrtc.org/reference/webrtc-internals/vieexternalcodec) and trying to integrate the H264 codec this way. The problem is that VIEExternalCodec doesn't look implemented in WebRTC for iOS
- transmitting binaries through the DataChannel, and then decode the binaries outside the WebRTC framework, using either FFMPEG or AVFoundation for the use of hardware decoding on the device. The problem is that DataChannel doesn't look implemented in WebRTC for iOS.

Did someone already succeed in doing such an implementation? If yes, what's the easiest way to do it? (maybe there's another way..)
Thank in advance for your help.

Kaiduan Xie

unread,
Apr 21, 2014, 10:25:30 AM4/21/14
to discuss...@googlegroups.com
You can apply the patch from


and build OpenH264 on iOS.

/Kaiduan


--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

alexandr...@withings.com

unread,
May 5, 2014, 11:01:05 AM5/5/14
to discuss...@googlegroups.com
Hi,

Thanks a lot for your help. I carefully read your post about integration of openH264 in webRTC and made a lot of tests to implement it correctly. Currently, I'm getting the following error in the compilation of my app, which is directly linked to the lib webrtc_video_coding, modified by the patch :

"Undefined symbols for architecture armv7:
"webrtc::H264Decoder::Create()", referenced from:
webrtc::VCMCodecDataBase::CreateDecoder(webrtc::VideoCodecType) const in libwebrtc_video_coding.a(webrtc_video_coding.codec_database.o)"

the only things I did for now to get this error is getting the webRTC trunk from webrtc svn, and applied the patch you posted on this page: https://webrtc-codereview.appspot.com/11239004/

Kaiduan Xie

unread,
May 5, 2014, 9:11:38 PM5/5/14
to discuss...@googlegroups.com
Alexandre,

You forgot to link webrtc_h264 library.

/Kaiduan


--

alexandr...@withings.com

unread,
May 9, 2014, 7:34:11 AM5/9/14
to discuss...@googlegroups.com
Thanks for your help.

Now I have sucessfully patched my webRTC trunk and linked everything with openH264.

But now, when I get the sdp, the H264 codec is now displaying? I get several audio codecs like opus, ISAC and video codecs like VP8.

Here is the video part of my sdp:

a=mid:video
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=rtcp-mux
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:TKcN6NGHYUvPEMu...
a=rtpmap:100 VP8/90000
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=rtcp-fb:100 goog-remb
a=rtpmap:116 red/90000
a=rtpmap:117 ulpfec/90000

Do you have any idea what I need to add to have to choice to use h264?

Kaiduan Xie

unread,
May 9, 2014, 9:33:31 AM5/9/14
to discuss...@googlegroups.com
Please apply the libjingle patch in the following post,


/Kaiduan

alexandr...@withings.com

unread,
May 9, 2014, 11:09:05 AM5/9/14
to discuss...@googlegroups.com
Thanks a lot, it's working perfectly ;)

alexandr...@withings.com

unread,
Jun 18, 2014, 11:30:35 AM6/18/14
to discuss...@googlegroups.com
@Kaiduan,

Hi! I'm currently trying to improve your patch (especially for iOS). I get a crash on Forward Error Correction when I send frames with a big size. I tried increasing the maximum bitrate allowed in h264_impl.cc , setting the param.iTargetBitrate to a high value (like 10 000 000), but it didn't fix anything. I also tried to use this quick fix: https://groups.google.com/forum/#!searchin/discuss-webrtc/fec_packet_list_/discuss-webrtc/lk5YzEKllKs/xGgs7Ysxi6EJ .
I get a malloc_error, and it happens on several platforms: iOS and Linux, so it's a problem directly in the webrtc libs. Do you have an idea of what to modify to solve this issue? It simply avoids us to send good quality packets.

Thanks a lot for your help.

Bridger Maxwell

unread,
Jun 27, 2014, 12:37:50 AM6/27/14
to discuss...@googlegroups.com
I got that patch applied successfully (thanks!) but when I run AppRTCDemo on two iOS devices (an iPad Air and an iPhone 5s), I only get one frame every 5 seconds or so, even with the camera running at 192x144. The local video renders fine, but the remote video is coming in extremely slowly. When I use vp8, it runs at a decent speed.

I'm trying to profile the app to see what is slow, but nothing obvious is showing up. The CPU is only at about 20% utilization. Any ideas on what could be happening? Is openh264 giving good results for others on iOS?

Once I get this working, I'd like to try using the hardware encoder / decoder exposed in iOS 8.

- Bridger Maxwell

tech74

unread,
Sep 11, 2014, 3:33:58 PM9/11/14
to discuss...@googlegroups.com
Hi 

Did you solve problem with slow send H264 bitrate, I'm getting same results as yourself 7 fps and send bitrate of 80Kbs

THanks

I Ainx

unread,
Oct 9, 2014, 1:01:43 PM10/9/14
to discuss...@googlegroups.com
Hi Bridger,

Did you ever get the hardware encoder/decoder working?

thanks,
iain


On Friday, June 27, 2014 5:37:50 AM UTC+1, Bridger Maxwell wrote:

Divyam Goel

unread,
Aug 15, 2015, 2:31:30 AM8/15/15
to discuss-webrtc
still seeing lower outgoing frame rates with h264 video encoding, any advice ?

Iñaki Baz Castillo

unread,
Aug 15, 2015, 5:20:26 AM8/15/15
to discuss...@googlegroups.com
2014-04-17 15:47 GMT+02:00 Alexandre Ohayon <ohayo...@gmail.com>:
> The problem is that DataChannel doesn't look implemented in WebRTC for iOS.

It is.


--
Iñaki Baz Castillo
<i...@aliax.net>
Reply all
Reply to author
Forward
0 new messages