grok-video-generator
A powerful Elixir library for programmatically generating videos from various data sources and media assets. Simplifies the creation of dynamic video content within Elixir applications.
Installation
Add grok_video_generator to your list of dependencies in mix.exs:
elixir
def deps do
[
{:grok_video_generator, "~> 0.1.0"}] end
Then, run mix deps.get to fetch the dependencies.
Usage
Here are some idiomatic Elixir examples demonstrating how to use grok_video_generator.
1. Creating a simple video from images: elixir alias GrokVideoGenerator.Video
image_paths = ["path/to/image1.jpg", "path/to/image2.png", "path/to/image3.jpeg"]
= Video.create(image_paths) |> Video.with_duration(5) # Each image displayed for 5 seconds |> Video.with_output_path("output/simple_video.mp4") |> Video.render()
IO.puts("Simple video created at: #{video_path}")
2. Adding text overlays to a video: elixir alias GrokVideoGenerator.Video alias GrokVideoGenerator.Overlay
video_path = "input/existing_video.mp4"
= Video.load(video_path) |> Video.add_overlay(Overlay.text("Hello Elixir!", x: 100, y: 100, font_size: 32)) |> Video.with_output_path("output/video_with_text.mp4") |> Video.render()
IO.puts("Video with text overlay created at: #{video_path}")
3. Combining audio with a video: elixir alias GrokVideoGenerator.Video
video_path = "input/silent_video.mp4" audio_path = "input/background_music.mp3"
= Video.load(video_path) |> Video.add_audio(audio_path) |> Video.with_output_path("output/video_with_audio.mp4") |> Video.render()
IO.puts("Video with audio created at: #{video_path}")
4. Cropping and resizing a video: elixir alias GrokVideoGenerator.Video
video_path = "input/large_video.mp4"
= Video.load(video_path) |> Video.crop(x: 100, y: 50, width: 640, height: 480) |> Video.resize(width: 320, height: 240) |> Video.with_output_path("output/cropped_resized_video.mp4") |> Video.render()
IO.puts("Cropped and resized video created at: #{video_path}")
5. Generating a video from a list of slides with transitions: elixir alias GrokVideoGenerator.Video alias GrokVideoGenerator.Slide alias GrokVideoGenerator.Transition
slides = [ Slide.image("path/to/slide1.jpg", duration: 5), Slide.image("path/to/slide2.png", duration: 3), Slide.image("path/to/slide3.jpeg", duration: 7) ]
= Video.create(slides) |> Video.with_transition(Transition.fade(duration: 1)) |> Video.with_output_path("output/slideshow_video.mp4") |> Video.render()
IO.puts("Slideshow video created at: #{video_path}")
Feature Summary
- Video Creation: Generate videos from images, audio, and other video files.
- Overlay Support: Add text, images, and other visual elements as overlays.
- Audio Integration: Seamlessly combine audio tracks with video content.
- Video Manipulation: Crop, resize, and apply various transformations to videos.
- Slide Management: Create videos from a sequence of slides with customizable durations and transitions.
- Simple API: Provides an easy-to-use and composable API for building complex video generation workflows.
License
MIT
This package is part of the grok-video-generator ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/blog/grok-ai-video-generator-the-ultimate-guide-to-creating-ai-videos-2025/