亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將網格中的多個視頻合并到一個視頻中?

如何將網格中的多個視頻合并到一個視頻中?

慕桂英546537 2023-08-22 16:02:19
我有 36 個具有相同尺寸的視頻文件,想要將它們連接成一個具有 6x6 網格的視頻。理想情況下,給出的視頻數量是非正方形的,例如 12 個,4x3 網格,因為它可以是最大的正方形就很好了。我嘗試使用 matplotlib 的動畫庫,但未能首先將兩個方向的視頻連接為行,然后連接為列。任何幫助都是appriced!
查看完整描述

1 回答

?
慕斯王

TA貢獻1864條經驗 獲得超2個贊

OP 討論了 256 個視頻的縮放問題。就此而言,我建議使用自動化,例如使用 Python。我們可以看到這部分會隨著視頻數量的變化而變化:

假設你有一個 python 中所有視頻的列表(你可以手動完成,但我建議os.listdir像這樣使用)

以同樣的方式,您必須生成過濾器的輸入overlay,這將取決于您的輸出分辨率。假設它是由widthheight變量定義的。grid_width另外,在我的示例中,網格(和)的視頻數量grid_width是手動設置的。這是一個代碼示例,我沒有資源或時間來測試,但這應該是您工作的良好基礎:

###list_videos contains the path the the videos

width = 1920

height = 1080

input_videos = ""

input_setpts = "nullsrc=size={}x{} [base];".format(width, height)

input_overlays = "[base][video0] overlay=shortest=1 [tmp0];"

grid_width = 16

grid_height = 16

for index, path_video in enumerate(list_video):

? ? ? ? input_videos += " -i " + path_video

? ? ? ? input_setpts += "[{}:v] setpts=PTS-STARTPTS, scale={}x{} [video{}];".format(index, width//grid_width, height//grid_height, index)

? ? ? ? if index > 0 and index < len(list_video) - 1:

? ? ? ? ? ? input_overlays += "[tmp{}][video{}] overlay=shortest=1:x={}:y={} [tmp{}];".format(index-1, index, width//grid_width * (index%grid_width), height//grid_height * (index//grid_width), index)

? ? ? ? if index == len(list_video) - 1:

? ? ? ? ? ? input_overlays += "[tmp{}][video{}] overlay=shortest=1:x={}:y={}".format(index-1, index, width//grid_width * (index%grid_width), height//grid_height * (index//grid_width))


complete_command = "ffmpeg" + input_videos + " -filter_complex \"" + input_setpts + input_overlays + "\" -c:v libx264 output.mp4"


print(complete_command)?


查看完整回答
反對 回復 2023-08-22
  • 1 回答
  • 0 關注
  • 1623 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號