FFMPEG – 合并两个视频并排放在一起

huangapple go评论51阅读模式
英文:

FFMPEG - merge 2 videos side by side

问题

I have 2 videos, same video and audio quality but different length.
Lets say the video resolution is 1920x1080 pixel

What I found so far, but it is not what I need FFMPEG – 合并两个视频并排放在一起

On internet I found many examples which gives me the outcome of 3840x1080 pixel.

What I want:

Outcome: Video with 1920x1080 pixel 
use from video1: left part, such Pixel 1 to 960 
use from video2: right part, such Pixel 961 to 1920
audio is merged, i.e. I can hear both audios simultaneously as available

What I want - optional:

Between 2 videos, there is a visible split like |

Is there a single ffmpeg command line I can use?

Many Thanks,
BM

英文:

I have 2 videos, same video and audio quality but different length.
Lets say the video resolution is 1920x1080 pixel

I want to merge both videos side by side, considering the longest length.

What I found so far, but it is not what I need FFMPEG – 合并两个视频并排放在一起

On internet I found many examples which gives me the outcome of 3840x1080 pixel.

What I want:

Outcome: Video with 1920x1080 pixel 
use from video1: left part, such Pixel 1 to 960 
use from video2: right part, such Pixel 961 to 1920
audio is merged, i.e. I can hear both audios simultaneously as available

What I want - optional:

Between 2 videos, there is a visible split like |

Is there a single ffmpeg command line I can use?

Many Thanks,
BM

答案1

得分: 1

使用剪裁和堆叠:

ffmpeg -i test10.mkv -i test06.mkv -filter_complex "
color=red:2x1080:24000/1001:1[c];
[0]crop=iw/2-1:ih:0:0[v0];
[1]crop=iw/2+1:ih:iw-ow:0[v1];
[v0][c][v1]xstack=inputs=3:grid=3x1;
[0][1]amix
" output.mkv
或者

[v0][c][v1]hstack=inputs=3;
如果输入有不同的帧速率等,可以尝试使用叠加:

ffmpeg -i test10.mkv -i test06.mkv -filter_complex "
[0]crop=iw/2-1:ih:0:0[v0];
[1]crop=iw/2+1:ih:iw-ow:0[v1];
color=red:1920x1080[bg];
[bg][v0]overlay=shortest=1[b0];
[b0][v1]overlay=x=W-w;
[0][1]amix
" output.mkv
英文:

using crop and stack:

ffmpeg -i test10.mkv -i test06.mkv -filter_complex "
color=red:2x1080:24000/1001:1[c];
[0]crop=iw/2-1:ih:0:0[v0];
[1]crop=iw/2+1:ih:iw-ow:0[v1];
[v0][c][v1]xstack=inputs=3:grid=3x1;
[0][1]amix
" output.mkv

or

[v0][c][v1]hstack=inputs=3;

if inputs have different framerates etc, you can try to use overlay:

ffmpeg -i test10.mkv -i test06.mkv -filter_complex "
[0]crop=iw/2-1:ih:0:0[v0];
[1]crop=iw/2+1:ih:iw-ow:0[v1];
color=red:1920x1080[bg];
[bg][v0]overlay=shortest=1[b0];
[b0][v1]overlay=x=W-w;
[0][1]amix
" output.mkv

huangapple
  • 本文由 发表于 2023年2月19日 20:27:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500137.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定