Video Workflow Automation-1: A Serverless Watchfolder Workflow on GCP using Bitmovin APIs
In my previous blog post, we saw why and how we can run Bitmovin encoding jobs on GCP. We also saw how video file-based transcoding workflows on GCP can be set up using Bitmovin solutions to convert source media into output formats.
Once you start using Bitmovin on GCP to encode videos, the next step is naturally to build an automated workflow to process your content.
Set up a Serverless watch-folder workflow
In this example, I have created a serverless video transcoding watchfolder workflow solution using several GCP services including Google Cloud Storage (GCS), Google Compute Engine (GCE) and Google Cloud Functions.
Each video uploaded to GCS bucket input folder creates the following outputs:
- An MPEG-DASH and Apple HLS adaptive bitrate streams (both audio and video), for playout on multiple devices with different network bandwidth connections
- Manifests files for both HLS and MPEG-DASH playback (.m3u8 and .mpd)
Project Repository on GitHub for running Bitmovin on GCP (For the impatient!)
This repository on GitHub contains code that can be run both standalone and in a serverless environment .There is also a companion tutorial in README.md for the pre-reqs and for creating this workflow step-by-step. It also contains architecture diagrams.
saibalaji4/bitmovin-on-gcp-encode
This repository contains python code that will help you encode your source video files across multiple preset configs …github.com
Walkthrough of the workflow
- User uploads a video to the watchfolder input bucket in GCS. Only files added to this bucket will trigger the workflow
- The GCS create and finalize event triggers the Cloud Function that runs the encode.py python script
- The python script calls the Bitmovin APIs to transcode the video into corresponding ts and mp4 segments
- The Bitmovin APIs spin Google Compute Engine VMs (VMs and PVMs) to run the job
- The video segments (ts and mp4) are stored in the configured GCS output bucket
- When the encoding job finishes, it calls a webhook HTTP endpoint event which triggers another Google Cloud function
- This second function calls Bitmovin APIs to create manifest files (.m3u8 and .mpd)
- The Bitmovin APIs use the existing GCE instances to generate the manifest files
- The manifest files are uploaded to the GCS output bucket
Note: The GCP infrastructure is completely managed by the Bitmovin APIs. The VMs are deleted automatically whenever the jobs are completed and there are no new pending jobs
Use this workflow to use different encoding preset configurations
In the main.py script under the vod-basic-encoder folder, you should see the following VOD preset configs. It’s easy to create outputs with other formats supported by Bitmovin . You can refer to this Bitmovin doc for the supported formats, codecs and configurations.
And do check out the upcoming blog posts in this automation series. We’ll be adding thumbnails, sprites, DRM and CMS update.