RickBlog

恩返し

mp4をFFmpegでHLS(m3u8,ts)に変換[Ruby]

mp4をffmpegを使ってm3u8とtsファイルに変換する方法はこちらの記事を参考にした。

https://qiita.com/korsmic/items/fac1d737f48aabb1294fqiita.com

Rubyを使って変換したい場合はstreamio-ffmpegというgemを使う。 https://github.com/streamio/streamio-ffmpeg

optionsを以下のようにするとmp4をm3u8とtsファイルに変換できる。

options = { custom: ["-codec", "copy", "-map", "0", "-f", "segment", "-vbsf", "h264_mp4toannexb", "-segment_format", "mpegts", "-segment_time", "4", "-segment_list", "[output file path]", " [output file name] -%03d.ts" ]}