# GPU-Enabled Serverless Workflows for Efficient Multimedia Processing
## 4 Serverless Workflow for Multimedia Processing  
In order to demonstrate the benefits and performance of the platform, a use case has been defined that builds a serverless workflow to perform frame-level object detection in video together with the inclusion of subtitles from the audio transcript, with potential applications in surveillance. This demonstrates the ability of SCAR to provide an event-driven service for multimedia processing, triggered by video uploads to an S3 bucket that can automatically scale up to multiple function invocations and several EC2 instances to cope with the workload and then automatically scale down to zero provisioned resources.  
Figure 2: Functions Definition Language example.  
Hence, the platform allows the deployment of a highly available multimedia file-processing service with automated elasticity to support large workloads while maintaining zero cost when it is not in use.  
Figure 3 shows the different functions that compose the workflow, as well as the folders in the S3 bucket used for input and output. These container-based functions use the following open-source software:  
* _FFmpeg_[29]. Used to preprocess the videos uploaded to the _start_ folder, extracting and converting the audio to the input format expected by the _audio2 str_ function, as well as converting the videos to a suitable format (if they are not) for the object detection stage with YOLOv3. This function has been configured with the _lambda-batch_ execution mode, since, depending on the quality and duration of videos, it could not fit in the Lambda execution environment. According to the new output postprocessing stage, the function will upload the resulting files to the _audio_ or _video_ folder depending on their extension (_.avi_ or _.waw_).
* _audio2 str_[30]. A small application to generate subtitles from audio transcripts obtained through CMUSphinx [31], which uses acoustic models for speech recognition. The application, together with the models, has been packaged in a Docker container so that it can be defined as a serverless function in SCAR. This function will be triggered when the FFmpeg function uploads the extracted audio to the _audio_ folder and, after processing, will store the resulting subtitle file to the _result_ folder.
* _YOLOv3_[32; 33]. A real-time object detection system that, using the Darknet [34] neural network framework, can run on GPUs to accelerate the video inference process. It has been compiled with CUDA [35] support and packaged as a container to be executed in GPU-accelerated AWS Batch compute environments. GPU access has been enabled in the definition of the function, which has also been configured to be triggered when videos are uploaded to the S3 _video_ folder and to store the result in the _result_ folder.  
Figure 3: Simplified diagram of the multimedia processing workflow.  
Users will only have to download the files from the _result_ folder through the SCAR tool and open them in a multimedia player in order to watch the resulting video with prediction boxes together with the automatically generated subtitles, as shown in Figure 4.