如何像百度直播一樣優化用戶體驗(起播篇)

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"導讀:","attrs":{}},{"type":"text","text":"隨着互聯網的發展,越來越多人喜歡直播,百度直播也在快速發展中,爲了提升用戶的使用體驗,本文針對百度直播的複雜流程進行了整體梳理,並詳細說明開展的一系列起播優化工作。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"全文4216字,預計閱讀時間 9分鐘。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"一、背景","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"百度做直播有兩個目標:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1、把現實世界照搬到線上,在線上和在線下有一樣的體驗,直播種類有媒體、諮詢、電商、秀場等;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2、是對美好想象的一個完美塑造,隨着5G、VR、AI到來,帶給我們想象的空間,把線下沒有的東西超越這個時空,放到線上,超越線下的想象空間。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"做直播首先要做的就是QOE(Quality of Experience),我們作爲技術同學在保證業務目標的同時,也要提升用戶的體驗。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"直播的體驗有很多:首屏時間、延遲、畫面質量、音畫同步、清晰度、雜音、回聲等。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/db/dbf9e3ff94c4cdeef62723692a632204.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"從QOE角度出發,作爲衡量的標準QOS(Quality of Service)也有很多:推流成功率、推流卡頓流、轉推慢速比、端到端延遲、CDN流暢率、啓播耗時、拉流卡頓率、視頻碼率、轉推慢速比、內存消耗、CPU&GPU消耗等等。這些技術指標統一構成一個整體,作爲衡量直播服務質量的標準。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"但是從直播用戶的角度出發,當用戶點開直播後,用戶希望能夠馬上看到畫面,也就是直播啓播速度要快;當在沉浸式直播間上下滑動時,用戶也會希望當前屏幕要看到的直播迅速啓播。啓播耗時作爲用戶的首個直播感知,被放到了首要優化的目標。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ce/ce6975b23f992c273d8327a93ab8af9b.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"二、現狀","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"百度直播分中泛服務直播&泛娛樂直播,其中泛服務直播提供了媒體直播、諮詢直播、電商直播等服務,泛娛樂直播提供了秀場、音播、語音房等娛樂直播。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/84/84caf1070b8f139c3b3e71feef3000f6.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其中泛服務直播更爲複雜一些,關於啓播流程有以下幾個特點:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"1、流程繁瑣","attrs":{}},{"type":"text","text":":分爲外部跳轉直播間&沉浸式直播間內跳轉兩套流程,其中流程流轉環節也較多;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"2、直播狀態較多","attrs":{}},{"type":"text","text":":包含了直播中,回放、回放生成中等狀態;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"3、涉及面廣","attrs":{}},{"type":"text","text":":涉及百度App多個團隊:直播、播放器、內核、網絡、CDN等;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"4、行駛汽車換輪子","attrs":{}},{"type":"text","text":":百度極度重視直播,業務高速迭代,需要給行駛的汽車換輪子。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/cc/cc1d959983c1395a5e0b5478dcc64872.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"總結完了泛服務啓播的特點,那麼就要定量的去分析整個啓播的流程,用數據來衡量整個啓播的環節。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"三、數據分析","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對整個啓播流程進行數據分析,大致將啓播流程分爲三個大階段:","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"直播業務耗時、播放器耗時、內核耗時。","attrs":{}},{"type":"text","text":"下圖是大致的劃分:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/09/09f8997e0468f1809dd82ec7e1a0274c.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在實際數據統計中,會對各個環節進行更精細的統計,簡單說一下直播業務的數據統計和內核的數據統計:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/f7/f71de8d90f48afb2c1ba568d20d13f4c.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/56/56721dd76f2ca5075adb04d2c6d9cc77.png","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"直播業務的每個環節的進行數據量化,精確到每個步驟耗時,這樣在數據的基礎上進行分析。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"以內核爲例:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/00/00a38c7c9210ab8504769f6dbe31b7e7.png","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"然後就可以得到一份詳盡關於內核的數據的圖表。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"從用戶點擊跳轉到直播間或者沉浸式直播間內滑動切換直播間,到最終的直播播放成功,預計會有60多個的點位進行一些列的追蹤分析。詳細的數據表格呈現啓播過程中每一步驟的耗時,然後針對於耗時多的地方進行優化。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"首先在報表裏面佔比最大的是業務場景的耗時,約佔到60%以上,那麼首先解決的就是這塊耗時;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"第二塊耗時佔比較大的階段是拉流的耗時;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當比較大的耗時解決後,就需要針對於小的耗時進行鍼對性的優化。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"四、業務場景的優化","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"百度App的媒體直播和全民的秀場直播融合之後,會在直播間內進行混合分發。從直播跳轉角度來看,直播間的跳轉分爲兩種:一種是外部通過scheme跳轉到直播間,一種是沉浸式直播間內的滑動跳轉;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"下面是外部通過scheme跳轉到直播間的簡單流程:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/9a/9afcad70b12ec5e2a7b025529dd5ab53.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"通過scheme跳轉直播間有兩種情況:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1、無roomID的的情況,首先需要請求list接口,然後根據list中的roomId來繼續請求當前直播間的相關信息,根據相關的信息進行組件&插件的的安裝以及渲染操作,當頁面渲染完成後,開始創建播放器,setURL,並初始化內核,開始播放直到播放成功回調;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2、有roomID的情況,那麼會直接請求當前直播間的相關信息,然後執行與步驟1相同的操作。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"下面是沉浸式直播間內的滑動跳轉:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/3f/3f48ed82d75ff4b38b1f704548a8b533.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"相對於外部跳轉,沉浸式直播間內跳轉多了用戶的滑動操作,從滑停開始統計啓播,直到播放成功回調,整個啓播時長預計在1700ms左右,而在整個流程中,整個直播的業務耗時約爲1000ms左右。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"外部跳轉:內部跳轉 = 1: N;N要遠遠大於1,這樣看的話,優先優化直播間內跳轉。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"定性定量分析後,制定針對的優化方案:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/18/188338b12e36a92a6ecf3a1b6c18d83e.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"基於頁面卡頓的考慮,整體方案A&B兩種:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"A方案是在iphone8及以上的機型上面實施:在用戶滑動開始時開始創建播放器,並且直接調用播放。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"方案B是在iphone8以下的機型上面實施:在用戶滑動時開始創建播放器並且準備好資源,在用戶滑停之後銷燬上個直播間,並且開始下個直播間的播放。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"A&B方案的實施,使得卡頓率在這iphone8上下的機型都能夠表現的不錯,並不會給用戶卡頓帶來劣化的體驗,針對於機型也是經過ABTest不斷測試啓播與卡頓之間的平衡,尋求的一個暫時的平衡點。後面也會針對於卡頓來做不斷的優化來避免對象頻繁的創建與銷燬,來減少CPU的不斷計算,以使方案A所適應的機型不斷擴增。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"有了直播間內部跳轉的優化方案之後,那麼外部scheme的跳轉也就顯而易見了:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/4c/4c66e7459cddacf1e43bc9c4e6ddd3be.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"百度App的組件間通信方案使用的scheme來通信,那麼在scheme裏面添加直播的URL,在跳轉進直播頁面時直接通過scheme攜帶的URL來創建播放器,並開始播放直播,與業務邏輯並行執行。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"四、DNS預解析","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"DNS(Domain Name System),它的作用是根據域名查出IP地址,它是HTTP協議的前提,只有將域名正確的解析成IP地址後,後面的流程才能進行。在內核處理直播流的時候,直播DNS耗時八十分位大約在60ms,這塊的耗時也是比較多的。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在百度AppAPP中,防止DNS的劫持,同時也是爲了降低網絡時延,我們採用了HTTPDNS的方案:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ee/ee962988a8245a0ff9caa34374138b27.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"爲了優化直播DNS解析耗時,採用DNS預解析策略,提前緩存對應的IP,可以減少DNS解析的耗時時間。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在應用冷啓10s、網絡切換、前後臺切換等時機,根據模型判斷是否採取直播DNS預解析方案,模型的判斷標準爲:用戶N天內瀏覽直播時長M、當前網絡狀態、後端控制等等。當模型判定通過時,會調用HTTPDNS異步發起直播域名的解析獲得一個IP列表,對IP分別進行測速,測速後並不是直接選用結果最優的那一個,而是在測試結果可以接受的一定範圍內進行隨機挑選並緩存預解析的結果。避免了大量用戶都聚集到少數節點,導致的節點負載不均衡。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"HTTPDNS緩存IP的有效時間是從服務端獲取的,默認300s。當直播流域名解析開始時,查詢緩存,若存在有效IP(緩存時間<300s)直接返回對應IP,並調用HTTPDNS異步發起請求更新。若不存在也會異步發起請求更新,此時會降級到LocalDNS解析。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當網絡變化時(Wifi 4G),清除當前的緩存IP,並重新發起域名列表內所有域名的預解析。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"最終收益:使用HTTPDNS預解析後,直播DNS耗時小於3ms的PV佔總直播PV的90%以上。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"五、內核的一些優化","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"針對於報表裏面耗時較多的階段,進行了一系列針對的優化:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1、首屏強制渲染:主要就是視頻的首幀解碼出來就會強制走渲染流程,不會去做音畫同步;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2、弱網情況下,啓動低碼率啓播策略;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3、高端機型下加載下個播放器內核,並prepare,當切換直播時進行追幀操作。大概邏輯就是緩衝區延時超過3秒就每隔2秒就丟200ms音頻,直到低於3秒內不丟,如果超過16秒,就會全部丟掉 直接重連。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"六、直播起播優化","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"直播起播優化-媒體信息解析模塊的優化","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":"br"}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"視頻寬高、圖像編碼格式等信息是Android平臺硬件解碼器Mediacodec,IOS平臺硬件解碼器Video ToolBox必備信息,播放內核在配置平臺硬件解碼器之前,需要準備好視頻寬高、圖像編碼格式等信息。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一些封裝格式(例如MP4)會在頭部描述視頻寬高、圖像編碼格式等信息,針對視頻容器不包含上述信息的情況(例如FLV),FFMPEG原生流程就循環的下載視頻流,然後通過軟件解碼器解碼視頻,獲取上述信息;","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在H.264/AVC視頻編碼標準中,整個系統框架被分爲了兩個層面:視頻編碼層面(VCL)和網絡抽象層面(NAL)。其中,前者負責有效表示視頻數據的內容,而後者則負責格式化數據並提供頭信息,以保證數據適合各種信道和存儲介質上的傳輸。NAL中的SPS,PPS中已經寬高信息,圖像編碼格式的描述,可以通過解析SPS,PPS獲取必要信息,省去軟解視頻的流程。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/6e/6e6c781b134d868e36984d98ded342c7.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"七、直播回放(HLS)m3u8預取","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"直播視頻通常會被編碼成HLS格式保存,我們稱此爲直播回放,HLS封裝格式的視頻起播80分位爲1250ms,起播速度是反應播放體驗的核心指標,直播回放起播性能顯著差於直播(HTTP-FLV)的510ms。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"HLS封裝起播慢的主要原因是因爲需要先下載視頻索引文件(M3U8),通過解析該索引文件纔得到真正的視頻文件,也就是說相比直播(HTTP-FLV)至少多了一次HTTP的請求。爲了解決這個問題,通過提前預取HLS視頻索引文件(M3U8)到本地sdcard;起播時省去了M3U8下載部分耗時,AB實驗收益:對比命中和未命中預取M3U8實驗組,命中預取收益爲346ms。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/f7/f79f9036264897be0a60f18b3e40fe75.webp","alt":"圖片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"參考文獻:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"https://chromium.googlesource.com/chromium/src/+/HEAD/docs/ios/build_instructions.md","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"https://tools.ietf.org/html/rfc7858","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"italic","attrs":{}}],"text":"https://github.com/bilibili/ijkplayer","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"招聘信息:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"百度-直播研發部-泛知識直播組,團隊旨在建設業界一流的直播體驗,技術驅動業務,並在直播場景中不斷的創新,結合 VR&AR&AI 等技術,不斷探索新的玩法。播放內核, 團隊通過不斷提升內核的基礎性能,增強內核能力,完善指標監控,提高服務能力,最終實現更好的用戶體驗和產品質量。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"誠邀iOS & Android小夥伴,關注同名公衆號百度Geek說,點擊菜單欄“內推”即可加入搜索架構部,我們期待你的加入","attrs":{}},{"type":"text","text":"!","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"推薦閱讀:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://www.oschina.net/action/GoToLink?url=http%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg5MjU0NTI5OQ%3D%3D%26mid%3D2247495266%26idx%3D1%26sn%3Da50ed4cf4828bb6bdc6caa58c2cdae5a%26chksm%3Dc03ede1ef74957080a72f358781b0ee656be889bf4a91705a249ab1c7e36ce78294de2974226%26scene%3D21%23wechat_redirect","title":null,"type":null},"content":[{"type":"text","text":"|百度搜索穩定性問題分析的故事(下)","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://www.oschina.net/action/GoToLink?url=http%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg5MjU0NTI5OQ%3D%3D%26mid%3D2247495266%26idx%3D1%26sn%3Da50ed4cf4828bb6bdc6caa58c2cdae5a%26chksm%3Dc03ede1ef74957080a72f358781b0ee656be889bf4a91705a249ab1c7e36ce78294de2974226%26scene%3D21%23wechat_redirect","title":null,"type":null},"content":[{"type":"text","text":"|百度搜索穩定性問題分析的故事(上)","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://www.oschina.net/action/GoToLink?url=http%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzg5MjU0NTI5OQ%3D%3D%26mid%3D2247495229%26idx%3D1%26sn%3Db3cfdbcf0a5ebcc44d673dfbc8f83196%26chksm%3Dc03ede41f74957571ed3ef7e2a1f2f5f128bb3e8b9466039e0321a3340b49e8d823ae4f21d10%26scene%3D21%23wechat_redirect","title":null,"type":null},"content":[{"type":"text","text":"百度關於微前端架構EMP的探索:落地生產可用的微前端架構","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"---------- END ----------","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"百度Geek說","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"百度官方技術公衆號上線啦!","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"技術乾貨 · 行業資訊 · 線上沙龍 · 行業大會","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"招聘信息 · 內推信息 · 技術書籍 · 百度周邊","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"歡迎各位同學關注","attrs":{}}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章