Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
InsertableStreams
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Polina Gurtovaya
December 04, 2021
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
InsertableStreams
Polina Gurtovaya
December 04, 2021
More Decks by Polina Gurtovaya
See All by Polina Gurtovaya
Не учите алгоритмы
hellsquirrel
1
1.1k
Давайте все заблокируем
hellsquirrel
0
380
Wasmысле?
hellsquirrel
0
290
Магия декларативныx схем.
hellsquirrel
0
410
ML for HolyJS
hellsquirrel
0
210
Идеальный способ заблюрить белочку
hellsquirrel
0
200
ML/DL на фронте
hellsquirrel
0
250
WebRTC-404
hellsquirrel
0
590
Давайте декодируем кодеки
hellsquirrel
0
620
Featured
See All Featured
Speed Design
sergeychernyshev
33
2.2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
380
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
WCS-LA-2024
lcolladotor
0
980
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
Odyssey Design
rkendrick25
PRO
2
930
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
60k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
520
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Transcript
Смешные шапочки на Insertable Streams
Начнем с WebRTC…
Пересылаем видео, аудио, файлики, скриншару Challenge В условиях Лагающего интернета
Злых админов, настроивших fi rewall Между Большим количеством участников С разными приоритетами 🧟🧟🧟
None
Как работает WebRTC new RTCPeerConnection(…) new RTCPeerConnection(…) 🦄
Media: SRTP + SRTCP Data: SCTP Шифрование Работает поверх UDP→быстрее
Можно терять пакеты, если нужно Не гарантирует порядок Bundling DTLS: TLS для UDP
Как выглядит пожатое видео?
Compression: intra & inter
Intraframe compression (AV1)
Какие кодеки поддерживает ваш браузер?
Чего-то не хватает….
None
Streams 101
None
None
None
None
Insertable-streams const stream = await getUserMedia({ video: true }); const
track = stream.getVideoTracks()[0]; const processor = new MediaStreamTrackProcessor({ track }); const generator = new MediaStreamTrackGenerator({ kind: 'video' }); const transformer = new TransformStream({ async transform(frame, controller) { const newFrame = processFrameSomehow(frame); videoFrame.close(); controller.enqueue(newFrame); }, }); trackProcessor.readable.pipeThrough(transformer).pipeTo(trackGenerator.writable);
Как же нарисовать ?
Нам нужна нейронка :)
Находим точки одевания шапочки Выбираем бекенд •WebAssembly •WebGL •WebGPU Находим
нужную модель или грузим свою • Лучше использовать Lite (Mobile) варианты Закидываем в модель пиксели •getImageData •VideoDecoder.decode Запускаем модель и получаем результат
Рисуем const silhouette = predictions[0].annotations.silhouette const slice = [silhouette[silhouette.length -
4], silhouette[0], silhouette[4]] const hatW = slice[2][0] - slice[0][0] const hatH = hatW * ratio ctx.drawImage(image, slice[0][0] + 0.2 * hatW, slice[0][1] - 0.8 * hatH, hatW, hatH)
Крафтим новый поток const transformer = new TransformStream({ async transform(frame,
controller) { // ... const newFrame = new VideoFrame(canvas, { timestamp: frame.timestamp }) controller.enqueue(newFrame) frame.close() }}) trackProcessor.readable.pipeThrough(transformer).pipeTo(trackGenerator.writable) const transformedStream = new MediaStream([trackGenerator])
None
Что еще можно делать? • Encryption • Analytics • Transcoding
(VideoEncoder) • Frame rate change
@polina_gurtovaya @pgurtovaya @evilmartians @evilmartians_ru evilmartians.com Спасибо!
[email protected]