SlideShare a Scribd company logo
1 of 34
Creating React for live streams
Low-latency multimedia insights
Wojciech Barczyński
React for live streams?
How it works?
Let’s get started!
Weird 50% packet loss… on localhost?
Observed issues
● Weird packet loss on localhost while streaming with RTP
● A few first packets were correct
● Many next packets were lost
● Only happened on Linux - worked fine on MacOS
UDP buffer overflow
Problems:
● By default UDP buffers on Linux are small (usually ~200kB)
● UDP packets are discarded and lost if overflow occurs
Solutions:
● Increasing UDP buffer size
● Speeding-up reading from UDP sockets
Usually packets are coming in batches
Decoders
Test performance with “real” video
Hardware decoding/encoding
● Decoding/encoding is often the most computationally
expensive part of the pipeline
● With FFmpeg / GStreamer changing decoders/encoders is
quite easy
● Low-hanging fruit in optimization process
Reducing memory copying with
hardware decoding/encoding
Queue - one element to rule them all!
Synchronizing streams, lazy decoding, network instability handling
Queue
Buffering:
● Reducing impact of network unreliability
● Helps stream synchronization
Back-pressure:
● Reducing RAM usage with lazy decoding
Rendering / Mixing
Preallocating memory
● Memory allocations are slow
● It’s faster to copy memory to preallocated buffer, than
allocating memory “on the fly”
What we did?
● GPU textures are preallocated - we don’t need to do large
allocations on each render
● LiveCompositor sometimes use stack preallocated array
buffers instead of heap OTF allocated data structures
Profiling - check your hardware
With GPU rendering:
● Decoding & encoding - >70% CPU usage
● Rendering - <1% CPU usage
● Rendering cost is negligible
With emulating rendering on CPU:
● Rendering - ~70% CPU usage
(depends on render complexity)
Profiling - check your hardware
We optimized renders to be able to run on servers
without GPU by:
● Rendering text/image textures only once
● Flattening all “div”-s to render them at once
Encoders - low effort optimizations
Encoders - low effort optimizations
Hardware encoding has worst quality, but is much faster.
Changing encoder setting can greatly impact your performance:
● Encoder preset and bitrate are most important
● ip-factor (key-frames / p-frames), tune etc. also have some
impact on performance and latency
Sending outputs
Sending outputs - know your players!
Sending outputs - know your players!
Not all players work in the same way!
Some players can handle metadata differently.
Examples:
● Different SDP handling
● Disregarding audio PTS values
Ask important questions
Before optimizing your pipeline, you should consider:
● Does it have to be real-time?
● Costs of the other parts of infrastructure
Does it have to be real-time?
If you can process it offline, maybe it’s not worth to do it real-
time.
LiveCompositor also supports offline processing
With offline processing you can:
- reduce complexity
- send streams reliably, without losing frames (e.g. TCP vs
UDP)
- process all streams without dropping frames
- perform operations with frame-perfect precision
Cost of the other parts of infrastructure
Live demo
Announcements
Stable API
Questions?
Thanks for listening

More Related Content

Similar to Creating React for live streams - Insights on low-latency multimedia processing

Industrial Technology Multimedia Video Theory Prelim Course
Industrial Technology Multimedia Video Theory Prelim CourseIndustrial Technology Multimedia Video Theory Prelim Course
Industrial Technology Multimedia Video Theory Prelim Course
jliang2145
 
Audio in linux embedded
Audio in linux embeddedAudio in linux embedded
Audio in linux embedded
trx2001
 
The components of a computer
The components of a computerThe components of a computer
The components of a computer
trisson255
 

Similar to Creating React for live streams - Insights on low-latency multimedia processing (20)

Bitmovin Low Latency CMAF Presentation_Streaming Media East by Paul MacDougall
Bitmovin Low Latency CMAF Presentation_Streaming Media East by Paul MacDougallBitmovin Low Latency CMAF Presentation_Streaming Media East by Paul MacDougall
Bitmovin Low Latency CMAF Presentation_Streaming Media East by Paul MacDougall
 
Optimizing Linux Servers
Optimizing Linux ServersOptimizing Linux Servers
Optimizing Linux Servers
 
Nimble Streamer Transcoder overview
Nimble Streamer Transcoder overviewNimble Streamer Transcoder overview
Nimble Streamer Transcoder overview
 
Industrial Technology Multimedia Video Theory Prelim Course
Industrial Technology Multimedia Video Theory Prelim CourseIndustrial Technology Multimedia Video Theory Prelim Course
Industrial Technology Multimedia Video Theory Prelim Course
 
VMworld 2013: How Good is PCoIP - A Remoting Protocol Shootout
VMworld 2013: How Good is PCoIP - A Remoting Protocol ShootoutVMworld 2013: How Good is PCoIP - A Remoting Protocol Shootout
VMworld 2013: How Good is PCoIP - A Remoting Protocol Shootout
 
Processor Organization
Processor OrganizationProcessor Organization
Processor Organization
 
I pod new
I pod newI pod new
I pod new
 
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheapUWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
UWE Linux Boot Camp 2007: Hacking embedded Linux on the cheap
 
