SlideShare a Scribd company logo
1 of 38
Download to read offline
Videostream compression
in iOS
Uladzimir
Predka
iOS developer,
*instinctools
1. A little bit about codecs and containers
2. A little bit about streaming
3. How to arrange it for iOS
4. Comparison of different approaches for compressing videostream
Owerview
About codecs and containers
The container is a file or streaming format, which takes care of packaging,
transport, and presentation of information which is inside of it.
About codecs and containers
Examples of containers:
● AVI
● MKV
● QuickTime
● MP4
● MPEG-TS
About codecs and containers
Examples of codecs:
Video:
● MPEG-4
● DivX
● h.264/x.264
Audio:
● MP3
● AAC
● DTS
What about the mechanism of media streaming?
Stream media is a multimedia which is continuously obtained by the user from the
streaming provider.
● live-streaming
● streaming on demand
What about the mechanism of media streaming?
Media data -> large amounts -> expensive storage and transmission
Recommended stream bandwidth:
● not HD video ~2 Mbit/s
● HD video ~5 Mbit/s
● UHD ~9Mbit/s
What about the mechanism of media streaming?
Example of calculation of the bandwidth:
1hour of video 320 × 240 ~ 300kbit/s ~128MB
for 1 thousand of users - 300Mbit/s == 135GB/h
What about the mechanism of media streaming?
The protocols used for streaming:
For audio compression: MP3, AAC, Vorbis ...
For video compression: h.264, VP8 …
Containers: MP4, FLV...
What about the mechanism of media streaming?
Transport protocols:
Used for media delivery from server to client.
RTMP (Real Time Messaging Protocol)
RTP (Real-time Transport Protocol) + RTCP
RTSP (Real Time Streaming Protocol)
What about the mechanism of media streaming?
Transport protocols:
Newer: Apple’s HLS, Adobe’s HDS, MPEG-DASH
The process often consists of two stages:
1. The delivery of stream to the server using the transport protocol (streaming
transport protocol)
2. Translation from server to final user (HTTP based protocols)
What about the mechanism of media streaming?
HLS (HTTP Live Streaming)
It is based on the principle of splitting the stream into fragments.
It uses advanced m3u playlist, which is downloaded at the beginning of the
session and contains metadata about the nested streams.
What about the mechanism of media streaming?
HLS (HTTP Live Streaming)
It involves the use of an intermediate server that:
1. transforms the media-stream into the correct format: h.264, MP3/HE-AAC/AC-
3 and packs into the MPEG-TS container
2. splits the MPEG-TS file into fragments of equal length + creates an index file
with a link to fragments (.m3u8)
How to compress video in iOS?
Life before iOS 8:
Hardware:
By using AVAssetWriter -> we write to a file (for online streaming write small
files, then read them and pass)
Software:
Using any third-party library (eg ffmpeg)
How to compress video in iOS?
Life after iOS 8:
VideoToolbox appears
How to compress video in iOS?
AVFoundation:
● Decoding directly when displaying.
● Encoding into file
VideoToolbox:
● Decoding frames into CVPixelBuffer
● Encoding frames into CMSampleBuffer
How to compress video in iOS?
Briefly about h.264:
● widely used
● gives much a better picture quality at lower bit rates (MPEG-2)
● ideal for videostreaming
● ...
How to compress video in iOS?
Briefly about h.264:
It uses two approaches to reduce the size of the video:
● It compresses data within one frame
● It compresses the data using information from the group of pictures (pictures
are grouped into groups GOP)
How to compress video in iOS?
Briefly about h.264: GOP (Group of Pictures )
How to compress video in iOS?
Briefly about h.264: GOP (Group of Pictures )
I-frames: (key-frame) - self-sufficient, has the biggest size, the fastest decoding.
P-frames: (predicted frame) - uses information from the nearest P- or I-frame
B-frame: (bidirectional frame) - used information from the frames before and after
current
How to compress video in iOS?
VideoToolbox: the main points
It provides direct access to the decoder / encoder.
It depends on CoreMedia, CoreVideo and CoreFoundation
It requires additional work with buffers obtained from the encoder.
The process of preparing videostream in iOS
1. Capture video from the device -> CMSampleBuffer with uncompressed
frame data
2. Compressing frame by encoder from VideoToolbox -> CMSampleBuffer
with compressed frame data
3. Converting the stream of CMSampleBuffer into NALUs streaming trough the
network
The process of preparing videostream in iOS
The process of preparing videostream in iOS
The process of preparing videostream in iOS
Compression process:
1. Create and configure VTCompressionSession by using
VTCompressionSessionCreate, as one of the parameters we pass a
pointer to encoding callback-function
2. Call VTCompressionSessionEncodeFrame, as one of the parameters we
pass CVPixelBufferRef, repeat for each frame.
3. Process CMSampleBuffer that we get from encoder callback.
The process of preparing videostream in iOS
The creation of СompressionSession
The process of preparing videostream in iOS
Sending the buffer to the compression:
The process of preparing videostream in iOS
The signature of the callback-function:
The process of preparing videostream in iOS
Then it is necessary to convert stream of CMSampleBuffers to the stream of
packets suitable for further transmission over the network.
The process of preparing videostream in iOS
The process of preparing videostream in iOS
The process of preparing videostream in iOS
Getting the parameters from sampleBuffer's I-frame
The process of preparing videostream in iOS
Annex B vs AVCC
The process of preparing videostream in iOS
Getting raw compressed data:
The process of preparing videostream in iOS
Profit
The process of preparing videostream in iOS
Профит
Thanks for your attention!
More info:
1. WWDC, 513 - 2014 (https://developer.apple.com/videos/play/wwdc2014/513/)
2. “Learning AVFoundation: …” by Bob McCune

More Related Content

What's hot

OWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
OWASP AppSecEU 2018 – Attacking "Modern" Web TechnologiesOWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
OWASP AppSecEU 2018 – Attacking "Modern" Web TechnologiesFrans Rosén
 
Intégration de SonarQube dans GitLab ci
Intégration de SonarQube dans GitLab ciIntégration de SonarQube dans GitLab ci
Intégration de SonarQube dans GitLab ciwiemfourati
 
常見設計模式介紹
常見設計模式介紹常見設計模式介紹
常見設計模式介紹Jace Ju
 
Play with FILE Structure - Yet Another Binary Exploit Technique
Play with FILE Structure - Yet Another Binary Exploit TechniquePlay with FILE Structure - Yet Another Binary Exploit Technique
Play with FILE Structure - Yet Another Binary Exploit TechniqueAngel Boy
 
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)LanarkSeung
 
