Skip to main content

Python SDK for the Very Good FFmpeg API

Project description

very-good-ffmpeg

Python SDK for the Very Good FFmpeg API — run FFmpeg jobs in the cloud.

PyPI

Homepage · API Docs · GitHub

Installation

pip install very-good-ffmpeg

Usage

import os
from very_good_ffmpeg import VGF

client = VGF(os.environ["VGFFMPEG_API_KEY"])

# Create a job and wait for it to complete
job = client.run(
    input_files={"input": "https://example.com/input.mp4"},
    output_files=["output.mp4"],
    ffmpeg_commands=["-i {{input}} -vf scale=1280:720 {{output.mp4}}"],
    wait=True,
)

print(job.status)       # "succeeded"
print(job.output_files) # {"output.mp4": "https://..."}

Async is also supported — use arun, jobs.aget, jobs.alist, jobs.acancel, files.aupload, etc.

import asyncio, os
from very_good_ffmpeg import VGF

async def main():
    client = VGF(os.environ["VGFFMPEG_API_KEY"])
    job = await client.arun(
        input_files={"input": "https://example.com/input.mp4"},
        output_files=["output.mp4"],
        ffmpeg_commands=["-i {{input}} -vf scale=1280:720 {{output.mp4}}"],
        wait=True,
    )
    print(job.status)

asyncio.run(main())

Reference

Create a job — client.run(...) / client.arun(...)

Submits an FFmpeg job. Pass wait=True to block until the job reaches a terminal state.

job = client.run(
    input_files={"input": "https://example.com/input.mp4"},
    output_files=["output.mp4"],
    ffmpeg_commands=["-i {{input}} -c:v libx264 {{output.mp4}}"],
    webhook_url="https://example.com/webhook",  # optional
    machine="nvidia",  # optional: "cpu" | "nvidia"
    wait=True,
)

Get a job — client.jobs.get(id) / client.jobs.aget(id)

job = client.jobs.get("job_abc123")
print(job.status)  # "queued" | "running" | "succeeded" | "failed" | "cancelled"

List jobs — client.jobs.list(...) / client.jobs.alist(...)

Returns a JobList with data (list of jobs) and paging_params.

result = client.jobs.list(limit=20, offset=0)
print(result.data)          # list[Job]
print(result.paging_params) # PagingParams(limit=20, offset=0, total=100, has_more=True)

Cancel a job — client.jobs.cancel(id) / client.jobs.acancel(id)

job = client.jobs.cancel("job_abc123")
print(job.status)  # "cancelled"

Poll until done — job.wait(...) / job.async_wait(...)

job = client.run(input_files=..., output_files=..., ffmpeg_commands=...)
job.wait(timeout=120)
print(job.status)

Upload a file — client.files.upload(data, content_type?) / client.files.aupload(...)

Upload bytes or a file path to temporary storage and get back a URL you can use as an input_files value.

with open("input.mp4", "rb") as f:
    download_url = client.files.upload(f.read(), "video/mp4")

job = client.run(
    input_files={"input": download_url},
    output_files=["output.mp4"],
    ffmpeg_commands=["-i {{input}} -vf scale=1280:720 {{output.mp4}}"],
)

Pass a file path directly to have the SDK read it for you:

download_url = client.files.upload("input.mp4")

Prepare upload — client.files.prepare() / client.files.aprepare()

Returns a TmpFile with upload_url and download_url if you need to stream a large file yourself.

tmp = client.files.prepare()
# PUT your file to tmp.upload_url, then use tmp.download_url as input

Examples

See examples/example/main.py for a runnable example covering both sync and async usage.

cd examples/example
pip install -r requirements.txt
VGFFMPEG_API_KEY=your_key python main.py

Support

Open an issue at github.com/verygoodffmpeg/Very-Good-FFmpeg-Python-SDK or email please_help@verygoodffmpeg.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

very_good_ffmpeg-1.0.2.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

very_good_ffmpeg-1.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file very_good_ffmpeg-1.0.2.tar.gz.

File metadata

  • Download URL: very_good_ffmpeg-1.0.2.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.4 HTTPX/0.28.1

File hashes

Hashes for very_good_ffmpeg-1.0.2.tar.gz
Algorithm Hash digest
SHA256 09271d0a3ef9607a201a3baac4d22aaa744c208592e4994604786710fe067b23
MD5 b5bedfdfb8364a7893573ee1506a1266
BLAKE2b-256 8d814f96f260e49d91a8d58efae16007a041aaa8cd32ad5f7a41a31399f81c0b

See more details on using hashes here.

File details

Details for the file very_good_ffmpeg-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: very_good_ffmpeg-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.4 HTTPX/0.28.1

File hashes

Hashes for very_good_ffmpeg-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a035541c9b3c7c5947cebf7a5af550a43380cb97095cee0f7b87bedd5fbc707
MD5 2955ee44bd3aa1831b84afca42bed3a1
BLAKE2b-256 9d9e03846b32e199689b96d93a8dc7bd919a075149702ea313928e3ec7258b40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page