Vlogger-ShowMaker / vlogger /videofusion.py
GrayShine's picture
Upload 60 files
2e5e07d verified
raw
history blame
659 Bytes
import torch
import os
from decord import VideoReader, cpu
import numpy as np
import torchvision
def fusion(path):
fnames = []
for fname in os.listdir(path):
if not fname.startswith("result"):
fnames.append(fname)
fnames.sort(key=lambda x: int(x.split('.')[0]))
for i, fname in enumerate(fnames):
fpath = os.path.join(path, fname)
video = VideoReader(fpath, ctx=cpu(0))
video = video[:].asnumpy()
if i == 0:
result = video
else:
result = np.concatenate((result, video), axis=0)
torchvision.io.write_video(path + "/" + "result" + '.mp4', result, fps=8)