191019 Forward / Deferred Rendering
191019 Forward / Deferred Rendering191019 Forward / Deferred Rendering
191019 Forward / Deferred RenderingKWANGIL KIM
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricksJavier Eguiluz
 
[JWAP-2] DI & Spring
[JWAP-2] DI & Spring[JWAP-2] DI & Spring
[JWAP-2] DI & SpringYoung-Ho Cho
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling RewriterJustin Edelson
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016Frans Rosén
 
[데브루키] Color space gamma correction
[데브루키] Color space gamma correction[데브루키] Color space gamma correction
[데브루키] Color space gamma correctionMinGeun Park
 
Testes pythonicos com pytest
Testes pythonicos com pytestTestes pythonicos com pytest
Testes pythonicos com pytestviniciusban
 
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Unity Technologies
 
Automate Behavior-driven Development | DrupalCon Portland 2022
Automate Behavior-driven Development | DrupalCon Portland 2022Automate Behavior-driven Development | DrupalCon Portland 2022
Automate Behavior-driven Development | DrupalCon Portland 2022DOCOMO Innovations, Inc.
 

What's hot (20)

OWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
OWASP AppSecEU 2018 – Attacking "Modern" Web TechnologiesOWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
OWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
 
Intégration de SonarQube dans GitLab ci
Intégration de SonarQube dans GitLab ciIntégration de SonarQube dans GitLab ci
Intégration de SonarQube dans GitLab ci
 
常見設計模式介紹
常見設計模式介紹常見設計模式介紹
常見設計模式介紹
 
Play with FILE Structure - Yet Another Binary Exploit Technique
Play with FILE Structure - Yet Another Binary Exploit TechniquePlay with FILE Structure - Yet Another Binary Exploit Technique
Play with FILE Structure - Yet Another Binary Exploit Technique
 
Python decorators
Python decoratorsPython decorators
Python decorators
 
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
 
191019 Forward / Deferred Rendering
191019 Forward / Deferred Rendering191019 Forward / Deferred Rendering
191019 Forward / Deferred Rendering
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
PHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and SessionsPHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and Sessions
 
[JWAP-2] DI & Spring
[JWAP-2] DI & Spring[JWAP-2] DI & Spring
[JWAP-2] DI & Spring
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling Rewriter
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 
[데브루키] Color space gamma correction
[데브루키] Color space gamma correction[데브루키] Color space gamma correction
[데브루키] Color space gamma correction
 
