24
PeerConnection リリリリ MediaRecorder WebRTC Meetup Tokyo #10 2016.05.17 リリリリリリリリリリ リリリリリリ @massie_g

PeerConnectionリレーとMediaRecorder

  • Upload
    mganeko

  • View
    1.228

  • Download
    0

Embed Size (px)

Citation preview

PeerConnection リレーとMediaRecorderWebRTC Meetup Tokyo #10

2016.05.17インフォコム株式会社がねこまさし@massie_g

WebRTC Meetup Tokyo #2 にて• 「音声が多段中継できない」

PeerConnection

MediaStream

PeerConnectionMediaStream

配信元

PeerConnection

PeerConnectionMediaStream

中間層

視聴者

音が出ない!!映像は出る

Issue 2192Investigate/ Implement adding remote audio track/stream to a PeerConnection.

• Aug 7, 2013 – Split from https://

code.google.com/p/webrtc/issues/detail?id=383 (Mar 21, 2012) for tracking the work on the audio side.

• May 28, 2014– They are replumbing all the audio stack so it takes some time.

Here is a rough roadmap given earlier this year (march):• Move the WebRTC APM to Chrome• Implement a media stream render mixer in Chrome.• Change the render callback from a pull model to a push model, and

connect the render data to the mixer• Allow WebRtc to pass un-mix data to Chrome through Libjingle, and

add support for relaying the stream.

根が深い、やっかいな問題らしい。残念

遂に対応! Chrome 49 でリリースISSUE 2192

Chrome M49 WebRTC Release Notes

で、やってみた(同一タブだけど)

PeerConnection

MediaStream

PeerConnectionMediaStream

PeerConnection

PeerConnectionMediaStream

音も出た!!映像は出る

PeerConnection PeerConnectionMediaStream

デモhttps://mganeko.github.io/webrtcexpjp/self/relay.html短縮 URL https://goo.gl/dPOIRU

で、何ができるか?• ディレイ !

音声ディレイのデモ(録画)

映像ディレイのデモhttps://mganeko.github.io/webrtcexpjp/self/relay_delay.html短縮 URL https://goo.gl/jo3Hhl

もう少し真面目に、何が嬉しいの?• 社内イベント配信に WebRTC 利用中• 社内ネットワークが細い箇所がある

拠点 1

拠点 2

拠点 4 拠点 3

拠点 6

拠点 5

こんな形で社内配信できるかも(未実施)拠点 1

拠点 2

拠点 4

拠点 3

拠点 6

拠点 5

MediaRecorder

Chrome 49 から MediaRecorder も改善

PeerConnection

PeerConnectionMediaStream

MediaStream

MediaRecorder

MediaRecorder

WebM

WebM

ローカル OK

Chrome 49 からリモートのストリームも録画可能に

MediaRecorder で気になることMediaStream

MediaRecorder

WebM

ビットレート1 ~ 2Mbps

VLC で確認

10 秒で 1.3MB 、 1 分で 7MB 程度

BandWidth を制限したら?

PeerConnection

PeerConnectionMediaStream

MediaStream

MediaRecorder

MediaRecorder

WebM

WebM

ローカル OK

ビットレート1 ~ 2Mbps

通信制限SDP の b=AS で 256kbps

ビットレート256kbps?

• https://mganeko.github.io/webrtcexpjp/self/record_bandwidth.html• 短縮 URL https://goo.gl/6J6yFE

結果 chrome://webrtc-internals/

通信は 256kbps

結果 VLC

ビットレート1 ~ 2Mbps

BandWidth を制限しても

PeerConnection

PeerConnectionMediaStream

MediaStream

MediaRecorder

MediaRecorder

WebM

WebM

ローカル OK

ビットレート1 ~ 2Mbps

通信制限SDP の b=AS で 256kbps

ビットレート1 ~ 2Mbps で、変わらず

MediaRecorder と VP9• https://mganeko.github.io/webrtcexpjp/self/record_relay_vp9.html• 短縮 URL https://goo.gl/agr3Yk

PeerConnection

PeerConnectionMediaStream

MediaStream

MediaRecorder

MediaRecorder

WebM

WebM

SDP でCodec VP9 指定

(普通にやると)VP8 やっぱり VP8

録画のエンコーダー• 通信用のエンコーダーと、録画用のエンコーダーは独立している

PeerConnectionPeerConnectionMediaStream

MediaRecorder

MediaStream

Encoder

WebM

Encoder

MediaRecorder

Encoder

WebM

もともと複数のエンコーダーあり• 複数の相手と通信する場合、別々のエンコーダーを利用

PeerConnectionPeerConnectionMediaStream Encoder

MediaRecorder

Encoder

WebM

PeerConnection PeerConnectionEncoder

PeerConnection PeerConnectionEncoder

VP9 で録画する正しい方法// Chrome 50 で確認var options = {mimeType: 'video/webm; codecs=vp9'};var recorder = new MediaRecorder(localStream, options);

https://mganeko.github.io/webrtcexpjp/self/record_vp9.html短縮 URL https://goo.gl/3hpkhA

MediaRecorder でビットレート調整(将来)// 仕様にはあるけど、今は効かないvar options = { audioBitsPerSecond : 32000, videoBitsPerSecond : 256000, mimeType : 'video/webm'};var mediaRecorder = new MediaRecorder(stream, options);

Thank you!