Today we are excited to announce a big new feature: real-time encoding.

Real-time encoding allows your videos to be encoded while they are still uploading. Since our servers can encode video files much faster than most of your users can upload it, they will no longer have to wait for the encoding process to finish after uploading a video. As you can see in the screencast above, this effectively amounts to a 150-fold increase in encoding speed.

Existing customers can enable this feature by simply adding "realtime": true to their video encoding Step. We have also updated the docs for this feature.

If you are new to Transloadit, you can get your hands on this by signing up.

Technical details

From a technical perspective, real-time encoding works by pumping the video upload stream into FFmpeg via standard input.

While this sounds easy in theory, it is rather difficult to pull off on most stacks. Luckily, our system is built on Node.js, which is very well equipped for this kind of stream redirection.

To make it happen, we are using our handcrafted file upload parser, which writes the uploaded file to disk and gives us progress events along the way. Each progress event feeds a new chunk of the video into FFmpeg. However, if FFmpeg can't keep up, we wait for the standard input stream to drain. This way, there can never be any sort of memory build-up.

Dealing with errors is also important. If FFmpeg gives us an error during the real-time encoding, we simply abandon it and fall back to the regular encoding.

In short, that is how it works. If you are interested in more details, just leave a comment. In case you are already heavily invested in your own video stack, we are also available for consulting to bring this technology to your platform. Just contact us.

What's next

This is just one of the Steps to bring streaming functionality to all parts of our service. The next thing we need to tackle is streaming real-time encoded videos to amazon S3.

Another challenge lies in certain "mov" files that have their metadata at the end of the file. Luckily we got Daniel G. Gaytor excited about this, which prompted him to port his python version of qtfaststart to JavaScript. We are therefore confident that all of this will get sorted out with the next upgrade of our jQuery SDK.

We would also like to let you know that Daniel is currently looking for a remote job, so you should contact him if you are looking to add a really smart hacker to your team.

Final thoughts

Our mission is to improve file uploading on the web, so please let us know what other aspects of it are ruining your day - we will be happy to build the solution!

Credits

The example video uploaded in the screencast was produced by our friends at némata.