Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
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
1k
Давайте все заблокируем
hellsquirrel
0
370
Wasmысле?
hellsquirrel
0
270
Магия декларативныx схем.
hellsquirrel
0
400
ML for HolyJS
hellsquirrel
0
190
Идеальный способ заблюрить белочку
hellsquirrel
0
190
ML/DL на фронте
hellsquirrel
0
240
WebRTC-404
hellsquirrel
0
570
Давайте декодируем кодеки
hellsquirrel
0
620
Featured
See All Featured
Ethics towards AI in product and experience design
skipperchong
2
330
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
A Tale of Four Properties
chriscoyier
163
24k
A designer walks into a library…
pauljervisheath
211
24k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
190
Designing for humans not robots
tammielis
254
26k
Statistics for Hackers
jakevdp
799
230k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
350
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
How to make the Groovebox
asonas
2
2.3k
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]