D2 Hdr
D2 HdrD2 Hdr
D2 Hdr
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
SonarQube for AEM
SonarQube for AEMSonarQube for AEM
SonarQube for AEM
 
Testes pythonicos com pytest
Testes pythonicos com pytestTestes pythonicos com pytest
Testes pythonicos com pytest
 
Mimikatz
MimikatzMimikatz
Mimikatz
 
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
 
Automate Behavior-driven Development | DrupalCon Portland 2022
Automate Behavior-driven Development | DrupalCon Portland 2022Automate Behavior-driven Development | DrupalCon Portland 2022
Automate Behavior-driven Development | DrupalCon Portland 2022
 

Viewers also liked

AVFoundation @ TACOW 2013 05 14
AVFoundation @ TACOW 2013 05 14AVFoundation @ TACOW 2013 05 14
AVFoundation @ TACOW 2013 05 14Ryder Mackay
 
社内勉強会02 ターミナルマルチプレクサ[公開用]
社内勉強会02 ターミナルマルチプレクサ[公開用]社内勉強会02 ターミナルマルチプレクサ[公開用]
社内勉強会02 ターミナルマルチプレクサ[公開用]Keme Sato
 
Cognitive Foreplay
Cognitive ForeplayCognitive Foreplay
Cognitive ForeplayPK Rasam
 
The Benefits of Social Media Listening for Advancement in Higher Education
The Benefits of Social Media Listening for Advancement in Higher Education The Benefits of Social Media Listening for Advancement in Higher Education
The Benefits of Social Media Listening for Advancement in Higher Education Lisa Kalner Williams
 
How to build an environment that enables Innovation.
How to build an environment that enables Innovation.How to build an environment that enables Innovation.
How to build an environment that enables Innovation.Johanna Green
 
Twitter, una sonda permanente de opinión y una vía para canalizar acciones ci...
Twitter, una sonda permanente de opinión y una vía para canalizar acciones ci...Twitter, una sonda permanente de opinión y una vía para canalizar acciones ci...
Twitter, una sonda permanente de opinión y una vía para canalizar acciones ci...Mª Luz Congosto
 
OpenFlowコントローラ開発支援ツールの提案
OpenFlowコントローラ開発支援ツールの提案OpenFlowコントローラ開発支援ツールの提案
OpenFlowコントローラ開発支援ツールの提案Yutaka Yasuda
 
Gamification - Elements for a Gamification Learning Strategy
Gamification - Elements for a Gamification Learning StrategyGamification - Elements for a Gamification Learning Strategy
Gamification - Elements for a Gamification Learning StrategyAndrew Hughes
 
Inspirational Quotes
Inspirational QuotesInspirational Quotes
Inspirational QuotesMark Gilroy
 
20160521謝昇佑-不安分的創業:好食機的社會企業
20160521謝昇佑-不安分的創業:好食機的社會企業20160521謝昇佑-不安分的創業:好食機的社會企業
20160521謝昇佑-不安分的創業:好食機的社會企業youthsummit
 
CVPR2015勉強会 Global Refinement of Random Forest
CVPR2015勉強会 Global Refinement of Random ForestCVPR2015勉強会 Global Refinement of Random Forest
CVPR2015勉強会 Global Refinement of Random ForestKoichi Takahashi
 
The Arrival Discussion Questions - Chapter 1
The Arrival Discussion Questions - Chapter 1The Arrival Discussion Questions - Chapter 1
The Arrival Discussion Questions - Chapter 1grantthomasonline
 
Heroku Dyno再起動時の振る舞い
Heroku Dyno再起動時の振る舞いHeroku Dyno再起動時の振る舞い
Heroku Dyno再起動時の振る舞いShunji Konishi
 
実装だって楽したい!〜リアルタイム通信はじめの一歩〜
実装だって楽したい!〜リアルタイム通信はじめの一歩〜実装だって楽したい!〜リアルタイム通信はじめの一歩〜
実装だって楽したい!〜リアルタイム通信はじめの一歩〜Yuka Tokuyama
 
IETF remote participation via Meetecho @ WebRTC Meetup Stockholm
IETF remote participation via Meetecho @ WebRTC Meetup StockholmIETF remote participation via Meetecho @ WebRTC Meetup Stockholm
IETF remote participation via Meetecho @ WebRTC Meetup StockholmLorenzo Miniero
 
Caso clínico - Otorrino Mazatlán
Caso clínico - Otorrino MazatlánCaso clínico - Otorrino Mazatlán
Caso clínico - Otorrino MazatlánOtorrino Mazatlán
 

