Open DayBySay opened 6 years ago
特徴:
ざっくり:
ちなみにAppleが HLS テスト用の環境を用意してくれてる(オンデマンド配信) https://developer.apple.com/streaming/examples/
↑のHTML部の実装
<div>
<video src="https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8" controls autoplay width="960" height="540"></video>
</div>
こんだけ
通ってる
➜ firebase-misc git:(master) ruby validate-hls/validate-hls.rb "https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8"
validate-hls
Validating: Set of 1 URL(s)
| Validating: Playlist(https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8)
| | ✔ Downloadable with 200 OK
| | Validating: Playlist(https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/v5/prog_index.m3u8)
| | | ✔ Downloadable with 200 OK
| | | Validating: Fragment(https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/v5/fileSequence0.ts)
| | | | ✔ Downloadable with 200 OK
| | | | ✔ Keyframe is first frame
| | | Validating: Fragment(https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/v5/fileSequence1.ts)
| | | | ✔ Downloadable with 200 OK
| | | | ✔ Keyframe is first frame
| | | Validating: Fragment(https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/v5/fileSequence2.ts)
...
次はクライアントアプリの勉強。 Apple公式のサンプルを見てみる。
このサンプルエラー吐いとる・・
2018-05-20 11:33:47.131200+0900 AVFoundationQueuePlayer-Swift[57302:822679] Error occurred with message: Optional("Media \"Progressive Download\" failed to load key \"playable\""), error: Optional(Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSUnderlyingError=0x604000440150 {Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x60800011c950>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802, NSErrorPeerCertificateChainKey=(
"<cert(0x7f83c705bc00) s: *.test.edgekey.net i: DigiCert SHA2 Secure Server CA>",
"<cert(0x7f83c705c600) s: DigiCert SHA2 Secure Server CA i: DigiCert Global Root CA>"
), NSUnderlyingError=0x6040004400c0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTr
動作確認したいだけなので下記対応した
ちとごちゃついてるけど、この辺で再生するための動画を渡しているっぽい
let newPlayerItem = AVPlayerItem(asset: loadedAsset)
self.player.insert(newPlayerItem, after: nil)
この実装でいけた
//
// ViewController.swift
// Study-HTTPLiveStreaming
//
// Created by 清 貴幸 on 2018/05/20.
// Copyright © 2018年 daybysay. All rights reserved.
//
import UIKit
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var playerView: PlayerView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let item = AVPlayerItem(url: URL(string: "https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8")!)
let player = AVPlayer(playerItem: item)
playerView.playerLayer.player = player
player.play()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
class PlayerView: UIView {
var player: AVPlayer? {
get {
return playerLayer.player
}
set {
playerLayer.player = newValue
}
}
var playerLayer: AVPlayerLayer {
return layer as! AVPlayerLayer
}
override class var layerClass: AnyClass {
return AVPlayerLayer.self
}
}
他所様のHLS配信を覗いてみようのコーナー
仕様ツール
なるほど
2018-05-20 12:10:34 GET https://edge-210-140-227-42.showroom-live.com/liveedge/b6f466163e7540bf9717f233f693ffa2f08968bb7ec23c351405d0981ab22415_low/chunklist_w1070664597.m3u8
← 200 OK application/vnd.apple.mpegurl 177b 46ms
Request Response Detail
Accept-Ranges: bytes
Access-Control-Expose-Headers: Content-Length
Server: WowzaStreamingEngine/4.2.0
Cache-Control: no-cache
Access-Control-Allow-Origin: https://www.showroom-live.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Range
Date: Sun, 20 May 2018 03:10:37 GMT
Content-Type: application/vnd.apple.mpegurl
Content-Length: 177
Raw [m:auto]
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:735
#EXTINF:2.002,
media_w1070664597_735.ts
#EXTINF:2.002,
media_w1070664597_736.ts
2秒に1回くらい?更新しているっぽい
2018-05-20 12:10:37 GET https://edge-210-140-227-42.showroom-live.com/liveedge/b6f466163e7540bf9717f233f693ffa2f08968bb7ec23c351405d0981ab22415_low/chunklist_w1070664597.m3u8
← 200 OK application/vnd.apple.mpegurl 177b 90ms
Request Response Detail
Accept-Ranges: bytes
Access-Control-Expose-Headers: Content-Length
Server: WowzaStreamingEngine/4.2.0
Cache-Control: no-cache
Access-Control-Allow-Origin: https://www.showroom-live.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Range
Date: Sun, 20 May 2018 03:10:39 GMT
Content-Type: application/vnd.apple.mpegurl
Content-Length: 177
Raw [m:auto]
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:736
#EXTINF:2.002,
media_w1070664597_736.ts
#EXTINF:2.002,
media_w1070664597_737.ts
これどんなクライアントからも見れてしまうのだろうか?と思って試した所、私の手元のクライアントから見ることができました。
実装
let item = AVPlayerItem(url: URL(string: "https://edge-210-140-227-42.showroom-live.com/liveedge/b6f466163e7540bf9717f233f693ffa2f08968bb7ec23c351405d0981ab22415_low/playlist.m3u8")!)
これ、VRChatにHLS対応のスクリーンを作れば、東雲めぐちゃんの配信をVRChat内で見られる可能性
視聴側の雰囲気はわかってきたので、次は配信
FFMpegでできそう
ffmpegでwebcamのビデオをエンコードでしてmediastreamsegmenterに渡せるかなーというのを試している
ローカルでサーバをたてて、MacのCameraから取得した映像をHLS形式で配信してiOS Simulatorで見ている所
Macのサファリからみているところ
TODO:
must
should
資料