LoginSignup
4

More than 5 years have passed since last update.

ごめんよ、まだ僕にはHLSを作れるツールがあるんだ。こんな嬉しいことはない。ShakaPackagerでmp4からHLSを作る。

Posted at

ようやく

ネクストスケープ 配信事業本部 Advent Calendar 2016 もコンプリートの目が出てきたのですが
まだ空いている日が有るので、例のごとく小ネタで埋めます。
相変わらずの、誰得な内容です。

HLSって・・・

みんな何のツールで作ってるんですかね?Macの環境が有るならそれ用のツールが有りますけど、
WindowsやLinuxの人はやっぱりffmpegで作ってるんでしょうか。それともbento4でしょうか。

実はGooleがMPEG-DASHのパッケージャとして開発をしている ShakaPackager にもいつの間にやらHLSの作成機能が実装されていたりします。
しかも、Widevineでの暗号化まで出来てしまうので結構お得です。再生できるプレーヤーを用意するのが大変ですが。
先日Windows用ShakaPackagerをビルドする記事も書いたので、今回はShakaPackagerを使ってHLSを作ってみようと思います。

早速作ってみる(Windows向け)

単純にHLSをmp4から作るだけなら

packager input=some.mp4,stream=video,segment_template=video_$Number$.ts,playlist_name=video_playlist.m3u8 ^
input=some.mp4,stream=audio,segment_template=audio_$Number$.ts,playlist_name=audio_playlist.m3u8,hls_group_id=audio ^
--single_segment=false ^
--hls_master_playlist_output="master_playlist.m3u8"

こんな感じでしょうか。

これに、Widevineの暗号化オプションを付けると

packager input=some.mp4,stream=video,segment_template=video_$Number$.ts,playlist_name=video_playlist.m3u8 ^
input=some.mp4,stream=audio,segment_template=audio_$Number$.ts,playlist_name=audio_playlist.m3u8,hls_group_id=audio ^
--single_segment=false ^
--hls_master_playlist_output="master_playlist.m3u8" ^
--enable_widevine_encryption ^
--key_server_url "https://license.uat.widevine.com/cenc/getcontentkey/widevine_test" ^
--content_id "3031323334353637" ^
--signer "widevine_test" ^
--aes_signing_key "1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9" ^
--aes_signing_iv "d58ce954203b7c9a9a9d467f59839249"

こんな感じですかね。
Widevine用のオプションの値はテスト用のデフォルト値です。Widevineのバートナーの方なら、この辺の値は
持っていると思いますので書き換えて下さい。
※ネクストスケープはWidevineの認定パートナー企業です。この記事を書いている人は認定パートナーの一人です。

この暗号化はAES-CTR方式でのWidevine暗号化なので、これをAES-CBC方式でのWidevine暗号化に変えると

packager input=some.mp4,stream=video,segment_template=video_$Number$.ts,playlist_name=video_playlist.m3u8 ^
input=some.mp4,stream=audio,segment_template=audio_$Number$.ts,playlist_name=audio_playlist.m3u8,hls_group_id=audio ^
--single_segment=false ^
--hls_master_playlist_output="master_playlist.m3u8" ^
--enable_widevine_encryption ^
--key_server_url "https://license.uat.widevine.com/cenc/getcontentkey/widevine_test" ^
--content_id "3031323334353637" ^
--signer "widevine_test" ^
--aes_signing_key "1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9" ^
--aes_signing_iv "d58ce954203b7c9a9a9d467f59839249" ^
--protection_scheme cbcs

という感じです。これで、今の所ほぼ誰も再生できないコンテンツが出来上がりました。

ほんと誰得なんだよ・・・

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
4