LoginSignup
1
2

More than 5 years have passed since last update.

FFmpegを使ってOPENREC(ライブ)を録画する方法

Last updated at Posted at 2017-10-25

ffmpeg を使えばOPENRECライブ(生配信)をmp4ファイルに録画することができる

  • この記事はmacOS想定
  • ffmpegさえ利用可能にすればWindowsやLinuxでも使えるのでは

Homebrew のインストール

必須ではないが便利

macOS
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

ffmpeg のインストール

macOS
brew instal ffmpeg

インストールできたかの確認

macOS
ffmpeg -version
ffmpeg version N.N Copyright (c) 2000-YYYY the FFmpeg developers

録画したファイルを置く専用フォルダを用意して移動

macOS
$ cd Desktop
$ mkdir video
$ cd video

OPENRECを録画する

デベロッパーツールを開き、Networkタブへ移動する

表示 > 開発 / 管理 > デベロッパー ツール
"Network"タブを表示する

録画したいOPENRECをChromeブラウザで開く

https://www.openrec.tv/live/hogehoge

playlist.m3u8の情報を取得する

Networkコンソールにm3u8を表示する

フィルターにm3u8を指定すると便利

playlist.m3u8を右クリックしてcURLを取得する

Copy > Copy as cURL

fig_2017-10-25_17_05_25.png

  • playlist.m3u8 が良い

ffmpeg コマンドラインの構築に必要な情報を抽出する

コピーしたcURLは以下のようになる

curl 'https://stationhoge.openrec.tv/live1/ngrp:hogehogehogehogehogehogehogehogehogehogehoge_normal/playlist.m3u8' -H 'origin: https://www.openrec.tv' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: ja,en-US;q=0.8,en;q=0.6' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36' -H 'accept: text/plain, */*; q=0.01' -H 'referer: https://www.openrec.tv/live/hogehoge' -H 'authority: stationhoge.openrec.tv' --compressed

ffmpeg コマンドラインを構築する

上記の情報を以下のように再構築する

ffmpeg \
-headers 'Origin: https://www.openrec.tv' \
-headers 'Accept-Encoding: gzip, deflate, br' \
-headers 'Accept-Language: ja,en-US;q=0.8,en;q=0.6' \
-user_agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" \
-headers 'Accept: text/plain, */*; q=0.01' \
-headers 'Referer: https://www.openrec.tv/live/hogehoge' \
-headers 'Authority: stationhoge.openrec.tv' \
-i "https://stationhoge.openrec.tv/live1/ngrp:hogehogehogehogehogehogehogehogehogehogehoge_normal/playlist.m3u8" \
-codec copy \
-bsf:a aac_adtstoasc \
-movflags faststart \
video.mp4

実際は各々の環境で異なる箇所のみ変更すれば良い。具体的には
- user_agent
- Referer
- Authority
- m3u8のURL

録画する

macOSのターミナルを開き、上記コマンドを実行する。
停止するには q を押す

確認する

フォルダ内を覗くと
video.mp4
ができているはず

高度な操作

ffmpeg Documentation
にたくさんオプションが説明されている

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2