Skip to main content

Contentor Video Processor

A Django app for programmatically creating different video resolutions, compressing videos, and reducing storage and bandwidth costs without sacrificing quality. Reduce video sizes dramatically (e.g., from 1GB to 100MB) while maintaining visual quality.

Preview

Below are screenshots that demonstrate the key features and interfaces of the Contentor Video Processor Demo:

The video uploaded with chunks to prevent timeout or memory leak Video Upload Interface

Contentor dashboard for realtime monitoring Results Dashboard

Status Table in the beginning admin panel Status Table

Status Table after complete in the admin panel Status Table

Built-in player with resolution settings Video Player

Features

  • Chunk upload support for large video files (10GB+ files can be uploaded with proper settings)
  • Automatic video compression and resolution conversion
  • Support for multiple video resolutions (original, 720p, 480p, 360p)
  • S3-compatible storage integration
  • Chunked file uploads for large video files
  • Webhook notifications for processing status updates
  • Easy integration with your existing Django models

🧪 Have a Look at the Demo Repo

Curious to see how it works in action? Check out the Demo Repository for a fully functional example.

Perfect for testing, learning, or using as a starting point for your own project.

Installation

pip install django-contentor-video-processor

Quick Start

1. Add to INSTALLED_APPS and Context Processors

Add contentor_video_processor to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    # ...
    'contentor_video_processor',
    # ...
]

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [BASE_DIR / "templates"],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                ...,
                "contentor_video_processor.context_processor.video_resolutions",
                ...,
            ],
        },
    },
]

2. Configure Settings

Add the following to your settings.py:

# STORAGE SETTINGS
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY")
AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_BUCKET_NAME")
AWS_S3_ENDPOINT_URL = os.getenv("AWS_ENDPOINT")

AWS_LOCATION = "customers/your-org/media"

# Remove hardcoded `MEDIA_URL` if you want signed URLs
AWS_DEFAULT_ACL = None
AWS_QUERYSTRING_AUTH = True  # Enable signed URLs
AWS_S3_FILE_OVERWRITE = True
AWS_S3_OBJECT_PARAMETERS = {
    "CacheControl": "max-age=3600",  # Cache for 1 hour
}

ADMIN_RESUMABLE_CHUNK_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
ADMIN_RESUMABLE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
ADMIN_RESUMABLE_CHUNKSIZE = 52428800  # 50MB matching chunk size

# Contentor API credentials (get your free API key at https://contentor.app)
CONTENTOR_VIDEO_PROCESSING_ACCESS_KEY = os.getenv("CONTENTOR_VIDEO_PROCESSING_ACCESS_KEY", "")
CONTENTOR_VIDEO_PROCESSING_ACCESS_TOKEN = os.getenv("CONTENTOR_VIDEO_PROCESSING_ACCESS_TOKEN", "")

# Your application's base URL (needed for webhook notifications)
BASE_URL = "https://your-app-url.com"

# The app and model that will contain your videos
CONTENTOR_VIDEO_MODEL = "your_app.Video"
CONTENTOR_VIDEO_PROCESSING_REQUESTS_APP = "your_app"
CONTENTOR_PROCESSING_REQUEST_MODEL_VERBOSE_NAME = "Video Processing Request"
CONTENTOR_PROCESSING_REQUEST_MODEL_VERBOSE_NAME_PLURAL = "Video Processing Requests"
CONTENTOR_VIDEO_RESOLUTIONS = ["original", "720p", "480p", "360p"]
CONTENTOR_ORIGINAL_RESOLUTION = "1080p"

# Additional configuration options
CONTENTOR_VIDEO_PROCESSING_CONFIG = {
    # contentor settings
    "api_url": "https://process.contentor.app/api/process-video/",
    "download_provider": "minio",
    "upload_provider": "minio",
    "original_resolution": "1080p",
    "resolutions": ["original", "720p", "480p", "360p"],

    # video quality settings
    "crf": "30",                # Compression quality (lower = better quality, higher file size)
    "preset": "ultrafast",      # Encoding speed preset
    "optimise_for_web": True,
    "output_file_format": "mp4" # Output format
}

