LoginSignup
1
4

More than 5 years have passed since last update.

FFmpegを使ってOPENREC(アーカイブ)を保存する方法

Last updated at Posted at 2017-10-26

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

normal.m3u8の情報を取得する

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

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

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

Copy > Copy as cURL

fig_2017-10-26_18_13_10.png

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

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

curl 'https://hogehoge.cloudfront.net/hogehogehogehogehogehogehogehogehogehogehogehoge/normal.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 'If-None-Match: "hogehogehogehogehogehogehoge"' -H 'Connection: keep-alive' -H 'If-Modified-Since: hoge, DD MMM YYYY HH:MM:SS GMT' --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 'If-None-Match: "hogehogehogehogehogehogehoge"' \
-headers 'Connection: keep-alive' \
-headers 'If-Modified-Since: hoge, DD MMM YYYY HH:MM:SS GMT' \
-i "https://hogehoge.cloudfront.net/hogehogehogehogehogehogehogehoge/normal.m3u8" \
-codec copy \
-bsf:a aac_adtstoasc \
-movflags faststart \
video.mp4

録画する

macOSのターミナルを開き、上記コマンドを実行する。

録画が終了したら自動的に停止する

確認する

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

高度な操作

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

1
4
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
4