Viewers also liked (20)

AVFoundation @ TACOW 2013 05 14
AVFoundation @ TACOW 2013 05 14AVFoundation @ TACOW 2013 05 14
AVFoundation @ TACOW 2013 05 14
 
社内勉強会02 ターミナルマルチプレクサ[公開用]
社内勉強会02 ターミナルマルチプレクサ[公開用]社内勉強会02 ターミナルマルチプレクサ[公開用]
社内勉強会02 ターミナルマルチプレクサ[公開用]
 
El Modelo de los Tres Tableros
El Modelo de los Tres TablerosEl Modelo de los Tres Tableros
El Modelo de los Tres Tableros
 
Math
MathMath
Math
 
A history of programming
A history of programmingA history of programming
A history of programming
 
Cognitive Foreplay
Cognitive ForeplayCognitive Foreplay
Cognitive Foreplay
 
The Benefits of Social Media Listening for Advancement in Higher Education
The Benefits of Social Media Listening for Advancement in Higher Education The Benefits of Social Media Listening for Advancement in Higher Education
The Benefits of Social Media Listening for Advancement in Higher Education
 
How to build an environment that enables Innovation.
How to build an environment that enables Innovation.How to build an environment that enables Innovation.
How to build an environment that enables Innovation.
 
Twitter, una sonda permanente de opinión y una vía para canalizar acciones ci...
Twitter, una sonda permanente de opinión y una vía para canalizar acciones ci...Twitter, una sonda permanente de opinión y una vía para canalizar acciones ci...
Twitter, una sonda permanente de opinión y una vía para canalizar acciones ci...
 
OpenFlowコントローラ開発支援ツールの提案
OpenFlowコントローラ開発支援ツールの提案OpenFlowコントローラ開発支援ツールの提案
OpenFlowコントローラ開発支援ツールの提案
 
Gamification - Elements for a Gamification Learning Strategy
Gamification - Elements for a Gamification Learning StrategyGamification - Elements for a Gamification Learning Strategy
Gamification - Elements for a Gamification Learning Strategy
 
Inspirational Quotes
Inspirational QuotesInspirational Quotes
Inspirational Quotes
 
20160521謝昇佑-不安分的創業:好食機的社會企業
20160521謝昇佑-不安分的創業:好食機的社會企業20160521謝昇佑-不安分的創業:好食機的社會企業
20160521謝昇佑-不安分的創業:好食機的社會企業
 
Atelier Lean Feedback
Atelier Lean FeedbackAtelier Lean Feedback
Atelier Lean Feedback
 
CVPR2015勉強会 Global Refinement of Random Forest
CVPR2015勉強会 Global Refinement of Random ForestCVPR2015勉強会 Global Refinement of Random Forest
CVPR2015勉強会 Global Refinement of Random Forest
 
The Arrival Discussion Questions - Chapter 1
The Arrival Discussion Questions - Chapter 1The Arrival Discussion Questions - Chapter 1
The Arrival Discussion Questions - Chapter 1
 
Heroku Dyno再起動時の振る舞い
Heroku Dyno再起動時の振る舞いHeroku Dyno再起動時の振る舞い
Heroku Dyno再起動時の振る舞い
 
実装だって楽したい!〜リアルタイム通信はじめの一歩〜
実装だって楽したい!〜リアルタイム通信はじめの一歩〜実装だって楽したい!〜リアルタイム通信はじめの一歩〜
実装だって楽したい!〜リアルタイム通信はじめの一歩〜
 
IETF remote participation via Meetecho @ WebRTC Meetup Stockholm
IETF remote participation via Meetecho @ WebRTC Meetup StockholmIETF remote participation via Meetecho @ WebRTC Meetup Stockholm
IETF remote participation via Meetecho @ WebRTC Meetup Stockholm
 
Caso clínico - Otorrino Mazatlán
Caso clínico - Otorrino MazatlánCaso clínico - Otorrino Mazatlán
Caso clínico - Otorrino Mazatlán
 

Similar to Videostream compression in iOS

Ott Streaming Protocols and DRM
Ott Streaming Protocols and DRMOtt Streaming Protocols and DRM
Ott Streaming Protocols and DRMASIMYILDIZ
 
Project Paper
Project PaperProject Paper
Project PaperVideoguy
 
Use of Automation Codecs Streaming Video Applications Based on Cloud Computing
Use of Automation Codecs Streaming Video Applications Based on Cloud ComputingUse of Automation Codecs Streaming Video Applications Based on Cloud Computing
Use of Automation Codecs Streaming Video Applications Based on Cloud ComputingTELKOMNIKA JOURNAL
 
