Goal: Leverage the Oracle Cloud Free Tier to transcode video files to AV1 to optimize storage space.
- Source: Original videos are stored in a local directory.
- Remote Processing: Files are transcoded to AV1 on remote Oracle Cloud instances.
- Retrieval: Completed transcoded videos are downloaded back to a local destination folder.
- Cleanup: Remote copies are purged after a successful transfer to maintain free space.
Operational Workflow: This project is designed for intermittent local availability. The local PC is only powered on when in active use by the user, not specifically for transcoding. The synchronization process is intended to run automatically in the background during these periods to manage the remote queue.
The project consists of two main components:
-
transcode.sh- Designed to run as a cron job on the Oracle Cloud instance:- Uses
flockto ensure only one instance is active at a time. - Scans for files, ignoring partial uploads (e.g., hidden files generated by
rsync). - Executes
ffmpegto perform the AV1 transcoding. - Deletes the source file on the cloud once transcoding is successful.
- Uses
-
sync_transcoded.py- Designed to run automatically on the local Windows machine (e.g., via Task Scheduler) whenever it is powered on:- Downloads finished transcoded files and removes them from the Oracle Cloud server.
- Verifies that sufficient disk space exists on the cloud instance before proceeding.
- Uploads new source files for the next batch of transcoding tasks.
To ensure stability and allow for future pipeline stages, the project uses a numbered directory structure:
- Local Source: The local directory where you place raw video files.
01_upload_staging(Server): Temporary area for incoming files (prevents processing partial uploads).02_transcode_queue(Server): Files moved here are picked up bytranscode.shfor processing.03_transcode_staging(Server): Whereffmpegwrites the temporary output file during encoding.04_transcode_finished(Server): Final server destination for completed files, waiting for download.- Local Destination: The local directory where finished files are automatically retrieved.
cd /home/ubuntu
git clone https://github.com/FlippFuzz/transcode
cd transcode
chmod +x transcode.sh
# Add the cron job to run every minute (non-interactive and idempotent)
(crontab -l 2>/dev/null | grep -Fv "/home/ubuntu/transcode/transcode.sh"; echo "* * * * * /home/ubuntu/transcode/transcode.sh") | crontab -