3. Update URLs

Add the Contentor Video Processor URLs to your main urls.py:

from django.urls import include, path

urlpatterns = [
    # ...
    path("contentor-video/", include("contentor_video_processor.urls")),
    # ...
]

4. Integrate with Your Models

Inherit from ContentorVideoModel and add a ContentorVideoField to your model:

from django.db import models
from contentor_video_processor.models import ContentorVideoModel
from contentor_video_processor.models import ContentorVideoField

class Video(ContentorVideoModel):
    title = models.CharField(max_length=255)
    description = models.TextField(blank=True)
    
    # This field will store your video and handle processing
    video = ContentorVideoField(
        null=True,
        blank=True,
        upload_to="videos/original/",
    )
    
    # Add any other fields you need

5. Run Migrations

python manage.py makemigrations
python manage.py migrate

6. Collect Static Files

Ensure that STATICFILES_FINDERS includes AppDirectoriesFinder:

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

Then run:

python manage.py collectstatic

7. Use the Video Template

In your templates, use the provided video element to display your videos with all available resolutions:

{% include "contentor_video_processor/video_element.html" with video=your_video_object %}

Server Configuration

Nginx Configuration for Large File Uploads

When handling large video files, you may need to adjust your server timeout settings to avoid upload timeouts. Here's an example Nginx configuration:

location /contentor-video/upload {
    proxy_pass http://app:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    proxy_connect_timeout 300;
    proxy_send_timeout    300;
    proxy_read_timeout    300;
    send_timeout          300;
}

Advanced Usage

Customizing Video Processing Options

You can customize the video processing options by modifying the CONTENTOR_VIDEO_PROCESSING_CONFIG in your settings:

CONTENTOR_VIDEO_PROCESSING_CONFIG = {
    # ...
    "crf": "23",            # Better quality but larger file size
    "preset": "medium",     # Balance between encoding speed and compression
    # ...
}

Webhook Notifications

The app can send notifications when video processing is complete. To enable this, make sure you have set either:

  • The BASE_URL setting, which will construct a webhook URL automatically
  • A hardcoded webhook URL in your configuration

Troubleshooting

Upload Issues

  • If you're experiencing timeouts during large file uploads, increase the timeout settings in your web server configuration.
  • Ensure your S3-compatible storage is properly configured with the correct credentials.

Processing Issues

  • Verify that your Contentor API credentials are correct.
  • Check the Contentor dashboard for processing status and error messages.
  • Ensure your webhook URL is accessible from the internet if you're expecting status updates.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

[License information] This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for django-contentor-video-processor 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-contentor-video-processor 0.9.2
File Size Uploaded Provenance
django_contentor_video_processor-0.9.2.tar.gz 37.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-contentor-video-processor 0.9.2
File Interpreter ABI Platform
django_contentor_video_processor-0.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 77.5 kB

Release files / django_contentor_video_processor-0.9.2.tar.gz

Download URL django_contentor_video_processor-0.9.2.tar.gz
Size 37.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c0da2e7863a091374ba3def9ff843d8f6c98279a765271c2ab76ad76e223e6b3
BLAKE2b-256 checksum
How to use checksums
0d6e2ef55168add21eb1aaf76937bd2d8fb631a1637dd04cc14b3881c1f1f708
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / django_contentor_video_processor-0.9.2-py3-none-any.whl

Download URL django_contentor_video_processor-0.9.2-py3-none-any.whl
Size 40.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2caa6a9c5298c30668f8bd8c5a2191cba4183b68ae5bae85591581592cbd914
BLAKE2b-256 checksum
How to use checksums
bc47fa76f1ecf189d4cad0487e7ec0ff105f0544563cb7c9b39582039508f05f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Security for django-contentor-video-processor 0.9.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page