1 Capture a live video feed of 720p resolution at 30 fps fr.pdf
1 Capture a live video feed of 720p resolution at 30 fps fr.pdf1 Capture a live video feed of 720p resolution at 30 fps fr.pdf
1 Capture a live video feed of 720p resolution at 30 fps fr.pdfacmcollection
 
1_MWS2018_Tutorial1_Pham_Internet Delivered Media.pdf
1_MWS2018_Tutorial1_Pham_Internet Delivered Media.pdf1_MWS2018_Tutorial1_Pham_Internet Delivered Media.pdf
1_MWS2018_Tutorial1_Pham_Internet Delivered Media.pdfAliIssa53
 
what_is_a_codec_2010
what_is_a_codec_2010what_is_a_codec_2010
what_is_a_codec_2010Justin Giles
 
Windows7: Video Improvements
Windows7: Video ImprovementsWindows7: Video Improvements
Windows7: Video Improvementswonderu
 
Video Streaming Compression for Wireless Multimedia Sensor Networks
Video Streaming Compression for Wireless Multimedia Sensor NetworksVideo Streaming Compression for Wireless Multimedia Sensor Networks
Video Streaming Compression for Wireless Multimedia Sensor NetworksIOSR Journals
 
Detailed Tasks 13 marks The web application running on la.pdf
Detailed Tasks 13 marks The web application running on la.pdfDetailed Tasks 13 marks The web application running on la.pdf
Detailed Tasks 13 marks The web application running on la.pdficonsystemsslm
 
4 multimedia elements - video
4   multimedia elements - video4   multimedia elements - video
4 multimedia elements - videoKelly Bauer
 
Apple's live http streaming
Apple's live http streamingApple's live http streaming
Apple's live http streamingYoss Cohen
 
Video Streaming
Video StreamingVideo Streaming
Video StreamingVideoguy
 
Video compression
Video compressionVideo compression
Video compressionDarkNight14
 
EQR Reporting: Rails + Amazon EC2
EQR Reporting:  Rails + Amazon EC2EQR Reporting:  Rails + Amazon EC2
EQR Reporting: Rails + Amazon EC2jeperkins4
 

Similar to Videostream compression in iOS (20)

Ott Streaming Protocols and DRM
Ott Streaming Protocols and DRMOtt Streaming Protocols and DRM
Ott Streaming Protocols and DRM
 
Performance Analysis of Various Video Compression Techniques
Performance Analysis of Various Video Compression TechniquesPerformance Analysis of Various Video Compression Techniques
Performance Analysis of Various Video Compression Techniques
 
Project Paper
Project PaperProject Paper
Project Paper
 
Dos presentation by ahlam shakeel
Dos presentation by ahlam shakeelDos presentation by ahlam shakeel
Dos presentation by ahlam shakeel
 
Use of Automation Codecs Streaming Video Applications Based on Cloud Computing
Use of Automation Codecs Streaming Video Applications Based on Cloud ComputingUse of Automation Codecs Streaming Video Applications Based on Cloud Computing
Use of Automation Codecs Streaming Video Applications Based on Cloud Computing
 
1 Capture a live video feed of 720p resolution at 30 fps fr.pdf
1 Capture a live video feed of 720p resolution at 30 fps fr.pdf1 Capture a live video feed of 720p resolution at 30 fps fr.pdf
1 Capture a live video feed of 720p resolution at 30 fps fr.pdf
 
1_MWS2018_Tutorial1_Pham_Internet Delivered Media.pdf
1_MWS2018_Tutorial1_Pham_Internet Delivered Media.pdf1_MWS2018_Tutorial1_Pham_Internet Delivered Media.pdf
1_MWS2018_Tutorial1_Pham_Internet Delivered Media.pdf
 
WEEK 1
WEEK 1WEEK 1
WEEK 1
 
what_is_a_codec_2010
what_is_a_codec_2010what_is_a_codec_2010
what_is_a_codec_2010
 
FMS 3.5
FMS 3.5FMS 3.5
FMS 3.5
 
Windows7: Video Improvements
Windows7: Video ImprovementsWindows7: Video Improvements
Windows7: Video Improvements
 
Video Streaming Compression for Wireless Multimedia Sensor Networks
Video Streaming Compression for Wireless Multimedia Sensor NetworksVideo Streaming Compression for Wireless Multimedia Sensor Networks
Video Streaming Compression for Wireless Multimedia Sensor Networks
 
Computer Networking
Computer NetworkingComputer Networking
Computer Networking
 
