Open7
Cloudflare上で動画配信
![じゅっじゅおー](https://res.cloudinary.com/zenn/image/fetch/s--EJuunWRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/3806dde8b0.jpeg)
動画配信まるっと面倒見てくれるstream
mp4入れれば、配信用にトランスコードして保持してくれる
![じゅっじゅおー](https://res.cloudinary.com/zenn/image/fetch/s--EJuunWRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/3806dde8b0.jpeg)
HLSに自前で変換できるならR2に入れて配信する方が安そう
Publicバケットにして、Objectがcacheに乗ればegressにはお金がかからないので配信料を落とせる
cacheヒット前にBクラスのオペレーションにお金はかかるが、安い
StorageもGCSと比べて安い
![じゅっじゅおー](https://res.cloudinary.com/zenn/image/fetch/s--EJuunWRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/3806dde8b0.jpeg)
Cloudflare CDNのキャッシュにデフォルトでm3u8, tsは含まれないので含める
とりあえず拡張子ルール設定
![じゅっじゅおー](https://res.cloudinary.com/zenn/image/fetch/s--EJuunWRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/3806dde8b0.jpeg)
HLSが格納されているフォルダー単位でアップロードしたいときはrclone使うとよい
![じゅっじゅおー](https://res.cloudinary.com/zenn/image/fetch/s--EJuunWRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/3806dde8b0.jpeg)
公式から持ってきただけ
rclone config file
で ~/.config/rclone/rclone.conf
にフォルダーができるので、そこで設定を記述
[r2]
type = s3
provider = Cloudflare
access_key_id = abc123
secret_access_key = xyz456
endpoint = https://<accountid>.r2.cloudflarestorage.com
acl = private
![じゅっじゅおー](https://res.cloudinary.com/zenn/image/fetch/s--EJuunWRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/3806dde8b0.jpeg)
先にAPI keyが必要
ぽちぽち案内に従ってkeyを発行
![じゅっじゅおー](https://res.cloudinary.com/zenn/image/fetch/s--EJuunWRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/3806dde8b0.jpeg)
rclone copy フォルダ名 r2:バケット名/フォルダ名
r2はrclone.confで指定したprofile名