Skip to content

wahabshah/nginx-live-vod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Main

Adaptive bitrate streaming

  • 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
  • https://www.youtube.com/watch?v=z1m9NadpGAg

  • 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.

    • image
  • 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

    1. 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
    1. Apple HTTP Live Streaming (HLS)
    2. Adobe HTTP Dynamic Streaming (HDS)
    3. Microsoft Smooth Streaming (MSS)
    4. Common Media Application Format (CMAF)
    5. QuavStreams Adaptive Streaming over HTTP
    6. Uplynk
    7. Moving Picture Experts Group - Dynamic Adaptive Streaming over HTTP (MPEG-DASH)

fragmented MP4 (Smooth Streaming ingest)

  • 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)

Step1: Build RTMP Server

  • 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

Step2: Start RTMP Server

  • Build and Start the container:-
    sudo /usr/local/nginx/sbin/nginx -t
    sudo /usr/local/nginx/sbin/nginx

Step3: Sending Video to RTMP Server

  • 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
    • OBS Studio
      • Using Hardware e.g WebCam
        • TODO:
    • 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
  • The following streams will be eventually available:-
  • 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>

Step4a: View RTMP

  • It can be tested via rtmp://localhost:8086/live/bbb :-
    • VLC

Step4b: Test HLS

  • It can be tested via
    • VLC:- http://localhost:8085/hls/bbb/index.m3u8
    • Open Chrome:- hls.html

Step4c: Test DASH

  • It can be tested via
    • VLC :- http://localhost:8085/dash/bbb/index.mpd
    • Open Chrome:- dash.html

WebRTC as alternative to RTMP

  • Youtube Website offers two ways to live stream:-
    • RTMP => Using an encoder software :-
      • image
      • image
    • WebRTC => Using no encode software and webcam directly in browser :-
      • image
      • image
  • Youtube App for ioS and Android offers only native WebRTC way live stream
    • image
  • image
  • https://www.youtube.com/watch?v=htN-gIPOkP0

Scaling Facebook Live Videos to a Billion Users

TikTok

  • Video Engineer
    • image

Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published