-
Different Types of Streaming:-
- WebRTC live
- RTMP live
- RTMP VOD
- HTTP live including
- HLS live
- DASH live
- HTTP VOD including
- HLS VOD
- DASH VOD
-
Each client can only play a certain type of video:-
- All browsers today that is capable of media source extensions can play MPEG-DASH
- MP4 is simple because it is a file that can be delivered through HTTP
- Apple devices like iPhone and iPad can play HLS
- Silverlight and Xbox require Smooth Streaming
- Old browsers that have the Adobe Flash plugin can play RTMP
- All browsers today that is capable of media source extensions can play MPEG-DASH
-
Stream video in multiple formats, including :-
- Real-Time Messaging Protocol (RTMP)
- HTTP Live Streaming (HLS)
- Dynamic Adaptive Streaming over HTTP (DASH)
-
You can configure NGINX (eNGINe-X) to stream video using all of the protocols
-
Codecs are the software that implements the compression/decompression algorithms whereas file formats are containers that hold the compressed video.
-
- The following diagram shows the traditional encoding and static packaging workflow.
- The following diagram shows the
dynamic packaging
workflow - https://learn.microsoft.com/en-us/azure/media-services/previous/media-services-deliver-streaming-content
- Dynamic:- Gives links to HLS, MPEG-DASH and MSS and HTML player will automatically select the segement which will be stripped from the MP4 on the fly
- Progressive :- Gives links to all multi-bitrate MP4 and HTML video element will download single file progressively
- The following diagram shows the traditional encoding and static packaging workflow.
-
https://resources.antmedia.io/docs/adaptive-bitrate-streaming
- Lowering the resolutions of videos for recorded streams is not a big deal.
- However, doing the same job for live streams on the fly is not as easy as recorded streams
-
It is a technique used in streaming multimedia over computer networks.
-
While in the past most video or audio streaming technologies utilized streaming protocols such as RTP with RTSP.
-
Today's adaptive streaming technologies are almost exclusively based on HTTP and designed to work efficiently over large distributed HTTP networks such as the Internet.
-
It works
- by detecting a user's bandwidth and CPU capacity in real time, adjusting the quality of the media stream accordingly.
- It requires the use of an encoder which encodes a single source media (video or audio) at multiple bit rates.
- The player client switches between streaming the different encodings depending on available resources.
- "The result: very little buffering, fast start time and a good experience for both high-end and low-end connections
-
Implementations
- Dynamic Adaptive Streaming over HTTP (DASH)
- MPEG-4 AVC OR Advanced Video Coding (AVC) OR H.264 OR MPEG-4 Part 10, is a video compression standard based on block-oriented, motion-compensated coding
- Apple HTTP Live Streaming (HLS)
- Adobe HTTP Dynamic Streaming (HDS)
- Microsoft Smooth Streaming (MSS)
- Common Media Application Format (CMAF)
- QuavStreams Adaptive Streaming over HTTP
- Uplynk
- Moving Picture Experts Group - Dynamic Adaptive Streaming over HTTP (MPEG-DASH)
- To output multi-bitrate Smooth Streaming (fragmented MP4) as output. The supported URL schemes are http:// or https://.
- Ateme TITAN Live
- Antix Digital StreamZ Live (previously Imagine Communication SelenioFlex Live)
- Cisco Digital Media Encoder 2200
- Elemental Live (version 2.14.15 and higher due to the TLS 1.2 requirement)
- Envivio 4Caster C4 Gen III
- Ffmpeg
- Media Excel Hero Live and Hero 4K (UHD/HEVC)
- Build Image and Run Container:-
docker build --build-arg UID=`id -u` -t nginx-rtmp-stretch-img -f Dockerfile . docker run -p 3000:3000 -p 8085:80 -p 8086:1935 --rm -it nginx-rtmp-stretch-img:latest /bin/bash
- Build and Start the container:-
sudo /usr/local/nginx/sbin/nginx -t sudo /usr/local/nginx/sbin/nginx
- There are following options to Streaming Video to RTMP Server
rtmp://localhost:8086/live/bbb
:-- ffmpeg
- Using file e.g bbb.mp4
./stream.sh
- Using Hardware e.g WebCam
- Using another stream
- Using file e.g bbb.mp4
- OBS Studio
- Using Hardware e.g WebCam
- TODO:
- Using Hardware e.g WebCam
- Adobe Flash Media Live Encoder 3.2
- Antix Digital StreamZ Live (previously Imagine Communication SelenioFlex Live)
- Blackmagic ATEM Mini and ATEM Mini PRO
- Cambria Live 4.3
- Elemental Live (version 2.14.15 and higher)
- GoPro Hero 7 and Hero 8
- Haivision KB
- Haivision Makito X HEVC
- Osprey Talon hardware encoders, Talon 4K-SC, Talon UHD-SC
- Restream.io
- Streamlabs
- Switcher Studio (iOS)
- Telestream Wirecast (version 13.0.2 or higher due to the TLS 1.2 requirement)
- Telestream Wirecast S (only RTMP is supported. No RTMPS support due to lack of TLS 1.2+)
- Teradek Slice 756
- VMIX
- xStream
- ffmpeg
- The following streams will be eventually available:-
- RTMP – rtmp://localhost:8086/live/bbb
- HLS – http://localhost:8085/hls/bbb/index.m3u8
- DASH – http://localhost:8085/dash/bbb/index.mpd
- Additional info:-
root@b91e571417bb:/# tree /tmp
/tmp
|-- dash
| |-- bbb-536490.m4a
| |-- bbb-536490.m4v
| |-- bbb-553156.m4a
| |-- bbb-553156.m4v
| |-- bbb-566172.m4a
| |-- bbb-566172.m4v
| |-- bbb-582323.m4a
| |-- bbb-582323.m4v
| |-- bbb-593363.m4a
| |-- bbb-593363.m4v
| |-- bbb-611490.m4a
| |-- bbb-611490.m4v
| |-- bbb-627056.m4a
| |-- bbb-627056.m4v
| |-- bbb-init.m4a
| |-- bbb-init.m4v
| |-- bbb-raw.m4a
| |-- bbb-raw.m4v
| `-- bbb.mpd
`-- hls
|-- bbb-33.ts
|-- bbb-34.ts
|-- bbb-35.ts
|-- bbb-36.ts
|-- bbb-37.ts
|-- bbb-38.ts
`-- bbb.m3u8
2 directories, 26 files
<?xml version="1.0"?>
<MPD
type="dynamic"
xmlns="urn:mpeg:dash:schema:mpd:2011"
availabilityStartTime="2022-12-28T10:42:58Z"
publishTime="2022-12-28T10:55:26Z"
minimumUpdatePeriod="PT5S"
minBufferTime="PT5S"
timeShiftBufferDepth="PT21S"
profiles="urn:hbbtv:dash:profile:isoff-live:2012,urn:mpeg:dash:profile:isoff-live:2011"
xmlns:xsi="http://www.w3.org/2011/XMLSchema-instance"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd">
<Period start="PT0S" id="dash">
<AdaptationSet
id="1"
segmentAlignment="true"
maxWidth="1280"
maxHeight="720"
maxFrameRate="30">
<Representation
id="stream_H264"
mimeType="video/mp4"
codecs="avc1.64001f"
width="1280"
height="720"
frameRate="30"
startWithSAP="1"
bandwidth="2500000">
<SegmentTemplate
timescale="1000"
media="$Time$.m4v"
initialization="init.m4v">
<SegmentTimeline>
<S t="713966" d="8333"/>
<S t="722299" d="8333"/>
<S t="730632" d="8334"/>
<S t="738966" d="8333"/>
<S t="747299" d="8333"/>
<S t="755632" d="8334"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
<AdaptationSet
id="2"
segmentAlignment="true">
<AudioChannelConfiguration
schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
value="1"/>
<Representation
id="stream_AAC"
mimeType="audio/mp4"
codecs="mp4a.40.2"
audioSamplingRate="48000"
startWithSAP="1"
bandwidth="160000">
<SegmentTemplate
timescale="1000"
media="$Time$.m4a"
initialization="init.m4a">
<SegmentTimeline>
<S t="713966" d="8333"/>
<S t="722299" d="8333"/>
<S t="730632" d="8334"/>
<S t="738966" d="8333"/>
<S t="747299" d="8333"/>
<S t="755632" d="8334"/>
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
</Period>
</MPD>
- It can be tested via
rtmp://localhost:8086/live/bbb
:-- VLC
- It can be tested via
- VLC:-
http://localhost:8085/hls/bbb/index.m3u8
- Open Chrome:- hls.html
- VLC:-
- It can be tested via
- VLC :-
http://localhost:8085/dash/bbb/index.mpd
- Open Chrome:- dash.html
- VLC :-
- Youtube Website offers two ways to live stream:-
- Youtube App for ioS and Android offers only native WebRTC way live stream
- https://www.youtube.com/watch?v=htN-gIPOkP0
- https://www.youtube.com/watch?v=IO4teCbHvZw
- RTMPS => Encoders (multi bitrate and multi resolution) => HTTP (MPEG-DASH)
- https://www.nginx.com/blog/video-streaming-for-remote-learning-with-nginx => Tutorial inspired for this repo
- https://gist.github.com/outcast/13289bd872b06700089d9fe1a94441ce => nginx.conf used in above tutorial
- https://www.nginx-cn.net/blog/streaming-hls-dash-nginx/#Agenda => Very good introduction to all concepts
- https://docs.peer5.com/guides/setting-up-hls-live-streaming-server-using-nginx/
- https://mpolinowski.github.io/docs/DevOps/NGINX/2019-11-07--nginx-rtmp-streaming-container/2019-11-07/ => Good tutorial of HLS
- https://unix.stackexchange.com/questions/628717/why-cant-open-the-stream-with-hls-url => ffplay to stream rtsp
- https://www.digitalocean.com/community/tutorials/how-to-set-up-a-video-streaming-server-using-nginx-rtmp-on-ubuntu-20-04 => Very good introduction of RTMP and then for
- https://dzone.com/articles/hls-streaming-by-nginx-and-apche-tomcat => RTSP -> RTMP -> HLS
- Working Setups:-
- https://github.com/ustoopia/Live-stream-server-portable-Windows-Nginx-RTMP-HLS-Dash => Using Windows with RTMP, DASH and DLS
- It works as following:-
git clone --single-branch --branch v2.0 [email protected]:ustoopia/Live-stream-server-portable-Windows-Nginx-RTMP-HLS-Dash.git C:\livestream2 Change conf/nginx.conf Start NGINX.exe OBS:- http://localhost:8087/live/stream VLC:- http://localhost:8087/live/stream
- It works as following:-
- https://hub.docker.com/r/tiangolo/nginx-rtmp => WorkingLinuxContainer but only RTMP
docker pull tiangolo/nginx-rtmp docker run --rm -p 8088:1935 --name nginx-rtmp tiangolo/nginx-rtmp root@ef731ef3526d:/# netstat -anlp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:1935 0.0.0.0:* LISTEN 1/nginx: master pro tcp6 0 0 :::1935 :::* LISTEN 1/nginx: master pro OBS:- http://localhost:8088/live/bbb VLC:- http://localhost:8088/live/bbb
- https://github.com/ustoopia/Live-stream-server-portable-Windows-Nginx-RTMP-HLS-Dash => Using Windows with RTMP, DASH and DLS
- https://flashphoner.com/how-to-broadcast-webrtc-rtsp-and-rtmp-streams-to-media-source-extensions-via-the-websocket-protocol/
- https://github.com/Miczeq22/simple-chat-app