video2pptx プログラム仕様

概要:

MP4等の動画から定期的または操作後の安定画面のスクリーンショットを作成し、PowerPointに貼り付けます。

詳細説明:

ffmpegおよびffprobeがシステムのPATHに存在し、Pillowとpython-pptxがインストールされている必要があります。

video2pptx.add_image_fit(slide, image_path: Path, left, top, width, height) → None
概要:

指定された領域に収まるように画像をスライドに追加します。

引数:
param slide:

画像を追加するスライドオブジェクト

type slide:

pptx.slide.Slide

param image_path:

追加する画像ファイルのパス

type image_path:

Path

param left:

領域の左端位置

type left:

int または float

param top:

領域の上端位置

type top:

int または float

param width:

領域の幅

type width:

int または float

param height:

領域の高さ

type height:

int または float

戻り値:
returns:

なし

rtype:

None

video2pptx.add_textbox(slide, text: str, left, top, width, height, size: int, color, bold=False, align=None)
概要:

スライドにテキストボックスを追加します。

引数:
param slide:

テキストボックスを追加するスライドオブジェクト

type slide:

pptx.slide.Slide

param text:

表示するテキスト

type text:

str

param left:

左端の位置

type left:

int または float

param top:

上端の位置

type top:

int または float

param width:

幅

type width:

int または float

param height:

高さ

type height:

int または float

param size:

フォントサイズ

type size:

int

param color:

RGBカラーのタプル

type color:

tuple

param bold:

太字にするかどうか

type bold:

bool

param align:

テキストの配置

type align:

PP_ALIGN

戻り値:
returns:

作成されたテキストボックスのシェイプオブジェクト

rtype:

pptx.shapes.autoshape.Shape

video2pptx.extract_analysis_frames(video: Path, destination: Path, start: float, end: float, sample_fps: float) → list[Path]
概要:

動き解析用に使用する低解像度フレームを抽出します。

引数:
param video:

動画ファイルのパス

type video:

Path

param destination:

保存先ディレクトリのパス

type destination:

Path

param start:

抽出開始時刻

type start:

float

param end:

抽出終了時刻

type end:

float

param sample_fps:

抽出のサンプリングfps

type sample_fps:

float

戻り値:
returns:

抽出された画像パスのリスト

rtype:

list[Path]

video2pptx.extract_frame(video: Path, at: float, destination: Path, max_width: int) → None
概要:

動画から指定時刻のフレームを抽出し画像として保存します。

引数:
param video:

動画ファイルのパス

type video:

Path

param at:

抽出する時刻

type at:

float

param destination:

保存先ファイルのパス

type destination:

Path

param max_width:

画像の最大幅

type max_width:

int

戻り値:
returns:

なし

rtype:

None

video2pptx.main() → None
概要:

動画からスクリーンショットを抽出してPowerPoint資料を作成するメイン処理です。

引数:

なし

戻り値:
returns:

なし

rtype:

None

video2pptx.make_slide(prs: Presentation, entries: list[tuple[float, Path]], page: int) → None
概要:

抽出した画像と時刻を配置したスライドを作成します。

引数:
param prs:

プレゼンテーションオブジェクト

type prs:

Presentation

param entries:

時刻と画像パスのタプルのリスト

type entries:

list

param page:

スライド番号

type page:

int

戻り値:
returns:

なし

rtype:

None

video2pptx.mean_frame_difference(before: Path, after: Path) → float
概要:

2つの画像間の平均絶対グレースケール差分をフルスケールのパーセントとして計算します。

引数:
param before:

比較元画像ファイルのパス

type before:

Path

param after:

比較先画像ファイルのパス

type after:

Path

戻り値:
returns:

差分のパーセンテージ

rtype:

float

video2pptx.motion_times(video: Path, temp_dir: Path, start: float, end: float, args: Namespace) → list[float]
概要:

低解像度フレームの変化から操作後の安定画面の時刻リストを検出します。

引数:
param video:

動画ファイルのパス

type video:

Path

param temp_dir:

作業用ディレクトリのパス

type temp_dir:

Path

param start:

検出開始時刻

type start:

float

param end:

検出終了時刻

type end:

float

param args:

コマンドライン引数を格納したNamespace

type args:

argparse.Namespace

戻り値:
returns:

検出された時刻のリスト

rtype:

list[float]

video2pptx.parse_args() → Namespace
概要:

コマンドライン引数をパースします。

引数:

なし

戻り値:
returns:

パース結果を格納したNamespaceオブジェクト

rtype:

argparse.Namespace

video2pptx.require_command(name: str) → None
概要:

コマンドがシステムに存在するか確認します。

引数:
param name:

確認するコマンド名

type name:

str

戻り値:
returns:

なし

rtype:

None

例外:
raises RuntimeError:

コマンドが見つからない場合

video2pptx.run(command: list[str]) → str
概要:

外部コマンドを実行し標準出力を取得します。

引数:
param command:

実行するコマンドのリスト

type command:

list[str]

戻り値:
returns:

コマンドの標準出力文字列

rtype:

str

video2pptx.timestamp(seconds: float) → str
概要:

秒数を HH:MM:SS 形式の文字列に変換します。

引数:
param seconds:

秒数

type seconds:

float

戻り値:
returns:

フォーマットされた時間文字列

rtype:

str

video2pptx.video_duration(video: Path) → float
概要:

動画の長さを秒単位で取得します。

引数:
param video:

動画ファイルのパス

type video:

Path

戻り値:
returns:

動画の長さ

rtype:

float