(windows native) Add h264 hardware encoding to webrtc

2,198 views
Skip to first unread message

51501...@gmail.com

unread,
Dec 10, 2018, 9:36:57 PM12/10/18
to discuss-webrtc
Hi guys, 

Did you ever add h264 hardware encode / decode to webrtc (windows native)?

I am now focus on a project which has 2 sides: 
one side capture the desktop, encode it, send to the other side, the other side decode and show it.

So the first side must capture at least 30 frames per second. But webrtc software encoding is too slow to encode a 1920*1080 frame, 30fps is not possile.
I have to add h264 hardware encode to webrtc.

i am now working on webrtc's #25779 commit (about 2 weeks ago). 
I think webrtc already has the h264 hardware encoding source code. 
May a gn arg will enable it, any idea?

Michael Kris

unread,
Dec 11, 2018, 2:58:27 PM12/11/18
to discuss...@googlegroups.com
As far as I can tell no hardware acceleration is not part of webrtc itself, at-least not libwebrtc implementation but it is part of the chromium implementation, specifically when calling webrtc::CreatePeerConnectionFactory( chromium provides a custom video encoder and decoder factories that could end up creating an accelerated video encoders based on build parameters, runtime parameters etc
to make libwebrtc implement hw encoders you will need to make your own or replicate chrome implementation and that is what I have been doing for the last few days 
 

51501...@gmail.com

unread,
Dec 11, 2018, 8:39:09 PM12/11/18
to discuss-webrtc
Thanks. i will try the same thing you did.

Michael Kris於 2018年12月12日星期三 UTC+8上午3時58分27秒寫道:

51501...@gmail.com

unread,
Dec 11, 2018, 9:43:17 PM12/11/18
to discuss-webrtc
I downloaded chromium source code.
it's hard to find the custom video encoder you mentioned. where is it?

Michael Kris於 2018年12月12日星期三 UTC+8上午3時58分27秒寫道:

Pradeep Kumar

unread,
Dec 12, 2018, 3:46:20 AM12/12/18
to discuss-webrtc
Hi Michael,

I found one of google document about H/W acceleration in Chrome as below:

This might help you to understand better and find related code.

PS: As new to the Chrome, don't know the source dir of H/W acceleration. 

Regards,
Pradeep

Alexandre GOUAILLARD

unread,
Dec 12, 2018, 7:32:14 AM12/12/18
to discuss...@googlegroups.com
chrome design and libwebrtc signs are quite different because of, among other things, the sandboxing. Libwebrtc lives in a single process, i.e. share a memory block across threads, while different process are isolated in chrome. Everything that crosses the boundary then needs to have a different memory model as processes cannot directly share memory. That's one of the reason, and it s illustrated by the IPCs (inter process calls) in the (old design document). 

another reason is the capturer access. To be able to share a cam across tabs, you need the capturer (i.e. almost all GetUserMedia code based) to be in the Browser user agent, and then the frames (possibly rotated and/or scaled) are send over to their respective tabs, using .... yes you know it, IPC. The underlying VideoFrame classes then support different kind of storage: libwebrtc is in-memory by default, chrome can be either IPC-friendly, or GPU texture-based to avoid unnecessary frame copies along the pipeline.

Finally, to be thorough, the Echo cancellation can only be done right at the UA level as well, since it needs to be aware of all the possible audio sources contributing to the audio captured by the mic, and not only a single tab. In the old naive design, if you were opening two tabs, the echo cancellation would fail to take into account the audio coming from the second tab, and it would always fail.

Some other differences between standalone libwebrtc and browsers implementations, including directories are illustrated here (warning, details potentially outdated, but concepts still valid):

hope this helps.


--

---
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/c4e898bb-3510-4b1c-a835-42b90ed786a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Alex. Gouaillard, PhD, PhD, MBA
------------------------------------------------------------------------------------
President - CoSMo Software Consulting, Singapore
------------------------------------------------------------------------------------

Chen Yang

unread,
Dec 22, 2018, 4:18:33 AM12/22/18
to discuss-webrtc
Hi,
I want to do it too.
Do you fix it?
Would you mind to share your experience to me?
And advice will be great.

在 2018年12月11日星期二 UTC+8上午10:36:57,51501...@gmail.com写道:

51501...@gmail.com

unread,
Dec 27, 2018, 4:34:18 AM12/27/18
to discuss-webrtc
i am so close to finish it.
i add nvenc_h264 to implement a h264 hw encoder (with nvenc sdk)

i can encode right but i don't know how to set rtpframgment header
see my another post 

51501...@gmail.com

unread,
Dec 27, 2018, 4:34:52 AM12/27/18
to discuss-webrtc
Reply all
Reply to author
Forward
0 new messages