File size: 659 Bytes
2e5e07d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)