Finally MediaCoder is stepping on its way to becoming a distributive transcoder. I decided to design a frame level distributing mechanism instead of file-level distributing. The system is made up of a master, which performs decoding and data distribution, and one or more agents, which receive raw video frame, encode them and send the encoded stream back to the master. Users will feel like still using a desktop version of MediaCoder, while the encoding is actually done on another one or more machines. This approach has several advantages:
- No need to expose the whole file to the encoding machine with OS file sharing.
- It’s possible to implement segmented + distributed transcoding
- The decoding is still done by a Windows box (where MediaCoder runs), which has better decoding capability. This also helps to unify the decoding standard in a distributed transcoding system.
- The transcoding agents need no storage for intermediate data during transcoding. The frames are transmited over LAN, encoded and send back over LAN.
However, nothing is perfect. The downsides are:
- A fast (Gigabyte) LAN is required. Otherwise, the transmission of raw video frame over LAN will be the bottleneck of the system
- The master will have heavy load if there are too many agents to be fed
Currently the finished work is still limited. The MediaCoder Agent is written from scratch and only supports x264 meanwhile. It’s OS portable already however and I decided to make it open-source. So that some one will help with the improvement and porting hopefully.
Here is what current implementation can do and the limitations:
- MediaCoder Agent wait for incoming connection from MediaCoder upon running
- When MediaCoder is put into the new “Distributive” mode, it will off-load video encoding to MediaCoder Agent running on the other machine or locally.
- During the transcoding in distributive mode, MediaCoder decodes video into raw frames, send the frames to the agent over TCP and wait for the agent to return encoded stream in the return channel
- MediaCoder Agent can literally run on any OS (32 or 64 bit) with x264 installed (in /usr/bin by default, the location can be altered in MediaCoder’s Settings dialog)
- Audio encoding is not off-loaded and still done locally
- Currently only x264 is tested and only a single agent is supported
Here are some instructions to make things work.
- Download and install latest MediaCoder 2011 build 5210 (link at the bottom).
- Changing task mode to “Distributive”
- Setting agent IP address (currently only one agent is supported)
- Tick “Agent Under Linux” if agent is running on Linux
- Alter the path of x264 if needed
- Install (compile or apt-get) x264 on the machine to run MediaCoder Agent
- Checking out the source code of MediaCoder Agent from SourceForge repository (yes I am back to SF.net again)
- Compile the source code and run ./mcagent and it’s ready to roll
- If you want to use MediaCoder Agent on Windows, it’s even easier. You will find mcagent.exe in MediaCoder’s installation folder after applying the build 5210 update mentioned above. You don’t need to deal with x264 as it’s just in the codecs folder.
- After setting up, just do the transcoding as you do normally, adding files, setting parameters and pushing the start button
- You will note that the encoder CPU usage is almost zero. That’s where the difference is. The encoding is totally off-loaded from your local CPU.
- Everything else is just the same as in the “normal” mode
- Here on the agent machine, it’s busily processing the video frame pushed from the master machine. In my case, the agent machine is a Ubuntu x64 box.
- I am testing with a 100M LAN which will definitely be the bottleneck of the system when processing HD video. So a Gigabyte LAN is highly recommeded.
- After all frames have been processed, the master will obtain the complete encoded elementary stream and mux with the audio to output the final product.
So here is it. If you like this new toy for transcoding, I hope you can try it and give me as many feedbacks as possible.