顯示具有 youtube API 標籤的文章。 顯示所有文章
顯示具有 youtube API 標籤的文章。 顯示所有文章

星期二, 7月 11, 2017

[Youtube] 360直播的一些設定

如果想要在youtube直播360影像,可以參考以下官方說明
https://support.google.com/youtube/answer/6396222?hl=tw

設定編碼器

如要直播 360 度影片,您必須變更編碼規格。
  1. 選取 YouTube 直播平台上的 [活動]。提醒您,如果選取 [立即串流],您就無法直播 360 度影片。
  2. 前往「進階設定」,然後勾選「這是 360° 的現場直播影片」旁的方塊。如果您的裝置已整合 YouTube 直播的 360 度影片功能,您也可以透過我們的 API 進行直播。  
  3. 設定編碼器:
    1. 系統支援的解析度和位元率中,選擇您可以提供的最高直播設定。
    2. 直播 360 度影片時,建議採用 2160p 或 1440p 解析度。
    3. 為了提供最佳影片品質,建議您採用 16:9 長寬比。進一步瞭解長寬比

    位元率參考

詳細可以參考
https://support.google.com/youtube/answer/2853702?hl=zh-Hant

位元率的計算 bitrate (bps = bit/s = bit per second)

找到一個人的參考

檔案大小就看你的 bitrate 設多少, 
假設你設目標是(或稱平均) 1000kb/s, 那半小時是 30(分鐘)x60(每分60秒)=1800秒
那 1000kb/s x 1800s = 1800Mb, 1800Mb/8=225MB (1 byte = 8 bits) -> 
所以檔案大約 225MB (byte) 硬碟容量計算單為用 byte.

根據上述公式速算:
檔案大小 (MB) = (秒 * bit rate) / 8000
Bit rate  = 影片大小 * 8

在網路上抓了一個影片為 128.8MB檔案大小,長度為2.49分鐘的影片,
如何計算bitrate:

由於位元率是以bit 為單位,1 Bytes = 8 bits
依據公式 bitrate = 影片大小 * 8 

128.8M*8/169 (sec) = 6.09Mbps = 6090kbps 
(差不多就是1080p HD的bitrate)


星期四, 2月 16, 2017

[Objective-C] 自幹上傳 mutipart/form 到youtube

要測試一下上傳影片到youtube
由於先前有在java自幹過一次 mutipart/form(四年前了@@) ,
這次改用objective c,順道記錄一下。

Youtube Upload API

函式庫


沒用什麼第三方的庫,NSURLSession自幹

NSURLSessionConfiguration : 做授權

NSMutableURLRequest : 做連線

NSURLSessionUploadTask : 上傳的任務

基本上參考這篇就會寫了
NSURLSessionUploadTask(上传任务)

星期三, 1月 18, 2017

[Objective-C] 初試一下 youtube live streaming (二) 實作步驟

找到幾篇有關於直播的教學,但都2014了,還是可以參考一下。
以下簡述使用Youtube直播步驟

http://yhsiang.logdown.com/posts/2014/04/16/stream-to-youtube-with-live-streaming-api

https://youtube-eng.googleblog.com/2014/10/watchme-live-stream.html

http://justinyang1221.blogspot.tw/2014/10/live-stream-youtubestreaming-to-youtube.html

將即時串流推送到串流伺服器 (推流)
https://github.com/jgh-/VideoCore
https://github.com/LaiFengiOS/LFLiveKit => 最好操作整合,很多人拿來二次開發
https://github.com/pili-engineering/PLMediaStreamingKit

顯示即時串流 (拉流)
https://github.com/Bilibili/ijkplayer

完整流程

以下是最後實作完驗證過的流程,這篇也講的很清楚。
http://octuplus.co/Detalles/2084/Cannot-make-transition-of-my-Youtube-broadcast-to-live-using-Youtube-API

So a bit unclear rule is:
  1. ensure you have broadcast and livestream created and ready.
    and ensure that broadcast lifecycle status is not COMPLETE, otherwise recreate broadcast ... so ensure that your broadcast lifecycle status is ready
  2. bind broadcast to livestream
  3. start publishing video to livestream
  4. wait for livestream status active
  5. transition to testing (yes, you have to do it instead of moving to live)
  6. wait for broadcast lifeCycleStatus to become testing
  7. transition to live
  8. wait for broadcast lifeCycleStatus to become live
You cannot skip testing and cannot transition from complete to testing or ready.

星期四, 12月 29, 2016

[Objective-C] Youtube Oauth2 實作

記錄一下第一次寫iOS如何與Youtube Oauth2串接

首先要申請API KEY跟Oauth要用的Client ID


Oauth2的驗證url記錄 

https://accounts.google.com/o/oauth2/auth?client_id=<你的CLIENTID>.apps.googleusercontent.com&redirect_uri=http://localhost&scope=https://www.googleapis.com/auth/youtube&response_type=code&access_type=offline

403的爆炸

用webview直接丟Oauth2的連結,google會爆給你不允許存取的403 (disallowed_user-agent)



所以改用NSURLSession來處理request,在把結果丟給webview來呈現
成功後你會取得一個auth code: 例如


http://localhost/oauth2callback?code=

星期日, 12月 25, 2016

[Objective-C] 初試一下youtube live streaming (一) 相關資源蒐集

記錄一下工作需要研究的youtube live streaming的呼叫

前置作業

要先到https://console.developers.google.com/ 要先開一個專案並申請api金鑰



帳號啟用直播功能

如果帳號未啟動直播功能,會噴以下錯誤

{
    error =     {
        code = 403;
        errors =         (
                        {
                domain = "youtube.liveBroadcast";
                extendedHelp = "https://www.youtube.com/features";
                message = "The user is not enabled for live streaming.";
                reason = liveStreamingNotEnabled;
            }
        );
        message = "The user is not enabled for live streaming.";
    };
}

可以登入youtube後,到以下連結開通直播功能
https://www.youtube.com/features





Oauth2 處理iOS Client/Server的連線


youtube官方文件

https://support.google.com/youtube/answer/2853700?hl=en&ref_topic=6136989


YouTube Live Streaming API Overviewhttps://developers.google.com/youtube/v3/live/getting-started

YouTube Live Streaming API Code Samples (JAVA/PHP/PYTHON)

Objective C libs for REST

其他你感興趣的文章

Related Posts with Thumbnails