1 回答

TA貢獻1864條經驗 獲得超2個贊
OP 討論了 256 個視頻的縮放問題。就此而言,我建議使用自動化,例如使用 Python。我們可以看到這部分會隨著視頻數量的變化而變化:
假設你有一個 python 中所有視頻的列表(你可以手動完成,但我建議os.listdir
像這樣使用)
以同樣的方式,您必須生成過濾器的輸入overlay
,這將取決于您的輸出分辨率。假設它是由width
和height
變量定義的。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)?
添加回答
舉報