2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

画像と音声から動画をつくーる(Python)

Posted at

はじめに

がちもとさんアドベントカレンダー5日目の記事です。
今日は、画像と音声から動画を作成するプログラムを作りました。

開発環境

  • Windows 11 PC
  • Python 3.11

導入

image2movie.py
from moviepy.editor import *

# 画像ファイルの読み込み
image = ImageClip('slide.jpg')

# mp3音声ファイルの読み込み
audio = AudioFileClip('speech.mp3')

# 動画の長さを音声に合わせる
video = image.set_duration(audio.duration)

# 動画に音声を合成する
video = video.set_audio(audio)

# 動画を保存する
video.write_videofile('output.mp4', codec='libx264', fps=30)

実行結果

これでスライドとテキストを用意して、昨日のOpenAIでテキストから音声合成すれば、プレゼン用の動画もできちゃいますね!

お疲れさまでした。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?