Delivering faster video upload and streaming
Sharing a video from your iOS or Android device and allowing your audience to quickly stream without having to download it is a good user experience. In this article we show how we achieve this on Minsh apps. Please leave us some feedback in the comments, we really appreciate it.
The naive workflow is to select a video from the device and directly upload it to the cloud with a proper content-type
like video/mp4
so that the cloud storage provider can announce streaming capabilities.
This is how we actually started implementing video in the apps and we quickly saw the limitations of this naive approach. The only advantage of this method is that it was fast to develop for our customers to use videos.
Indeed, videos are now of very high definition and can easily take quite a lot of bandwidth to transfer. For example a 30 seconds video clip can weigh 70+ MB. So it takes a lot of patience for the broadcaster to complete the upload to the cloud.
Only then will the viewers be able to start streaming the video and the bigger the video, the more laggy the streaming will be. When mobile data connection is weak it can take ages to stream a short video.
Our solution is to reduce the definition of the video before uploading it to the cloud.
We detect video upload intent on the device and apply a transcoding pass to the video file, i.e., we re-compress the video to smaller dimensions and bit-rate.
The experience for the broadcaster is as follows:
- Select HD video file on device;
- Video file is detected and transcoding pass is applied to it;
- Loading progress starts from 0 and increases to 50% when the pass is being applied;
- The Loading progresses from 50% to 100% while the new smaller video file is being uploaded to the cloud.
Depending on data connection quality, the whole transcode + upload process will be faster than directly uploading the high definition video file.
The experience for the audience becomes:
- Receive push notification indicating new content;
- Tap the video play button;
- Video streaming starts with no lag.
Thanks to these optimisations, video upload and streaming are now first-class features of Minsh apps.