Docker で mp4 を HLS形式にコンバート
https://hub.docker.com/r/jrottenberg/ffmpeg/ を使いました。
事前に動画ファイルと出力先ディレクトリを用意します。
% tree .
.
├── dest
└── src
└── test.mp4
Docker イメージを pull して ffmpeg を実行します。
% docker pull jrottenberg/ffmpeg
% docker run --rm -v `pwd`/src:/src -v `pwd`/dest:/dest jrottenberg/ffmpeg -i /src/test.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls /dest/test.m3u8
実行ログです。
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609
configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-postproc --enable-small --enable-version3 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/src/test.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
creation_time : 2016-06-05T02:07:03.000000Z
Duration: 00:03:00.69, start: 0.000000, bitrate: 2737 kb/s
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2478 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2016-06-05T02:07:03.000000Z
handler_name : L-SMASH Video Handler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
creation_time : 2016-06-05T02:07:03.000000Z
handler_name : L-SMASH Audio Handler
[hls @ 0x184c980] Opening '/dest/test0.ts' for writing
Output #0, hls, to '/dest/test.m3u8':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
encoder : Lavf58.20.100
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2478 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 23.98 tbc (default)
Metadata:
creation_time : 2016-06-05T02:07:03.000000Z
handler_name : L-SMASH Video Handler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
creation_time : 2016-06-05T02:07:03.000000Z
handler_name : L-SMASH Audio Handler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls @ 0x184c980] Opening '/dest/test1.ts' for writing
[hls @ 0x184c980] Cannot use rename on non file protocol, this may lead to races and temporary partial files
[hls @ 0x184c980] Opening '/dest/test2.ts' for writing
[hls @ 0x184c980] Opening '/dest/test3.ts' for writing
[hls @ 0x184c980] Opening '/dest/test4.ts' for writing
[hls @ 0x184c980] Opening '/dest/test5.ts' for writing
[hls @ 0x184c980] Opening '/dest/test6.ts' for writing
[hls @ 0x184c980] Opening '/dest/test7.ts' for writing
[hls @ 0x184c980] Opening '/dest/test8.ts' for writing
[hls @ 0x184c980] Opening '/dest/test9.ts' for writing
[hls @ 0x184c980] Opening '/dest/test10.ts' for writing
[hls @ 0x184c980] Opening '/dest/test11.ts' for writing
[hls @ 0x184c980] Opening '/dest/test12.ts' for writing
[hls @ 0x184c980] Opening '/dest/test13.ts' for writing
[hls @ 0x184c980] Opening '/dest/test14.ts' for writingtrate=N/A speed= 276x
[hls @ 0x184c980] Opening '/dest/test15.ts' for writing
[hls @ 0x184c980] Opening '/dest/test16.ts' for writing
[hls @ 0x184c980] Opening '/dest/test17.ts' for writing
[hls @ 0x184c980] Opening '/dest/test18.ts' for writing
frame= 4331 fps=0.0 q=-1.0 Lsize=N/A time=00:03:00.67 bitrate=N/A speed= 233x
video:54653kB audio:5647kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
HLS形式で出力されました。
% tree .
.
├── dest
│ ├── test.m3u8
│ ├── test0.ts
│ ├── test1.ts
│ ├── test10.ts
│ ├── test11.ts
│ ├── test12.ts
│ ├── test13.ts
│ ├── test14.ts
│ ├── test15.ts
│ ├── test16.ts
│ ├── test17.ts
│ ├── test18.ts
│ ├── test2.ts
│ ├── test3.ts
│ ├── test4.ts
│ ├── test5.ts
│ ├── test6.ts
│ ├── test7.ts
│ ├── test8.ts
│ └── test9.ts
└── src
└── test.mp4
Read other posts