videostudio
Video Studio is a versatile video and audio processing package designed for creating, editing, and managing multimedia content. It leverages popular libraries such as MoviePy, Pydub, NumPy, and Scipy to provide powerful tools for handling audio and video files.
Features
- Video Editing: Combine videos, add transitions, overlay text, and more.
- Audio Processing: Trim, concatenate, fade in/out, and manipulate audio files.
- Speech Recognition: Convert speech to text using speech recognition.
- Image Processing: Overlay text on images and create dynamic visual content.
- Random File Selection: Automatically select random files from directories for processing.
Installation
You can install Video Studio from PyPI:
pip install videostudio
Simple Static Example
This example demonstrates how to create a simple video with static assets.
from videostudio.canvas import Canvas
from videostudio.elements import StaticAsset
canvas = Canvas(width=1080, height=1920, color=(255, 255, 255))
static_asset1 = StaticAsset(canvas, folder_path='examples/assets/video.mp4', position=('center', 'center'), start_time=0, duration=3)
static_asset2 = StaticAsset(canvas, folder_path='examples/assets/image.jpg', position=('center', 'center'), start_time=3, duration=3)
canvas.render(output_path='examples/1-simple-static/output.mp4')
Simple Transition Example
This example demonstrates how to add a simple transition between two static assets.
from videostudio.canvas import Canvas
from videostudio.elements import StaticAsset, Audio
from videostudio.transitions import Transition
canvas = Canvas(width=1080, height=1920, color=(255, 255, 255))
static_asset1 = StaticAsset(canvas, folder_path='examples/assets/video.mp4', position=('center', 'center'), start_time=0, duration=3)
static_asset2 = StaticAsset(canvas, folder_path='examples/assets/image.jpg', position=('center', 'center'), start_time=3, duration=2)
transition = Transition(canvas, static_asset1, static_asset2, effect='crossfade', duration=0.5)
canvas.render(output_path='examples/2-simple-transition/output.mp4')
Simple Audio Example
This example demonstrates how to create a simple video with static assets, transitions, and audio.
from videostudio.canvas import Canvas
from videostudio.elements import StaticAsset, Audio
from videostudio.transitions import Transition
canvas = Canvas(width=1080, height=1920, color=(255, 255, 255))
static_asset1 = StaticAsset(canvas, folder_path='examples/assets/video.mp4', position=('center', 'center'), start_time=0, duration=3)
static_asset2 = StaticAsset(canvas, folder_path='examples/assets/image.jpg', position=('center', 'center'), start_time=3, duration=3)
transition = Transition(canvas, static_asset1, static_asset2, effect='crossfade', duration=0.5)
audio_1 = Audio(canvas, folder_path='examples/assets/audio.wav', start_asset=static_asset1, end_asset=static_asset2, fade_in_duration=1, fade_out_duration=1)
canvas.render(output_path='examples/3-simple-audio/output.mp4')
Audio Fade Example
This example demonstrates how to create a simple video with static assets, transitions, audio, and audio fades.
from videostudio.canvas import Canvas
from videostudio.elements import StaticAsset, Audio
from videostudio.transitions import Transition
canvas = Canvas(width=1080, height=1920, color=(255, 255, 255))
static_asset1 = StaticAsset(canvas, folder_path='examples/assets', position=('center', 'center'), start_time=0, duration=3)
static_asset2 = StaticAsset(canvas, folder_path='examples/assets', position=('center', 'center'), start_time=3, duration=3)
transition = Transition(canvas, static_asset1, static_asset2, effect='crossfade', duration=0.5)
audio_1 = Audio(canvas, folder_path='examples/assets/audio.wav', start_asset=static_asset1, end_asset=static_asset2, fade_in_duration=2, fade_out_duration=2)
canvas.render(output_path='examples/4-audio-fade/output.mp4')
Asset Pool Example
This example demonstrates how to create a simple video with static assets, transitions, audio, and audio fades.
from videostudio.canvas import Canvas
from videostudio.elements import StaticAsset, Audio
from videostudio.transitions import Transition
canvas = Canvas(width=1080, height=1920, color=(255, 255, 255))
static_asset1 = StaticAsset(canvas, folder_path='examples/assets', position=('center', 'center'), start_time=0, duration=2)
static_asset2 = StaticAsset(canvas, folder_path='examples/assets', position=('center', 'center'), start_time=2, duration=1)
static_asset3 = StaticAsset(canvas, folder_path='examples/assets', position=('center', 'center'), start_time=3, duration=2)
transition = Transition(canvas, static_asset1, static_asset2, effect='crossfade', duration=0.5)
transition = Transition(canvas, static_asset2, static_asset3, effect='crossfade', duration=0.5)
audio_1 = Audio(canvas, folder_path='examples/assets/audio.wav', start_asset=static_asset1, end_asset=static_asset3, fade_in_duration=2, fade_out_duration=2)
canvas.render(output_path='examples/5-asset-pool/output4.mp4')
Audio Pool Example
This example demonstrates how to create a simple video from a pool of static assets with audio.
from videostudio.canvas import Canvas
from videostudio.elements import StaticAsset, Audio
from videostudio.transitions import Transition
canvas = Canvas(width=1080, height=1920, color=(255, 255, 255))
static_asset1 = StaticAsset(canvas, folder_path='examples/assets', position=('center', 'center'), start_time=0, duration=2)
static_asset2 = StaticAsset(canvas, folder_path='examples/assets', position=('center', 'center'), start_time=2, duration=1)
static_asset3 = StaticAsset(canvas, folder_path='examples/assets', position=('center', 'center'), start_time=3, duration=2)
transition = Transition(canvas, static_asset1, static_asset2, effect='crossfade', duration=0.5)
transition = Transition(canvas, static_asset2, static_asset3, effect='crossfade', duration=0.5)
audio_1 = Audio(canvas, folder_path='examples/assets', start_asset=static_asset1, end_asset=static_asset3, fade_in_duration=2, fade_out_duration=2)
canvas.render(output_path='examples/6-audio-pool/output3.mp4')
Smart Audio Example
This example demonstrates how to create a simple video and match the transitions with the audio.
from videostudio.canvas import Canvas
from videostudio.elements import StaticAsset, Audio
from videostudio.transitions import Transition
from videostudio.audio_analyzer import find_top_peaks, find_random_audio
canvas = Canvas(width=1080, height=1920, color=(255, 255, 255))
assets_folder = 'examples/assets'
random_audio = find_random_audio(assets_folder)
audio_peaks = find_top_peaks(random_audio, num_peaks_to_select=3, min_distance_sec=1)
peak1 = audio_peaks[0]
peak2 = audio_peaks[1]
peak3 = audio_peaks[2]
static_asset1 = StaticAsset(canvas, folder_path=assets_folder, position=('center', 'center'), start_time=0, duration=peak1)
static_asset2 = StaticAsset(canvas, folder_path=assets_folder, position=('center', 'center'), start_time=peak1, duration=peak2)
static_asset3 = StaticAsset(canvas, folder_path=assets_folder, position=('center', 'center'), start_time=peak2, duration=peak3)
transition = Transition(canvas, static_asset1, static_asset2, effect='crossfade', duration=0.5)
transition = Transition(canvas, static_asset2, static_asset3, effect='crossfade', duration=0.5)
audio_1 = Audio(canvas, folder_path=random_audio, start_asset=static_asset1, end_asset=static_asset3, fade_in_duration=2, fade_out_duration=2)
canvas.render(output_path='examples/7-smart-audio/output.mp4')
More coming soon...