-
Notifications
You must be signed in to change notification settings - Fork 0
/
images2video.py
executable file
·52 lines (40 loc) · 1.66 KB
/
images2video.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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import logger
log = logging.getLogger(__name__)
import argparse
import math
import os
import shutil
import multivisiontools
def main():
parser = argparse.ArgumentParser(description="Convert set of images into video.", parents=[logger.loggingParser])
parser.add_argument("-i", "--images", nargs="+",
help="Image files.")
parser.add_argument("-o", "--output", default="output.mp4",
help="Output video file. [Default: %(default)s]")
parser.add_argument("-r", "--resolution", nargs=2, default=[1280, 720], type=int,
help="Video resolution. [Default: %(default)s]")
parser.add_argument("-f", "--frame-rate", default=25.0, type=float,
help="Video frame rate. [Default: %(default)s]")
parser.add_argument("-d", "--image-durations", nargs="+", default=[5.0], type=float,
help="Image slide durations in seconds. [Default: %(default)s]")
parser.add_argument("-t", "--transition-times", nargs="+", default=[1.0], type=float,
help="Transition times in seconds. [Default: %(default)s]")
args = parser.parse_args()
logger.initLogger(args)
multivision = multivisiontools.Multivision(
frame_rate = args.frame_rate,
resolution = args.resolution,
video_format = os.path.splitext(args.output)[-1]
)
output = multivision.images_to_video(
args.images,
video_file = args.output,
image_durations = args.image_durations,
transition_times = args.transition_times
)
log.info("Created video in \"%s\" from %d images." % (args.output, len(args.images)))
if __name__ == "__main__":
main()