-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimg_to_video.py
55 lines (34 loc) · 1.24 KB
/
img_to_video.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 bpy
import os
import sys
# change to your path here
ROOT_DIR = "F:/Project/blender_tools"
DATA_DIR = os.path.join(ROOT_DIR, "env_data")
sys.path.append(ROOT_DIR)
import importlib
from tools import render
from tools import video
importlib.reload(render)
importlib.reload(video)
# NOTE you need to run with blender UI
def main():
output_path = os.path.join(ROOT_DIR, f"./doc/images/animate/img2video.mp4")
image_folder = os.path.join(ROOT_DIR, "./doc/images/animate")
image_name_list = [ f's_{i}.png' for i in range(5) ]
target_seconds = 2
fps = 20
reso_x = 400
reso_y = 400
sequence_name = 'img_seq'
video.clear_seqs()
sequence = video.add_img_seq( sequence_name, image_folder, image_name_list)
speed_up_scale = len(image_name_list) / (fps * target_seconds)
video.speed_up( sequence.name, speed_up_scale)
start_frame = int(sequence.frame_start)
end_frame = int(sequence.frame_final_duration)
video.add_color_background( 'background', [1,1,1], start_frame, end_frame*2)
render.set_render_frames( start_frame, end_frame )
render.set_render(reso_x, reso_y, format='FFMPEG', fps=fps)
render.do_render( output_path, animation=True )
if __name__ == '__main__':
main()