# coding: utf-8
import argparse
import sys
import cv2
from tqdm import tqdm
from ..chaptors import (
Administorator,
MarqueeEditor,
RotatingFaceEditor,
RotatingRectangleEditor,
SmartphoneEditor,
SpreadTileEditor,
TitleCallEditor,
)
from ..utils._path import (
OPENING_TEMPLATE_PATH,
ROTATING_FACE_LEFT_IMAGE_PATH,
ROTATING_FACE_RIGHT_IMAGE_PATH,
ROTATING_SQUARE_IMAGE_PATH,
SMARTPHONE_IMAGE_PATH,
SMARTPHONE_VIDEO_PATH,
)
[docs]def wed_op_create(argv=sys.argv[1:]):
"""Create a Wednesday’s Downtown Opening Video.
Args:
-T/--template (str, optional) : Path to a template video file. Defaults to ``OPENING_TEMPLATE_PATH``.
-O/--out (str, optional) : Path to an output video file. Defaults to ``None``.
--codec (str, optional) : Video Codec for output video. Defaults to ``"H264"``.
-SV/--smartphone-video (str, optional) : Path to a video which will be wrapped by the smartphone frame. Defaults to ``SMARTPHONE_VIDEO_PATH``.
-SI/--smartphone-image (str, optional) : Path to an image which will be wraps a smartphone video. Defaults to ``SMARTPHONE_IMAGE_PATH``.
-SQUARE/--square-image (str, optional) : Path to the rotating square image. Defaults to ``ROTATING_SQUARE_IMAGE_PATH``.
-FL/--face-left-image (str, optional) : Path to the rotating left-face image. Defaults to ``ROTATING_FACE_LEFT_IMAGE_PATH``.
-FR/--face-right-image (str, optional) : Path to the rotating right-face image. Defaults to ``ROTATING_FACE_RIGHT_IMAGE_PATH``.
-MUT/--morquee-upper-text (str, optional) : The upper text for :class:`wed.chaptors.marquee.MarqueeEditor`. Defaults to ``"WEDNESDAY"``.
-MLT/--morquee-lower-text (str, optional) : The lower text for :class:`wed.chaptors.marquee.MarqueeEditor`. Defaults to ``"DOWNTOWN"``.
-TCUT/--title-call-upper-text (str, optional) : The upper text for :class:`wed.chaptors.title_call.TitleCallEditor`. Defaults to ``"水曜日"``.
-TCMT/--title-call-middle-text (str, optional) : The middle text for :class:`wed.chaptors.title_call.TitleCallEditor`. Defaults to ``"の"``.
-TCLT/--title-call-lower-text (str, optional) : The lower text for :class:`wed.chaptors.title_call.TitleCallEditor`. Defaults to ``"ダウンタウン"``.
Note:
When you run from the command line, execute as follows::
$ wed-op-create -T path/to/template-video.mp4 \\
-O path/to/created-video.mp4 \\
--codec H264 \\
-SV path/to/smartphone.mp4 \\
-SI path/to/smartphone.png \\
-SQUARE path/to/rotating-square.png \\
-FL path/to/rotating-face-left.png \\
-FR path/to/rotating-face-right.png \\
-MUT WEDNESDAY \\
-MLT DOWNTOWN \\
-TCUT 水曜日 \\
-TCMT の \\
-TCLT ダウンタウン
"""
parser = argparse.ArgumentParser(prog="wed-op-create", add_help=True)
parser.add_argument(
"-T",
"--template",
type=str,
default=OPENING_TEMPLATE_PATH,
help="Path to a template video file.",
)
parser.add_argument(
"-O",
"--out",
type=str,
help="Path to an output video file.",
)
parser.add_argument(
"--codec",
type=str,
default="H264",
help="Video Codec for output video. Defaults to 'H264'",
)
parser.add_argument(
"-SV",
"--smartphone-video",
type=str,
default=SMARTPHONE_VIDEO_PATH,
help="Path to the video which will be wrapped by the smartphone frame. Defaults to SMARTPHONE_VIDEO_PATH",
)
parser.add_argument(
"-SI",
"--smartphone-image",
type=str,
default=SMARTPHONE_IMAGE_PATH,
help="Path to the image which will be wraps the smartphone video. Defaults to SMARTPHONE_IMAGE_PATH",
)
parser.add_argument(
"-SQUARE",
"--square-image",
type=str,
default=ROTATING_SQUARE_IMAGE_PATH,
help="Path to the rotating square image. Defaults to ROTATING_SQUARE_IMAGE_PATH",
)
parser.add_argument(
"-FL",
"--face-left-image",
type=str,
default=ROTATING_FACE_LEFT_IMAGE_PATH,
help="Path to the rotating left-face image. Defaults to ROTATING_FACE_LEFT_IMAGE_PATH",
)
parser.add_argument(
"-FR",
"--face-right-image",
type=str,
default=ROTATING_FACE_RIGHT_IMAGE_PATH,
help="Path to the rotating right-face image. Defaults to ROTATING_FACE_RIGHT_IMAGE_PATH",
)
parser.add_argument(
"-MUT",
"--morquee-upper-text",
type=str,
default="WEDNESDAY",
help="Upper text for Morquee Editor.",
)
parser.add_argument(
"-MLT",
"--morquee-lower-text",
type=str,
default="DOWNTOWN",
help="Lower text for Morquee Editor.",
)
parser.add_argument(
"-TCUT",
"--title-call-upper-text",
type=str,
default="水曜日",
help="Upper text for Title Call.",
)
parser.add_argument(
"-TCMT",
"--title-call-middle-text",
type=str,
default="の",
help="Middle text for Title Call.",
)
parser.add_argument(
"-TCLT",
"--title-call-lower-text",
type=str,
default="ダウンタウン",
help="Lower text for Title Call.",
)
args = parser.parse_args(argv)
administrator = Administorator(video_path=args.template)
administrator.append(
SmartphoneEditor(
video_path=args.smartphone_video,
image_path=args.smartphone_image,
)
)
administrator.append(RotatingRectangleEditor(square_image_path=args.square_image))
administrator.append(
MarqueeEditor(
upper_text=args.morquee_upper_text, lower_text=args.morquee_lower_text
)
)
administrator.append(SpreadTileEditor())
administrator.append(
RotatingFaceEditor(
face_left_image_path=args.face_left_image,
face_right_image_path=args.face_right_image,
)
)
administrator.append(
TitleCallEditor(
upper_text=args.title_call_upper_text,
middle_text=args.title_call_middle_text,
lower_text=args.title_call_lower_text,
)
)
out_path = administrator.export(out_path=args.out, codec=args.codec)