README.md

# bigfoot-video-generator

A robust Elixir library for generating dynamic video content. Simplifies the process of programmatically creating videos from templates, data, and assets.

## Installation

Add `bigfoot_video_generator` to your list of dependencies in `mix.exs`:
elixir
def deps do
  [
    {:bigfoot_video_generator, "~> 0.1.0"}
  ]
end

Then, run `mix deps.get` to fetch the dependency.

## Usage Examples

This library provides a streamlined approach to video generation. Here are a few examples:

**1. Simple Video Creation from a Template:**
elixir
alias BigfootVideoGenerator.Video

template_path = "path/to/your/template.aep"
output_path = "path/to/output/video.mp4"

{:ok, video} =
  Video.create(template_path, output_path)
  |> Video.render()

case video do
  {:ok, %{status: "completed"}} ->
    IO.puts("Video generation successful!")

  {:error, reason} ->
    IO.puts("Video generation failed: #{reason}")
end

**2. Dynamic Data Injection into a Template:**
elixir
alias BigfootVideoGenerator.Video

template_path = "path/to/your/template.aep"
output_path = "path/to/output/video.mp4"

data = %{
  title: "Elixir Rocks!",
  subtitle: "A Video Generated with Bigfoot"
}

{:ok, video} =
  Video.create(template_path, output_path, data)
  |> Video.render()

case video do
  {:ok, %{status: "completed"}} ->
    IO.puts("Video generation successful with dynamic data!")

  {:error, reason} ->
    IO.puts("Video generation failed: #{reason}")
end

**3. Asynchronous Video Rendering:**
elixir
alias BigfootVideoGenerator.Video

template_path = "path/to/your/template.aep"
output_path = "path/to/output/video.mp4"

{:ok, job_id} =
  Video.create(template_path, output_path)
  |> Video.render_async()

IO.puts("Video rendering started asynchronously with job ID: #{job_id}")

# Later, check the status of the job:
case Video.job_status(job_id) do
  {:ok, %{status: "completed", output_path: path}} ->
    IO.puts("Video completed at: #{path}")
  {:ok, %{status: "pending"}} ->
    IO.puts("Video still rendering...")
  {:error, reason} ->
    IO.puts("Error checking job status: #{reason}")
end

**4. Handling Complex Data Structures:**
elixir
alias BigfootVideoGenerator.Video

template_path = "path/to/your/template.aep"
output_path = "path/to/output/video.mp4"

data = %{
  profile: %{
    name: "Alice",
    age: 30
  },
  products: [
    %{name: "Product A", price: 10},
    %{name: "Product B", price: 20}
  ]
}

{:ok, video} =
  Video.create(template_path, output_path, data)
  |> Video.render()

# ... (error handling as above)

**5. Using with Supervisor Strategy**
elixir
defmodule MyVideoWorker do
  use GenServer

  def start_link(args) do
    GenServer.start_link(__MODULE__, args, name: __MODULE__)
  end

  def init(args) do
    {:ok, args}
  end

  def handle_info(:render, state) do
    template_path = Keyword.get(state, :template_path)
    output_path = Keyword.get(state, :output_path)
    data = Keyword.get(state, :data, %{})

    case BigfootVideoGenerator.Video.create(template_path, output_path, data) |> BigfootVideoGenerator.Video.render() do
      {:ok, _} ->
        Logger.info("Video rendered successfully!")
      {:error, reason} ->
        Logger.error("Video rendering failed: #{reason}")
    end
    {:noreply, state}
  end

  def render_video(template_path, output_path, data \\ %{}) do
    GenServer.cast(__MODULE__, :render)
  end
end

# inside your supervisor
children = [
  worker(MyVideoWorker, template_path: "...", output_path: "...")
]

## Feature Summary

*   **Template-Based Generation:** Generate videos using pre-designed templates.
*   **Dynamic Data Injection:** Inject data from your Elixir application into video templates.
*   **Asynchronous Rendering:** Queue video generation jobs for background processing.
*   **Error Handling:** Provides clear error messages for debugging.
*   **Flexible Data Support:** Handles various data structures including maps and lists.
*   **Job Status Tracking:** Monitor the status of asynchronous rendering jobs.

## License

MIT

This package is part of the bigfoot-video-generator ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/video/bigfoot-video-generator/