Detailed Tasks 13 marks The web application running on la.pdf
Detailed Tasks 13 marks The web application running on la.pdfDetailed Tasks 13 marks The web application running on la.pdf
Detailed Tasks 13 marks The web application running on la.pdf
 
4 multimedia elements - video
4   multimedia elements - video4   multimedia elements - video
4 multimedia elements - video
 
Apple's live http streaming
Apple's live http streamingApple's live http streaming
Apple's live http streaming
 
Video Streaming
Video StreamingVideo Streaming
Video Streaming
 
Video compression
Video compressionVideo compression
Video compression
 
IIS Smooth Streaming
IIS Smooth StreamingIIS Smooth Streaming
IIS Smooth Streaming
 
EQR Reporting: Rails + Amazon EC2
EQR Reporting:  Rails + Amazon EC2EQR Reporting:  Rails + Amazon EC2
EQR Reporting: Rails + Amazon EC2
 

More from *instinctools

ERP Customization for TV Services & Media Company
ERP Customization for TV Services & Media CompanyERP Customization for TV Services & Media Company
ERP Customization for TV Services & Media Company*instinctools
 
Integration Of Data Visualization Tools In Odoo: Pros And Cons.pdf
Integration Of Data Visualization Tools In Odoo: Pros And Cons.pdfIntegration Of Data Visualization Tools In Odoo: Pros And Cons.pdf
Integration Of Data Visualization Tools In Odoo: Pros And Cons.pdf*instinctools
 
Examples of custom intuitive dashboards in Odoo.pdf
Examples of custom intuitive dashboards in Odoo.pdfExamples of custom intuitive dashboards in Odoo.pdf
Examples of custom intuitive dashboards in Odoo.pdf*instinctools
 
CRM FOR MARKETING COMPANY
CRM FOR MARKETING COMPANYCRM FOR MARKETING COMPANY
CRM FOR MARKETING COMPANY*instinctools
 
BI Technologies and ECM-System For A Multi-Industry Corporation
BI Technologies and ECM-System For A Multi-Industry CorporationBI Technologies and ECM-System For A Multi-Industry Corporation
BI Technologies and ECM-System For A Multi-Industry Corporation*instinctools
 
How to protect sensitive data
How to protect sensitive dataHow to protect sensitive data
How to protect sensitive data*instinctools
 
Video streaming trends & technologies
Video streaming trends & technologiesVideo streaming trends & technologies
Video streaming trends & technologies*instinctools
 
Happy Programmer's day | 2021 | *instinctools in numbers
Happy Programmer's day | 2021 | *instinctools in numbersHappy Programmer's day | 2021 | *instinctools in numbers
Happy Programmer's day | 2021 | *instinctools in numbers*instinctools
 
Data Integration: Huntflow and PowerBI | Case Study | Software Development Co...
Data Integration: Huntflow and PowerBI | Case Study | Software Development Co...Data Integration: Huntflow and PowerBI | Case Study | Software Development Co...
Data Integration: Huntflow and PowerBI | Case Study | Software Development Co...*instinctools
 
Top software development trends of 2021
Top software development trends of 2021Top software development trends of 2021
Top software development trends of 2021*instinctools
 
6 hidden costs of cloud migration
6 hidden costs of cloud migration6 hidden costs of cloud migration
6 hidden costs of cloud migration*instinctools
 
Learning management system
Learning management systemLearning management system
Learning management system*instinctools
 
P2P trading platform - Blockchain solution for electricity provider
P2P trading platform - Blockchain solution for electricity providerP2P trading platform - Blockchain solution for electricity provider
P2P trading platform - Blockchain solution for electricity provider*instinctools
 
Business Analysis in IT
Business Analysis in ITBusiness Analysis in IT
Business Analysis in IT*instinctools
 
Electron. Build cross platform desktop apps with web technologies!
Electron. Build cross platform desktop apps with web technologies!Electron. Build cross platform desktop apps with web technologies!
Electron. Build cross platform desktop apps with web technologies!*instinctools
 
Apple Watch (Part 2)
Apple Watch (Part 2)Apple Watch (Part 2)
Apple Watch (Part 2)*instinctools
 
Apple Watch (Part 1)
Apple Watch (Part 1)Apple Watch (Part 1)
Apple Watch (Part 1)*instinctools
 

More from *instinctools (20)

ERP Customization for TV Services & Media Company
ERP Customization for TV Services & Media CompanyERP Customization for TV Services & Media Company
ERP Customization for TV Services & Media Company
 
