Minimal video generation and processing library.
Project description
About
Minimal video generation and processing library.
Setup
Install ffmpeg
# Install with brew for MacOS:
brew install ffmpeg
# Install with apt-get for Ubuntu:
sudo apt-get install ffmpeg
Install with pip
pip install videopython[generation]
You can install without
[generation]
dependencies for basic video handling and processing. The funcionalities found invideopython.generation
won't work.
Basic Usage
Video handling
from videopython.base.video import Video
# Load videos and print metadata
video1 = Video.from_path("tests/test_data/fast_benchmark.mp4")
print(video1)
video2 = Video.from_path("tests/test_data/slow_benchmark.mp4")
print(video2)
# Define the transformations
from videopython.base.transforms import CutSeconds, ResampleFPS, Resize, TransformationPipeline
pipeline = TransformationPipeline(
[CutSeconds(start=1.5, end=6.5), ResampleFPS(fps=30), Resize(width=1000, height=1000)]
)
video1 = pipeline.run(video1)
video2 = pipeline.run(video2)
# Combine videos, add audio and save
from videopython.base.transitions import FadeTransition
fade = FadeTransition(effect_time_seconds=3.0)
video = fade.apply(videos=(video1, video2))
video.add_audio_from_file("tests/test_data/test_audio.mp3")
savepath = video.save()
Video Generation
Using Nvidia A40 or better is recommended for the
videopython.generation
module.
# Generate image and animate it
from videopython.generation import ImageToVideo
from videopython.generation import TextToImage
image = TextToImage().generate_image(prompt="Golden Retriever playing in the park")
video = ImageToVideo().generate_video(image=image, fps=24)
# Video generation directly from prompt
from videopython.generation import TextToVideo
video_gen = TextToVideo()
video = video_gen.generate_video("Dogs playing in the snow")
for _ in range(10):
video += video_gen.generate_video("Dogs playing in the snow")
# Cut the first 2 seconds
from videopython.base.transforms import CutSeconds
transformed_video = CutSeconds(start_second=0, end_second=2).apply(video.copy())
# Upsample to 30 FPS
from videopython.base.transforms import ResampleFPS
transformed_video = ResampleFPS(new_fps=30).apply(transformed_video)
# Resize to 1000x1000
from videopython.base.transforms import Resize
transformed_video = Resize(width=1000, height=1000).apply(transformed_video)
filepath = transformed_video.save()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
videopython-0.2.0.tar.gz
(28.0 kB
view hashes)
Built Distribution
Close
Hashes for videopython-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d19d64fe5319fd35b7dc972faaabadb06752a487b1ec31057e76c3b752819ab |
|
MD5 | 193116dd0313e80ae207768216355512 |
|
BLAKE2b-256 | c07f8c6f3f41de15e60daa8cddc2f960a3a02cc014188782bad822c12a025562 |