1

I am working on screen sharing related project, and the only problem i encounter there is the need to display a screen shared from a PC or a Mac (Chromium browser, in fact an Electron app), on a Raspberry PI (i am using model 3 B, the most modern one). In my experiments, the project is just beginning, i am using RTCMultiConnection to share screen and watch it.

Problem is, it is uselessly slow (2-3 fps, sometimes with a 10 second delay) even with full HW acceleration enabled in Chromium which displays it, and i perfectly understand why: because it uses VP9 codec, for which no HW acceleration exists on Raspberry.

Question is: can i use H264 in RTCMultiConnection? If yes, how? I know WebRTC itself basically supports it.

4

1 回答 1

2

Add following code in your HTML demo file:

connection.processSdp = function(sdp) {
    // remove VP8+VP9 so that Firefox can use H264
    sdp = CodecsHandler.removeVPX(sdp);
    return sdp;
};

Go to "dev" directory and open this file: dev/CodecsHandler.js#L5-L30 line 5 to 30.

Make sure that VP8 and VP9 line sare correct.

a=rtpmap:100
a=rtpmap:101

Maybe VP8 is 96 and VP9 is 98. So replace rtpmap accordingly. E.g.

a=rtpmap:96
a=rtpmap:98

Make sure to test only using Firefox. I donno if Chrome stable channel also supports H264.

Fireox may require some flags. You can search h264 flags on about:config

Make sure to link dev/CodecsHandler.js in your HTML demo file, quickly after dist/RTCMultiConnection.min.js.

<script src="dist/RTCMultiConnection.min.js"></script>
<script src="dev/CodecsHandler.js"></script>
<script>
var connection = new RTCMultiConnection();
connection.socketURL = 'https://yourserver.com:9001/';
connection.processSdp = function(sdp) {
    // remove VP8+VP9 so that Firefox can use H264
    sdp = CodecsHandler.removeVPX(sdp);
    return sdp;
};
connection.openOrJoin('roomid');
</script>
于 2017-10-07T17:21:26.400 回答