Integration Of Data Visualization Tools In Odoo: Pros And Cons.pdf
Integration Of Data Visualization Tools In Odoo: Pros And Cons.pdfIntegration Of Data Visualization Tools In Odoo: Pros And Cons.pdf
Integration Of Data Visualization Tools In Odoo: Pros And Cons.pdf
 
Examples of custom intuitive dashboards in Odoo.pdf
Examples of custom intuitive dashboards in Odoo.pdfExamples of custom intuitive dashboards in Odoo.pdf
Examples of custom intuitive dashboards in Odoo.pdf
 
CRM FOR MARKETING COMPANY
CRM FOR MARKETING COMPANYCRM FOR MARKETING COMPANY
CRM FOR MARKETING COMPANY
 
BI Technologies and ECM-System For A Multi-Industry Corporation
BI Technologies and ECM-System For A Multi-Industry CorporationBI Technologies and ECM-System For A Multi-Industry Corporation
BI Technologies and ECM-System For A Multi-Industry Corporation
 
How to protect sensitive data
How to protect sensitive dataHow to protect sensitive data
How to protect sensitive data
 
Video streaming trends & technologies
Video streaming trends & technologiesVideo streaming trends & technologies
Video streaming trends & technologies
 
Happy Programmer's day | 2021 | *instinctools in numbers
Happy Programmer's day | 2021 | *instinctools in numbersHappy Programmer's day | 2021 | *instinctools in numbers
Happy Programmer's day | 2021 | *instinctools in numbers
 
Data Integration: Huntflow and PowerBI | Case Study | Software Development Co...
Data Integration: Huntflow and PowerBI | Case Study | Software Development Co...Data Integration: Huntflow and PowerBI | Case Study | Software Development Co...
Data Integration: Huntflow and PowerBI | Case Study | Software Development Co...
 
Top software development trends of 2021
Top software development trends of 2021Top software development trends of 2021
Top software development trends of 2021
 
6 hidden costs of cloud migration
6 hidden costs of cloud migration6 hidden costs of cloud migration
6 hidden costs of cloud migration
 
Learning management system
Learning management systemLearning management system
Learning management system
 
P2P trading platform - Blockchain solution for electricity provider
P2P trading platform - Blockchain solution for electricity providerP2P trading platform - Blockchain solution for electricity provider
P2P trading platform - Blockchain solution for electricity provider
 
Java Memory Model
Java Memory ModelJava Memory Model
Java Memory Model
 
Business Analysis in IT
Business Analysis in ITBusiness Analysis in IT
Business Analysis in IT
 
Java NIO.2
Java NIO.2Java NIO.2
Java NIO.2
 
Electron. Build cross platform desktop apps with web technologies!
Electron. Build cross platform desktop apps with web technologies!Electron. Build cross platform desktop apps with web technologies!
Electron. Build cross platform desktop apps with web technologies!
 
Apple Watch (Part 2)
Apple Watch (Part 2)Apple Watch (Part 2)
Apple Watch (Part 2)
 
Apple Watch (Part 1)
Apple Watch (Part 1)Apple Watch (Part 1)
Apple Watch (Part 1)
 
Viper architecture
Viper architectureViper architecture
Viper architecture
 

