2Align the input movies side-by-side with a black band
2Align the input movies side-by-side with a black band 16:9 to 16:9
FFmpegで2入力した16:9の動画を横に並べて黒帯をつけて16:9で出力する
FFmpegでプレビュー
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "color=s=hd1080 [base];[0] setpts=PTS-STARTPTS, scale=960:-1 [left];[1] setpts=PTS-STARTPTS, scale=960:-1 [right];[base][left] overlay=0:h/2:shortest=1 [wh2];[wh2][right] overlay=w:h/2:shortest=1" -f matroska - | ffplay -i -
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "color=s=hd1080 [base];[0] setpts=PTS-STARTPTS, scale=960:-1 [left];[1] setpts=PTS-STARTPTS, scale=960:-1 [right];[base][left] overlay=0:h/2:shortest=1 [wh2];[wh2][right] overlay=w:h/2:shortest=1" -movflags +faststart -pix_fmt yuv420p -c:v libx264 -crf 20 "output.mp4"
color=s=hd1080 [back_color];
で黒帯のベースにするcolor
フィルターを1920x1080のサイズで生成して[back_color]
という任意の名前をつけています。出力サイズは1920x1080のFullHDになります。
[0]setpts=PTS-STARTPTS, scale=960:-1[left];
で一つ目の入力動画input1.mp4
の入力動画の再生時刻の情報(PTS, presentation timestamp
)を設定して、アスペクト比を保ったままリサイズして[left]
という任意の名前をつけています。
[1]setpts=PTS-STARTPTS, scale=960:-1[right];
で二つ目の入力動画input2.mp4
の入力動画の再生時刻の情報(PTS, presentation timestamp
)を設定して、アスペクト比を保ったままリサイズして[right]
という任意の名前をつけています。
[back_color][left] overlay=0:h/2:shortest=1 [wh2];
で黒帯のベースにするcolor
フィルター[back_color]
に[left]
が左の真ん中に来るようにoverlay=0:h/2
と指定して貼り付けています。shortest=1
で短い方の動画が終わったら動画の出力を終了する指定をして[wh2]
という任意の名前をつけています。
[wh2][right] overlay=w:h/2:shortest=1
で[wh2]
に[right]
が右の真ん中に来るようにoverlay=w:h/2
と指定して貼り付けてshortest=1
で短い方の動画が終わったら動画の出力を終了する指定をしています。
2Align the input movies side-by-side with a black band 4:3 to 16:9
FFmpegで2入力した4:3の動画を横に並べて黒帯をつけて16:9で出力する
FFmpegでプレビュー
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "color=s=hd1080 [back_color];[0] setpts=PTS-STARTPTS, scale=960:-1 [left];[1] setpts=PTS-STARTPTS, scale=960:-1 [right];[back_color][left] overlay=0:h/4:shortest=1 [wh4];[wh4][right] overlay=w:h/4:shortest=1" -f matroska - | ffplay -i -
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "color=s=hd1080 [back_color];[0] setpts=PTS-STARTPTS, scale=960:-1 [left];[1] setpts=PTS-STARTPTS, scale=960:-1 [right];[back_color][left] overlay=0:h/4:shortest=1 [wh4];[wh4][right] overlay=w:h/4:shortest=1" -movflags +faststart -pix_fmt yuv420p -c:v libx264 -crf 20 "output.mp4"
FFmpegで3入力した16:9の動画を横に並べて黒帯をつけて16:9で出力する
FFmpegでプレビュー
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex "color=s=hd1080 [back_color];[0] setpts=PTS-STARTPTS, scale=640:-1 [left];[1] setpts=PTS-STARTPTS, scale=640:-1 [middle];[2] setpts=PTS-STARTPTS, scale=640:-1 [right];[back_color][left] overlay=0:h:shortest=1 [w];[w][middle] overlay=w:h:shortest=1[w2];[w2][right] overlay=w*2:h:shortest=1" -f matroska - | ffplay -i -
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex "color=s=hd1080 [back_color];[0] setpts=PTS-STARTPTS, scale=640:-1 [left];[1] setpts=PTS-STARTPTS, scale=640:-1 [middle];[2] setpts=PTS-STARTPTS, scale=640:-1 [right];[back_color][left] overlay=0:h:shortest=1 [w];[w][middle] overlay=w:h:shortest=1[w2];[w2][right] overlay=w*2:h:shortest=1" -movflags +faststart -pix_fmt yuv420p -c:v libx264 -crf 20 "output.mp4"
color=s=hd1080 [back_color];
で黒帯のベースにするcolor
フィルターを1920x1080のサイズで生成して[back_color]
という任意の名前をつけています。出力サイズは1920x1080のFullHDになります。
[0] setpts=PTS-STARTPTS, scale=640:-1 [left];
で一つ目の入力動画input1.mp4
の入力動画の再生時刻の情報(PTS, presentation timestamp
)を設定して、アスペクト比を保ったままリサイズして[left]</>という任意の名前をつけています。
[1] setpts=PTS-STARTPTS, scale=640:-1 [middle];
で二つ目の入力動画input2.mp4
の入力動画の再生時刻の情報(PTS, presentation timestamp
)を設定して、アスペクト比を保ったままリサイズして[middle]
という任意の名前をつけています。
[2] setpts=PTS-STARTPTS, scale=960:-1[right];
で三つ目の入力動画input3.mp4
の入力動画の再生時刻の情報(PTS, presentation timestamp
)を設定して、アスペクト比を保ったままリサイズして[right]
という任意の名前をつけています。
[back_color][left] overlay=0:h:shortest=1 [w];
で黒帯のベースにするcolor
フィルター[back_color]に[left]
が左の真ん中に来るようにoverlay=0:h
と指定して貼り付けています。shortest=1
で短い方の動画が終わったら動画の出力を終了する指定をして[w]
という任意の名前をつけています。
[w][middle] overlay=w:h:shortest=1[w2];
で[middle]
が[w]
の真ん中に来るようにoverlay=w:h
と指定して貼り付けています。shortest=1
で短い方の動画が終わったら動画の出力を終了する指定をして[w2]
という任意の名前をつけています。
[w2][right] overlay=w*2:h:shortest=1
で[right]
が[w2]
の右に来るようにoverlay=w*2:h
と指定して貼り付けてshortest=1
で短い方の動画が終わったら動画の出力を終了する指定をしています。
FFmpegで3入力した4:3の動画を横に並べて黒帯をつけて16:9で出力する
FFmpegでプレビュー
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex "color=s=hd1080 [back_color];[0] setpts=PTS-STARTPTS, scale=640:-1 [left];[1] setpts=PTS-STARTPTS, scale=640:-1[middle];[2] setpts=PTS-STARTPTS, scale=640:-1 [right];[back_color][left] overlay=0:h/1.6:shortest=1 [w];[w][middle] overlay=w:h/1.6:shortest=1[w2];[w2][right] overlay=w*2:h/1.6:shortest=1" -f matroska - | ffplay -i -
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -filter_complex "color=s=hd1080 [back_color];[0] setpts=PTS-STARTPTS, scale=640:-1 [left];[1] setpts=PTS-STARTPTS, scale=640:-1[middle];[2] setpts=PTS-STARTPTS, scale=640:-1 [right];[back_color][left] overlay=0:h/1.6:shortest=1 [w];[w][middle] overlay=w:h/1.6:shortest=1[w2];[w2][right] overlay=w*2:h/1.6:shortest=1" -movflags +faststart -pix_fmt yuv420p -c:v libx264 -crf 20 "output.mp4"
4:3の動画をリサイズして左右に余白をを付けて16:9で出力する
FFmpegでプレビュー
ffmpeg -i "input.mp4" -filter_complex "scale=oh*dar:1080:flags=lanczos+accurate_rnd,pad=ih*16/9:ih:(ow-iw)/2:0" -f matroska - | ffplay -i -
ffmpeg -i "input.mp4" -filter_complex "scale=oh*dar:1080:flags=lanczos+accurate_rnd,pad=ih*16/9:ih:(ow-iw)/2:0" -movflags +faststart -pix_fmt yuv420p -c:v libx264 -crf 20 "output.mp4"
scale=oh*dar:1080:flags=lanczos+accurate_rnd,pad=ih*16/9:ih:(ow-iw)/2:0
で入力動画を拡大縮小のアルゴリズムオプションにlanczos+accurate_rnd
を指定してアスペクト比を保ったまま1440x1080でリサイズして、pad
フィルタで出力サイズが1920x1080になるように左右に黒の余白を付けています。4:3の動画に余白をを付けて16:9で出力するコマンド
pad=ih*16/9:ih:(ow-iw)/2:0
16:9の動画の上下に余白をを付けて4:3で出力する
FFmpegでプレビュー
ffmpeg -i "input.mp4" -filter_complex "pad=iw:iw*3/4:0:(oh-ih)/2" -f matroska - | ffplay -i -
ffmpeg -i "input.mp4" -filter_complex "pad=iw:iw*3/4:0:(oh-ih)/2" -movflags +faststart -pix_fmt yuv420p -c:v libx264 -crf 20 "output.mp4"
16:9の動画に余白をを付けて4:3で出力するコマンド
pad=iw:iw*3/4:0:(oh-ih)/2