Core serverless video transcoding and API backend for StreamVault.
Project description
StreamVault Core SDK
streamvault-core-kaustubh is a serverless Python SDK that simplifies building event-driven AWS video streaming pipelines. It provides pre-built logic for FFmpeg MPEG-DASH transcoding, DynamoDB job tracking, and a RESTful backend with Role-Based Access Control (RBAC).
🚀 Installation
Install the library directly from PyPI (once published):
pip install streamvault-core-kaustubh
🏗️ Prerequisites
To use this SDK in AWS Lambda, your architecture requires:
- Source S3 Bucket: Where raw MP4s are uploaded.
- Distribution S3 Bucket: Where
.mpdand.m4ssegments are stored. - DynamoDB Table: A single-table design for tracking users and transcoding jobs (Partition Key:
PK, string). - FFmpeg Lambda Layer: An AWS Lambda Layer providing the
ffmpegbinary at/opt/python/bin/ffmpeg.
🎬 1. Video Transcoder Implementation
Create an AWS Lambda function triggered by S3 ObjectCreated events on your Source bucket.
This function uses the process_video_s3_trigger wrapper to automatically download the video, transcode it to MPEG-DASH, push to the Distribution bucket, and send an SNS alert!
# lambda_function.py
import streamvault
import os
def lambda_handler(event, context):
# Retrieve required environment variables
table_name = os.environ["DYNAMODB_TABLE_NAME"]
output_bucket = os.environ["OUTPUT_BUCKET"]
sns_topic = os.environ.get("SNS_TOPIC_ARN", None)
# 💥 StreamVault Magic
streamvault.process_video_s3_trigger(
event=event,
table_name=table_name,
output_bucket=output_bucket,
sns_topic_arn=sns_topic
)
return {
"statusCode": 200,
"body": "Transcoding workflow triggered successfully!"
}
🛡️ 2. API Gateway & User Registration Implementation
Create a second AWS Lambda function strictly for handling API Gateway requests. This function provides instant backend routes for: user registration, logging in, role-based video retrieval, video deletion, and group access assignments.
# api_lambda_function.py
import streamvault
import os
def lambda_handler(event, context):
# Retrieve required environment variables
table_name = os.environ["DYNAMODB_TABLE_NAME"]
source_bucket = os.environ["SOURCE_BUCKET"]
# 💥 StreamVault Magic
return streamvault.handle_api_request(
event=event,
table_name=table_name,
source_bucket=source_bucket
)
Supported API Routes:
If your API Gateway endpoint is https://api.example.com, you instantly have access to:
GET ?action=jobs- Retrieve all background transcoding job statuses (Admin).GET ?action=videos&group=[Group]- Retrieve successfully transcoded videos the user has access to.POST ?action=signup&username=[User]&password=[Pass]&group=[Plan]- Register a new user in the DB.GET ?action=login&username=[User]&password=[Pass]- Returns profile information and group tier.GET ?action=upload-url&filename=[Name.mp4]- Generates an S3 Pre-signed URL for direct uploads.DELETE ?action=delete&id=[JobID]- Completely purges a video from S3 and DynamoDB.POST ?action=update_access&id=[JobID]&group=[Plan]- Locks video access to a specific subscription tier.
🤝 Contributing
Pull requests are welcome! If you encounter issues setting up the AWS resources or FFmpeg Lambda Layer, please submit an issue to the bug tracker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamvault_core_kaustubh-0.1.0.tar.gz.
File metadata
- Download URL: streamvault_core_kaustubh-0.1.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8b25f7513b141e996b0bf9a419278106cb1350e20b429c81afee861bccad34c
|
|
| MD5 |
907af089de714d95b2decb9f3ef8bf43
|
|
| BLAKE2b-256 |
47f4585d594d71720f56db8aaba3c1fc4deea7fb662823ab14b257c0bf8fb9b0
|
File details
Details for the file streamvault_core_kaustubh-0.1.0-py3-none-any.whl.
File metadata
- Download URL: streamvault_core_kaustubh-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4636ed37ebaea9d1d0fa640ee0fbd5334697e6d1d1e19269eb390bf10159f467
|
|
| MD5 |
0a313a93eeb2e428b8bac35b405b8514
|
|
| BLAKE2b-256 |
d673d7e1c5c5e932814eac3414fcfa6a40f88a08c3a0980ad06267faa0a770b3
|