0
A
回答
0
你可能可以使用一組濾鏡來獲得你想要的。 你先重新調整第一視頻所需的大小左:https://ffmpeg.org/ffmpeg-filters.html#scale-1
'scale=width:height'
然後應用黑邊來定位左側的視頻; totalwidth
和totalheight
是輸出視頻的最終尺寸,x
和y
您的重新調整,左側視頻的位置:https://ffmpeg.org/ffmpeg-filters.html#pad-1
{
filter: 'pad',
options: 'totalwidth:totalheigth:x:y'
}
最後,使用複雜的過濾器overlay
把你的右側的視頻;注意,應首先重新調整:https://ffmpeg.org/ffmpeg-filters.html#overlay-1
{
filter: 'overlay', options: { x: 'x', y: 'y' },
},
這裏是你的代碼應該是什麼樣子:(基於快速文檔上:https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#complexfilterfilters-map-set-complex-filtergraph)
ffmpeg('left_video.avi')
.input('right_video.avi')
.complexFilter([
// Rescale input video
'scale=width:height',
// Add black bars to position your left video at x, y position
{
filter: 'pad',
options: 'totalwidth:totalheigth:x:y'
}
// Overlay the second input for right side video
{
filter: 'overlay', options: { x: 'x', y: 'y' },
},
], 'output');
注意我沒有測試它 ,但它應該工作