ffmpeg で動画を結合する方法 2 mpd ファイル編(memo)
ffmpeg で動画を結合する方法
基本的な手順は上記の URL を参照しつつ実施しました。
上記の手順で詰まったところを補足しています。
環境
ffmpeg は今回 WSL 入れて、Ubuntu 上で下記を実施してインストールしました。
sudo apt install ffmpeg
手順
- mp4 ファイルを作成。作成方法は問わず。
- 下記コマンドを実行する
ffmpeg -re -i test.mp4 -map 0 -map 0 -c:v:0 copy -c:a:0 copy \ -filter:v:1 "scale=-2:360" -c:v:1 libx264 -profile:v:1 main -b:v:1 600k -c:a:1 aac -b:a:1 128k \ -f dash -window_size 5 -adaptation_sets "id=0,streams=v id=1,streams=a" \ -movflags +faststart test.mpd
ログ
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2017-08-25T06:57:06.000000Z
Duration: 00:01:11.84, start: 0.000000, bitrate: 1383 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1253 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default)
Metadata:
creation_time : 2017-08-25T06:57:06.000000Z
handler_name : ISO Media file produced by Google Inc.
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2017-08-25T06:57:06.000000Z
handler_name : ISO Media file produced by Google Inc.
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #0:0 -> #0:2 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:3 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fffb9ffba00] using SAR=1/1
[libx264 @ 0x7fffb9ffba00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fffb9ffba00] profile Main, level 3.0
[libx264 @ 0x7fffb9ffba00] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=11 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=600 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[dash @ 0x7fffb9fa0980] Opening 'init-stream0.m4s' for writing
[dash @ 0x7fffb9fa0980] Opening 'init-stream1.m4s' for writing
[dash @ 0x7fffb9fa0980] Opening 'init-stream2.m4s' for writing
[dash @ 0x7fffb9fa0980] Opening 'init-stream3.m4s' for writing
Output #0, dash, to 'test.mpd':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf57.83.100
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1253 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
Metadata:
creation_time : 2017-08-25T06:57:06.000000Z
handler_name : ISO Media file produced by Google Inc.
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Metadata:
creation_time : 2017-08-25T06:57:06.000000Z
handler_name : ISO Media file produced by Google Inc.
Stream #0:2(und): Video: h264 (libx264), yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 600 kb/s, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
creation_time : 2017-08-25T06:57:06.000000Z
handler_name : ISO Media file produced by Google Inc.
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/600000 buffer size: 0 vbv_delay: -1
Stream #0:3(und): Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2017-08-25T06:57:06.000000Z
handler_name : ISO Media file produced by Google Inc.
encoder : Lavc57.107.100 aac
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing bitrate=N/A speed=0.996x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00001.m4s.tmp' for writingpeed=0.999x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00001.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00001.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00001.m4s.tmp' for writingpeed=0.998x
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00002.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00002.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00002.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00003.m4s.tmp' for writingpeed=0.999x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00003.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00003.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00002.m4s.tmp' for writingpeed=0.999x
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00004.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00004.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00004.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00003.m4s.tmp' for writingpeed=0.999x
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00005.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00005.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00005.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00006.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00006.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00006.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00004.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00007.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00007.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00007.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00005.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00008.m4s.tmp' for writingpeed=0.999x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00008.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00008.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00009.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00009.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00009.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00006.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00010.m4s.tmp' for writingpeed=0.999x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00010.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00010.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00007.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00011.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00011.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00011.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00012.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00012.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00012.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00008.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00013.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00013.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00013.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream0-00014.m4s.tmp' for writingpeed= 1x
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream1-00014.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream2-00009.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'chunk-stream3-00014.m4s.tmp' for writing
[dash @ 0x7fffb9fa0980] Opening 'test.mpd.tmp' for writing
frame= 2155 fps= 30 q=-1.0 Lq=-1.0 size=N/A time=00:01:11.84 bitrate=N/A speed=0.997x
video:16469kB audio:2223kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7fffb9ffba00] frame I:9 Avg QP:20.69 size: 40942
[libx264 @ 0x7fffb9ffba00] frame P:588 Avg QP:23.30 size: 6658
[libx264 @ 0x7fffb9ffba00] frame B:1558 Avg QP:28.54 size: 850
[libx264 @ 0x7fffb9ffba00] consecutive B-frames: 2.8% 1.8% 2.1% 93.4%
[libx264 @ 0x7fffb9ffba00] mb I I16..4: 14.3% 0.0% 85.7%
[libx264 @ 0x7fffb9ffba00] mb P I16..4: 0.6% 0.0% 1.2% P16..4: 38.9% 22.2% 17.1% 0.0% 0.0% skip:20.1%
[libx264 @ 0x7fffb9ffba00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 41.3% 2.9% 0.8% direct: 1.6% skip:53.4% L0:42.2% L1:51.6% BI: 6.1%
[libx264 @ 0x7fffb9ffba00] final ratefactor: 23.12
[libx264 @ 0x7fffb9ffba00] coded y,uvDC,uvAC intra: 78.9% 60.9% 23.5% inter: 10.5% 5.6% 0.1%
[libx264 @ 0x7fffb9ffba00] i16 v,h,dc,p: 25% 31% 8% 36%
[libx264 @ 0x7fffb9ffba00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 30% 11% 5% 8% 6% 10% 5% 7%
[libx264 @ 0x7fffb9ffba00] i8c dc,h,v,p: 57% 22% 15% 5%
[libx264 @ 0x7fffb9ffba00] Weighted P-Frames: Y:3.2% UV:0.2%
[libx264 @ 0x7fffb9ffba00] ref P L0: 59.5% 17.3% 13.7% 9.3% 0.2%
[libx264 @ 0x7fffb9ffba00] ref B L0: 82.9% 12.7% 4.5%
[libx264 @ 0x7fffb9ffba00] ref B L1: 89.8% 10.2%
[libx264 @ 0x7fffb9ffba00] kb/s:624.49
[aac @ 0x7fffba073ba0] Qavg: 57434.145