/
_test_i2v_.py
55 lines (51 loc) · 1.74 KB
/
_test_i2v_.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import asyncio
import os
import unittest
from v2v import Image2VideoProcessor
from . import _config_ as config
import numpy as np
from v2v.datastruct import FrameData
class TestImage2VideoProcessor(unittest.TestCase):
def setUp(self) -> None:
"""
모든 unittest 직전에 이 메서드가 호출됩니다.
"""
def tearDown(self) -> None:
"""
모든 unittest 직후에 이 메서드가 호출됩니다.
"""
def test_encode_frames(self):
width = config.test_i2vp["test_video_width"]
height = config.test_i2vp["test_video_height"]
fps = config.test_i2vp["test_video_fps"]
colors = config.test_i2vp["test_video_color_sequence"]
frame_datas = [
FrameData(fid, (np.ones((height, width, 3)) * c).astype(np.uint8))
for fid, c in enumerate(colors)
]
frame_datas.append(None) # end of the frame
i2vp = Image2VideoProcessor(
dst_video_path=config.test_i2vp["dst_video_path"],
width=width,
height=height,
fps=fps,
ffmpeg_options_input=config.test_i2vp["ffmpeg_options_input"],
ffmpeg_options_output=config.test_i2vp["ffmpeg_options_output"],
)
while True:
frame_data = frame_datas.pop(0)
i2vp(frame_data)
if frame_data is None:
break
self.assertEqual(
os.path.exists(i2vp.dst_video_path),
True,
f"{i2vp.dst_video_path} is not exist!",
)
os.remove(i2vp.dst_video_path)
self.assertEqual(
os.path.exists(i2vp.dst_video_path),
False,
f"{i2vp.dst_video_path} is not deleted!",
)
return