Videostream compression in iOS

  • 2. 1. A little bit about codecs and containers 2. A little bit about streaming 3. How to arrange it for iOS 4. Comparison of different approaches for compressing videostream Owerview
  • 3. About codecs and containers The container is a file or streaming format, which takes care of packaging, transport, and presentation of information which is inside of it.
  • 4. About codecs and containers Examples of containers: ● AVI ● MKV ● QuickTime ● MP4 ● MPEG-TS
  • 5. About codecs and containers Examples of codecs: Video: ● MPEG-4 ● DivX ● h.264/x.264 Audio: ● MP3 ● AAC ● DTS
  • 6. What about the mechanism of media streaming? Stream media is a multimedia which is continuously obtained by the user from the streaming provider. ● live-streaming ● streaming on demand
  • 7. What about the mechanism of media streaming? Media data -> large amounts -> expensive storage and transmission Recommended stream bandwidth: ● not HD video ~2 Mbit/s ● HD video ~5 Mbit/s ● UHD ~9Mbit/s
  • 8. What about the mechanism of media streaming? Example of calculation of the bandwidth: 1hour of video 320 × 240 ~ 300kbit/s ~128MB for 1 thousand of users - 300Mbit/s == 135GB/h
  • 9. What about the mechanism of media streaming? The protocols used for streaming: For audio compression: MP3, AAC, Vorbis ... For video compression: h.264, VP8 … Containers: MP4, FLV...
  • 10. What about the mechanism of media streaming? Transport protocols: Used for media delivery from server to client. RTMP (Real Time Messaging Protocol) RTP (Real-time Transport Protocol) + RTCP RTSP (Real Time Streaming Protocol)
  • 11. What about the mechanism of media streaming? Transport protocols: Newer: Apple’s HLS, Adobe’s HDS, MPEG-DASH The process often consists of two stages: 1. The delivery of stream to the server using the transport protocol (streaming transport protocol) 2. Translation from server to final user (HTTP based protocols)
  • 12. What about the mechanism of media streaming? HLS (HTTP Live Streaming) It is based on the principle of splitting the stream into fragments. It uses advanced m3u playlist, which is downloaded at the beginning of the session and contains metadata about the nested streams.
  • 13. What about the mechanism of media streaming? HLS (HTTP Live Streaming) It involves the use of an intermediate server that: 1. transforms the media-stream into the correct format: h.264, MP3/HE-AAC/AC- 3 and packs into the MPEG-TS container 2. splits the MPEG-TS file into fragments of equal length + creates an index file with a link to fragments (.m3u8)
  • 14. How to compress video in iOS? Life before iOS 8: Hardware: By using AVAssetWriter -> we write to a file (for online streaming write small files, then read them and pass) Software: Using any third-party library (eg ffmpeg)
  • 15. How to compress video in iOS? Life after iOS 8: VideoToolbox appears
  • 16. How to compress video in iOS? AVFoundation: ● Decoding directly when displaying. ● Encoding into file VideoToolbox: ● Decoding frames into CVPixelBuffer ● Encoding frames into CMSampleBuffer
  • 17. How to compress video in iOS? Briefly about h.264: ● widely used ● gives much a better picture quality at lower bit rates (MPEG-2) ● ideal for videostreaming ● ...
  • 18. How to compress video in iOS? Briefly about h.264: It uses two approaches to reduce the size of the video: ● It compresses data within one frame ● It compresses the data using information from the group of pictures (pictures are grouped into groups GOP)
  • 19. How to compress video in iOS? Briefly about h.264: GOP (Group of Pictures )
  • 20. How to compress video in iOS? Briefly about h.264: GOP (Group of Pictures ) I-frames: (key-frame) - self-sufficient, has the biggest size, the fastest decoding. P-frames: (predicted frame) - uses information from the nearest P- or I-frame B-frame: (bidirectional frame) - used information from the frames before and after current
  • 21. How to compress video in iOS? VideoToolbox: the main points It provides direct access to the decoder / encoder. It depends on CoreMedia, CoreVideo and CoreFoundation It requires additional work with buffers obtained from the encoder.
  • 22. The process of preparing videostream in iOS 1. Capture video from the device -> CMSampleBuffer with uncompressed frame data 2. Compressing frame by encoder from VideoToolbox -> CMSampleBuffer with compressed frame data 3. Converting the stream of CMSampleBuffer into NALUs streaming trough the network
  • 23. The process of preparing videostream in iOS
  • 24. The process of preparing videostream in iOS
  • 25. The process of preparing videostream in iOS Compression process: 1. Create and configure VTCompressionSession by using VTCompressionSessionCreate, as one of the parameters we pass a pointer to encoding callback-function 2. Call VTCompressionSessionEncodeFrame, as one of the parameters we pass CVPixelBufferRef, repeat for each frame. 3. Process CMSampleBuffer that we get from encoder callback.
  • 26. The process of preparing videostream in iOS The creation of СompressionSession
  • 27. The process of preparing videostream in iOS Sending the buffer to the compression:
  • 28. The process of preparing videostream in iOS The signature of the callback-function:
  • 29. The process of preparing videostream in iOS Then it is necessary to convert stream of CMSampleBuffers to the stream of packets suitable for further transmission over the network.
  • 30. The process of preparing videostream in iOS
  • 31. The process of preparing videostream in iOS
  • 32. The process of preparing videostream in iOS Getting the parameters from sampleBuffer's I-frame
  • 33. The process of preparing videostream in iOS Annex B vs AVCC
  • 34. The process of preparing videostream in iOS Getting raw compressed data:
  • 35. The process of preparing videostream in iOS Profit
  • 36. The process of preparing videostream in iOS Профит
  • 37. Thanks for your attention!
  • 38. More info: 1. WWDC, 513 - 2014 (https://developer.apple.com/videos/play/wwdc2014/513/) 2. “Learning AVFoundation: …” by Bob McCune