Native IP Decoding MPEG-TS Video to Uncompressed IP (and Vice versa) on COTS ...
Native IP Decoding MPEG-TS Video to Uncompressed IP (and Vice versa) on COTS ...Native IP Decoding MPEG-TS Video to Uncompressed IP (and Vice versa) on COTS ...
Native IP Decoding MPEG-TS Video to Uncompressed IP (and Vice versa) on COTS ...
 
uRock @ Jserv Course Final
uRock @ Jserv Course Final uRock @ Jserv Course Final
uRock @ Jserv Course Final
 
Audio in linux embedded
Audio in linux embeddedAudio in linux embedded
Audio in linux embedded
 
"Making Computer Vision Software Run Fast on Your Embedded Platform," a Prese...
"Making Computer Vision Software Run Fast on Your Embedded Platform," a Prese..."Making Computer Vision Software Run Fast on Your Embedded Platform," a Prese...
"Making Computer Vision Software Run Fast on Your Embedded Platform," a Prese...
 
Hardware hacking
Hardware hackingHardware hacking
Hardware hacking
 
Baking a Raspberry PI with Chef Rob
Baking a Raspberry PI with Chef RobBaking a Raspberry PI with Chef Rob
Baking a Raspberry PI with Chef Rob
 
GPU Computing for Data Science
GPU Computing for Data Science GPU Computing for Data Science
GPU Computing for Data Science
 
Linux Hosting Training Course Level 1-1
Linux Hosting Training Course Level 1-1Linux Hosting Training Course Level 1-1
Linux Hosting Training Course Level 1-1
 
N5 ISDD Hardware Requirements
N5 ISDD Hardware RequirementsN5 ISDD Hardware Requirements
N5 ISDD Hardware Requirements
 
Computer systems|Computer Networking & Communication System Assignment - Netw...
Computer systems|Computer Networking & Communication System Assignment - Netw...Computer systems|Computer Networking & Communication System Assignment - Netw...
Computer systems|Computer Networking & Communication System Assignment - Netw...
 
The components of a computer
The components of a computerThe components of a computer
The components of a computer
 
Design in Motion: Video Production Workflow
Design in Motion: Video Production WorkflowDesign in Motion: Video Production Workflow
Design in Motion: Video Production Workflow
 

Recently uploaded

Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 

Recently uploaded (20)

Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 

Creating React for live streams - Insights on low-latency multimedia processing

  • 1. Creating React for live streams Low-latency multimedia insights Wojciech Barczyński
  • 2. React for live streams?
  • 5. Weird 50% packet loss… on localhost?
  • 6. Observed issues ● Weird packet loss on localhost while streaming with RTP ● A few first packets were correct ● Many next packets were lost ● Only happened on Linux - worked fine on MacOS
  • 7. UDP buffer overflow Problems: ● By default UDP buffers on Linux are small (usually ~200kB) ● UDP packets are discarded and lost if overflow occurs Solutions: ● Increasing UDP buffer size ● Speeding-up reading from UDP sockets
  • 8. Usually packets are coming in batches
  • 10. Test performance with “real” video
  • 11. Hardware decoding/encoding ● Decoding/encoding is often the most computationally expensive part of the pipeline ● With FFmpeg / GStreamer changing decoders/encoders is quite easy ● Low-hanging fruit in optimization process
  • 12. Reducing memory copying with hardware decoding/encoding
  • 13. Queue - one element to rule them all! Synchronizing streams, lazy decoding, network instability handling
  • 14. Queue Buffering: ● Reducing impact of network unreliability ● Helps stream synchronization Back-pressure: ● Reducing RAM usage with lazy decoding
  • 16. Preallocating memory ● Memory allocations are slow ● It’s faster to copy memory to preallocated buffer, than allocating memory “on the fly” What we did? ● GPU textures are preallocated - we don’t need to do large allocations on each render ● LiveCompositor sometimes use stack preallocated array buffers instead of heap OTF allocated data structures
  • 17. Profiling - check your hardware With GPU rendering: ● Decoding & encoding - >70% CPU usage ● Rendering - <1% CPU usage ● Rendering cost is negligible With emulating rendering on CPU: ● Rendering - ~70% CPU usage (depends on render complexity)
  • 18. Profiling - check your hardware We optimized renders to be able to run on servers without GPU by: ● Rendering text/image textures only once ● Flattening all “div”-s to render them at once
  • 19. Encoders - low effort optimizations
  • 20. Encoders - low effort optimizations Hardware encoding has worst quality, but is much faster. Changing encoder setting can greatly impact your performance: ● Encoder preset and bitrate are most important ● ip-factor (key-frames / p-frames), tune etc. also have some impact on performance and latency
  • 22. Sending outputs - know your players!
  • 23. Sending outputs - know your players! Not all players work in the same way! Some players can handle metadata differently. Examples: ● Different SDP handling ● Disregarding audio PTS values
  • 24.
  • 25. Ask important questions Before optimizing your pipeline, you should consider: ● Does it have to be real-time? ● Costs of the other parts of infrastructure
  • 26. Does it have to be real-time? If you can process it offline, maybe it’s not worth to do it real- time. LiveCompositor also supports offline processing With offline processing you can: - reduce complexity - send streams reliably, without losing frames (e.g. TCP vs UDP) - process all streams without dropping frames - perform operations with frame-perfect precision
  • 27. Cost of the other parts of infrastructure
  • 31.
  • 32.