KURT LIANG
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Low-latency Streaming ###### tags: `Streaming` ## Low-latency Stream 影片和直播在我們的生活中無所不在,有些是為了好玩、記錄,或是見證歷史。但是在商業的世界裡,影片和直播就是專門吸引顧客的工具,要能更清晰、更及時又不會卡頓是最好的。 在直播 ( LIVE) 中,低延遲 ( Low latency ) 嚴重的影響觀眾的即時感,而在某些類型的直播中,低延遲又更為重要!像是運動、股市、新聞... 等等。所以在這樣的需求前提下,我們需要來了解什麼樣的技術可以達成低延遲實時串流和我們該怎麼使用。 - - - ## What is latency in video streaming? 當現實中,某足球隊伍踢進了一球,而過了幾秒你才在直播上看見球進了,這就是延遲 ![](https://i.imgur.com/XuWdUcP.png) - - - ## What is low latency? 延遲的單位是時間。其實並沒有一個標準來評定什麼是好延遲或壞延遲,大部分的網路直播延遲大概介於 30 ~ 60 秒間,而延遲時間低於 5 秒的話,在直播內我們就稱之為低延遲。 - - - ## When is low latency especially required? 低延遲伴隨著一些損失。如果想要有越低的延遲,可能直播的畫面分辨率會降低,畫質也會變差。反過來說,要有好的畫面就沒辦法用較低的延遲,但是在某些直播上,犧牲一些畫質換來低延遲是值得的,因為越接近實時越有魅力,例如以下的情況: - 雙向通信 : 如果是和觀眾有互動或交流的,例如 Q&A 時從觀眾中提問,那就需要低延遲,直播體驗才會更好,否則一個問題需要等 10 秒才能拿到,會把大家的耐心都磨光的 - 線上遊戲 : 線上遊戲必須實時反應玩家的動作。想像一下,假如你現在想要站起來去喝水,但是過了好幾秒才站起來,又再過好幾秒才去喝水,是不是快把人逼瘋了呢 ? 所以延遲是會破壞遊戲體驗的 - 線上博弈和運動 : 線上博弈因為涉及到錢,所以實時也是非常重要的,如果延遲好幾秒不免讓人懷疑是否有作弊行為或是讓某人具有優勢。而體育更不用說了,當隔壁為了進球歡呼,而你的畫面還在發球階段,真的會讓人理智斷線呢 - 實時拍賣 : 拍賣也需要非常低的延遲,因為每一拍都至關重要,如果一個商品你本來要拍,卻因為延遲沒拍到,那真是虧大了 - 視訊聊天 : 視訊聊天也是需要低延遲,訊號必須時時刻刻都是連接狀態,如果延遲高有可能也會造成訊號中斷 如果越需要和觀眾互動就越需要低延遲,如果沒有互動的必要就可以專注於畫面的呈現 - - - ## Important factors affecting latency 為了實現實時串流的直播,我們不得不克服一些無法控制的限制。延遲被幾個因素影響,我們可以解決幾個,但有幾個所耗成本太高,並不實際 以下是一些可能影響延遲較重要的因素 : - Bandwidth : 越高的頻寬越能增加數據的傳輸速度 - Connection type : 連接類型也影響傳輸速率和速度。例如光纖一定比 wifi 還要更快 - Encoding : 有很大的程度是因為編碼器的影響,所以盡量優化,減短信號發送到設備的時間 - Video format : 文件越大,傳輸速度越久 - Distance : 距離基地台或 wifi 越遠,延遲就越久 我們可以更改編碼器設定、用更好的頻寬或選擇更好的連線方式來減少延遲,但真正的問題還是在串流媒體協議及其在提供良好串流體驗中扮演的角色 - - - ## Streaming protocols to deliver low-latency video streams 串流協議是一組規則,用於控制數據如何從來源傳送到目的。在直播時使用這些協議來確保編碼器和串流傳輸服務在交換信息時在同個基礎上 某些情況下我們可以選擇使用哪種串流協議。但是通常取決於編碼器支持的協議和串流傳輸平台,讓我們來看看當今有哪些廣泛使用的協議 - - - ![](https://i.imgur.com/dV28qpH.png) ## Web RTC 由 Google 開發,用於瀏覽器間的延遲數據交換。2011 年發布的開源協議,通常用於對等式的視訊聊天中使用,如 Google Hangout。 該協議是實時數據傳輸和視訊會議的理想選擇。但是不得不在質量上做出妥協,因為速度才是重點。而且需要負責的服務器設置才能部屬 WebRTC,因此和大多數 CDN 不兼容。 一些 WebRTC 串流解決方案使用雲端將影片串流轉換為 WebRTC - - - ![](https://i.imgur.com/l3L53Yk.png) ## RTMP Real-Time Messaging Protocol ( RTMP ) 是 Macromedia 用於低延遲的解決方案。協議分成許多塊,主要目的是一致地傳送影像和聲音信號,可以滿足不同類型的連接。 最初 RTMP 很難被擴展,但是雲端的出現解決了這個問題,現在我們可以使用 RTMP 來實現低延遲並擁有很棒的速度 因為 Flash 即將消失,許多 CDN 也已經不支持 RTMP 了 - - - ![](https://i.imgur.com/TmrYagE.png) ## HLS & DASH HLS 和 DASH 是 WebRTC 的替代方案,它可以實現低於 5 秒的延遲。HLS 和 DASH 在處理原始資料之後構造串流傳輸的影片片段。視頻部分在發送給最終用戶之前,已合併到運輸容器(CMAF)中。視頻片段越小,等待時間越短。 CDN 將查看請求轉發到編碼器,編碼器發送到設備。從理論上講,使用 CMAF 或 “通用媒體應用程序格式” 可以將延遲時間進一步減少到一秒。 - - - ![](https://i.imgur.com/P1xwzL6.png) ## FTL Faster Than Light 是 Mixer 自己的低延遲協議。它是專門為支持交互式直播而開發的,用戶可以在其中與內容進行實時交互。 使用 FTL 必須使用可靠的網路連接和 Mixer 兼容性,否則還是使用其他協議比較好 - - - ## Multistreaming with low latency 如果需要同時在各個平台上直播,那對低延遲的要求是非常嚴格的,這時候需要一些可靠的東西來減少延遲。 使用諸如 Restream 之類的多串流時,技術上您與觀眾並不進行通信,僅與多串流服務平台通信,並允許多串流平台與直播平台通信 這就是為什麼選擇平台和串流協議很重要的原因,通過 RTMP 協議與服務器進行通信,並使用最佳可用的串流協議和平台通信,這些最好還是少介入。 - - - ## 結論 對於任何想要進行高畫質實時直播的人來說,延遲是至關重要的技術,如果進行串流傳輸,則需要實現低延遲,才能使觀眾獲得令人愉悅地觀看體驗,而不受任何干擾 減少延遲的最好方法就是選擇使用適合的串流協議,例如 WebRTC 或 FTL。如果是多平台串流則是盡可能用最快的協議將數據串流至多數據串流服務,其他工作只要交給多數據串流平台就好了。 ###### tags: `Streaming`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully