Saturday, August 9, 2014

FFMPEG Realtime Encoding Information

On VMS, user will upload video using web based uploader. The video will be detected by server encoder and start encoding to 3 different quality. The queue system managed by Gearman and the encoding will be done by FFMPEG.


We use Gearman as we planning to distribute the encode to our server farm encoders in the future. Right now, we use Gearman to queue the submitted jobs by our user.


Previously, we just call our FFMPEG from PHP shell_exec() and...boom. This happened when our users uploaded 10 videos at once . Learned from our mistakes, we search the internet Online Video encoding best practises. We stumble upon BeanstalkD and Gearman and also Parallel,PPSS for crunching the server resources.

We deployed Gearman on monthly server patches and now working perfectly. To add some visibility to our users what's going on after they upload the video, we put live indicator on the VMS and they can see the encoding done in real time

Web based indicator. 


FFMPEG already have the options to use all available CPU cores. So we use -threads 16 ( we have 8 cores ) and queue the job to run one by be using Gearman. So it is using FIFO concept. Fast In Fast Out. Peeking to our CPU usage after the changes, we're quite pleased withe results.

SIngle video encoding using 700% CPU

Once the encoding done, the videos will be sent to our storage server. Our Wowza VOD origin will fetch the video and serving them to Amazon Cloudfront CDN.

The resulted video encoded by FFMPEG

Why are we using Wowza ? Long story cut short, we want to save costs :D. Wowza can segment our VOD into our desired format, HLS,HDS and Smooth Streaming. And Wowza have very cool feature called MediaCache, and the most valuable feature that we really stick to them, the MediaCache HTTP Origin Mode, make CDN integration in blink of the eyes.

MyKLIK Video streaming in MBR for Desktop and Mobile
Upon arriving at Amazon Cloudfront CDN, the video distributed to all the world via Cloudfront HTTP CDN. Or if you want to save the bandwidth in your organization, simply install Squid and our videos will be easily integrate with you cache server.

Softwares mentioned in this blog :

Gearman : http://gearman.org
PPSS : https://code.google.com/p/ppss
BeanstalkD : http://kr.github.io/beanstalkd
SupervisorD : http://supervisord.org
FFMPEG : https://www.ffmpeg.org
Wowza Streaming Engine : http://www.wowza.com
Amazon Cloudfront : http://aws.amazon.com/cloudfront

No comments:

Post a Comment