Skip to main content

Official Python SDK for the ConvertIntoMP4 file conversion API

Project description

ConvertIntoMP4 Python SDK

Official Python SDK for the ConvertIntoMP4 file conversion API.

Installation

pip install convertintomp4

Requirements

  • Python 3.8+
  • requests library

Quick Start

from convertintomp4 import Client

client = Client(api_key="your-api-key")

# Quick convert a file
with open("video.mp4", "rb") as f:
    result = client.convert(f, "webm")
    print(f"Job ID: {result['jobId']}")

Configuration

client = Client(
    api_key="your-api-key",
    base_url="https://api.convertintomp4.com/v1",  # default
    sandbox=False,  # set to True for sandbox
    timeout=30,     # request timeout in seconds
)

Usage

Job-Based Conversion

job = client.create_job({
    "tasks": {
        "import-file": {
            "operation": "import/url",
            "url": "https://example.com/video.mp4",
        },
        "convert": {
            "operation": "convert",
            "input": "import-file",
            "output_format": "webm",
            "options": {"quality": "high"},
        },
        "export": {
            "operation": "export/url",
            "input": "convert",
        },
    }
})

# Wait for completion
completed = client.wait_for_job(job.id, interval=2.0, timeout=120.0)
print(f"Status: {completed.status}")

Import from URL

result = client.import_from_url(
    "https://example.com/video.mp4",
    target_format="webm",
    quality="high",
)

Manage Jobs

# List jobs
result = client.list_jobs(status="completed", limit=10)
for job in result["data"]:
    print(f"{job.id}: {job.status}")

# Get job details
job = client.get_job("job_abc123")

# Delete a job
client.delete_job("job_abc123")

# Cancel / retry
client.cancel_job("job_abc123")
client.retry_job("job_abc123")

Download Converted File

data = client.download_file("job_abc123")
with open("output.webm", "wb") as f:
    f.write(data)

Formats

formats = client.list_formats(category="video")
options = client.get_format_options("mp4", "webm")

Webhooks

webhook = client.create_webhook(
    url="https://your-app.com/webhook",
    events=["job.completed", "job.failed"],
    secret="your-secret",
)

webhooks = client.list_webhooks()
client.delete_webhook(webhook.id)

PDF Operations

# OCR
result = client.pdf_ocr("https://example.com/scan.pdf", language="eng")

# Split
parts = client.pdf_split("https://example.com/doc.pdf", ranges=["1-3", "4-6"])

# Merge
merged = client.pdf_merge(["https://example.com/a.pdf", "https://example.com/b.pdf"])

# Encrypt / Decrypt
client.pdf_encrypt("https://example.com/doc.pdf", password="secret")
client.pdf_decrypt("https://example.com/doc.pdf", password="secret")

# Compress
client.pdf_compress("https://example.com/doc.pdf")

# Watermark
client.pdf_watermark("https://example.com/doc.pdf", text="DRAFT", opacity=0.3)

# Extract pages
client.pdf_extract_pages("https://example.com/doc.pdf", pages=[1, 3, 5])

# Rotate
client.pdf_rotate("https://example.com/doc.pdf", angle=90, pages=[2, 4])

# Convert to PDF/A
client.pdf_to_pdfa("https://example.com/doc.pdf")

Error Handling

from convertintomp4 import (
    Client,
    ApiError,
    AuthenticationError,
    RateLimitError,
    TimeoutError,
)

try:
    job = client.get_job("invalid-id")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except TimeoutError:
    print("Request timed out")
except ApiError as e:
    print(f"API error {e.status_code}: {e.code} - {e.message}")

Context Manager

The client can be used as a context manager to ensure the HTTP session is properly closed:

with Client(api_key="your-api-key") as client:
    job = client.create_job(...)

License

MIT

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

convertintomp4-1.0.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

convertintomp4-1.0.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file convertintomp4-1.0.0.tar.gz.

File metadata

  • Download URL: convertintomp4-1.0.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for convertintomp4-1.0.0.tar.gz
Algorithm Hash digest
SHA256 76143d17dbeaad1f204593b3171367af9933138b99fa6a717606e28ba49e5786
MD5 c3273db448431a3315ad0b896dde2b81
BLAKE2b-256 ce85fe62759201e55c83a5ee21e994d8bfce9877d2c374ed0697d68bff6d2c42

See more details on using hashes here.

File details

Details for the file convertintomp4-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: convertintomp4-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for convertintomp4-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f4ac729a47ef95af4c80deffabee63f96940a4c994b7607b03f16a33c8bdee7
MD5 61f8f5bf392bcf5c2e45d7ba0b85216a
BLAKE2b-256 e5b2c64a6f4d8428ffb02b4f8a30397568c8344234809070676e763cdb4cd03c

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