A simple yet powerful media transcoder that converts any image sequence or video into a web-playable h264 video file.
The code for this project is proprietary, no link is available.
This tool was built with python to run on macOS.
As most transcoders operate, so too does Combustion start with decoding media into a common data space, to then output thru a destination codec. I started its design with inspiration from FFmpeg: by using an array of delegates that tie each file extension to a specific internal decoder. FFmpeg handles the majority of the formats, but my solution for raw image sequences and RED Digital Cinema videos was a bit more custom.
If you were a mediocre piece of software, where would you hide?
Redline is the command-line tools that I used as the decoding delegate for
I can't properly link to this tool, nor its documentation (which tells you a lot). RED Digital Cinema has hidden this command-line tool into their media management software, and have only recently released a standalone version for Linux. The documentation is a series of linked files that are served thru an AWS S3 bucket, with a URL that changes frequently. The tool itself is pretty verbose, but you'll need to test each of your input arguments to confirm that what the documentation is claiming, actually functions accordingly.
The wRAWng intermediate
My solution to decoding raw images, which can be handled natively thru FFmpeg if you have it complied to do so (a headache not worth having), involved using a few different tools that piped their data into one another. Doing this thru python's subprocess module is asynchronous, and I failed to discover how to pipe that intermediate image data into FFmpeg in real-time, to create the destination video file.
My solution was to decode each raw image to a compressed one (JPEG) and then to build the video from there. Unfortunately, this is slow and consumes more disk space than is necessary. 😓
Living in a 16 by 9 world
Throughout your life, you've probably watched videos and films with every aspect ratio known to man. But you might have noticed that most of the entertainment world settled on 16x9 as the width-by-height ratio of a video. Combustion puts all of its input media inside a box of this ratio, padding with black, before creating the destination file.
The challenge became massive when I discovered that FFmpeg was changing the pixel aspect ratio of certain inputs, just to achieve the 16x9 display aspect ratio, without my consent. The culprit was that when you multiply the aspect ratio by some input pixel integer if the result is not an integer, FFmpeg was fudging a parameter to avoid dealing with sub-pixel spatial interpolation. The fix involved recursively solving for the nearest dimensions of the input media which would allow both the scaling of the media and the padding of the media, to all take place with integer values.
There are many things that this software can't do -- but the same goes for every tool ever built.
Here are a few things that I've found which can break Combustion:
The beauty of media compression is that if a compression algorithm allows bitrate as an input parameter, you can then, with 100% accuracy, predict the output file size.
The general formula for output size of a video is
Width * Height * BitsPerColor * NumberOfColors * FramesPerSecond * BitsPerByte * BitsPerSecondRatio * NumberOfSeconds = OutputFileSize.
What this formula says is: Given a video resolution, the number of colors and how they are represented, the number of video frames to occur in 1 second, here’s how big your file will be.
Let’s take a look at a 1920x1080, 60 FPS video that comes out of a GoPro where the video is 30 seconds long. If the GoPro didn’t add compression to this video, and we just used the basic algorithm above, the file size would be 20GB. That’s insane. So by deciding on a good ratio by which to compress your video, we land on a manageable file of 500 MB.
The point of all of this is, combustion allows you to supply a ratio to your transcode, which is more powerful than supplying “bitrate”, and it’s why applications like Adobe Media Encoder have a “quality” slider. Using this feature and this tool, while at The Molecule, we were able to create a web-playable video of over 10000 media assets and the resulting size of all of them was less than 6GB. And they still looked great when played back in a web browser!