1 回答

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超2個(gè)贊
OP 討論了 256 個(gè)視頻的縮放問題。就此而言,我建議使用自動(dòng)化,例如使用 Python。我們可以看到這部分會(huì)隨著視頻數(shù)量的變化而變化:
假設(shè)你有一個(gè) python 中所有視頻的列表(你可以手動(dòng)完成,但我建議os.listdir
像這樣使用)
以同樣的方式,您必須生成過濾器的輸入overlay
,這將取決于您的輸出分辨率。假設(shè)它是由width
和height
變量定義的。grid_width
另外,在我的示例中,網(wǎng)格(和)的視頻數(shù)量grid_width
是手動(dòng)設(shè)置的。這是一個(gè)代碼示例,我沒有資源或時(shí)間來測(cè)試,但這應(yīng)該是您工作的良好基礎(chǔ):
###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)?
添加回答
舉報(bào)