February 16, 2010

Conversion of .avi to .mkv with Mediacoder

To all the video and audio enthusiasts out there, who need a good software to convert different video and audio files to different formats, give Mediacoder a spin...

It's an excellent software. I've been using it for about a year. It's completely free, comes with both x86 and x64 based installers and can handle almost every format there is.. It also has features usually found only in commercial video transcoders.

I've downloaded Mediacoder(x86 edition) along with all the useful plugins, zipped it into a file and uploaded it on mediafire. Download it HERE. Please keep in mind that Mediacoder also needs Mozilla Firefox to run. It can downloaded and installed HERE.


Please read my earlier post on audio and video formats and containers if you haven't already. Today's tutorial is meant to teach you how to use Mediacoder to convert your .avi files to .mkv files in order to save storage space.

Download Mediacoder either from my earlier link or from HERE. The software you download from the newer link will be the latest edition, but you'll have to install a good no. of plugins separately, while my earlier link has all the plugins built in. Download and unzip the file to C:\program files\Mediacoder. Click on the screens below to display them fully.

Navigate to the folder, right-click on mediacoder.exe and click on Send To->Desktop.



Open Mediacoder, and click on the leftmost button on the top, click on "Add File" and open the file(s) you want to convert.



Select the output folder on the top right-hand corner. This is where the new file after conversion will be stored. Something pretty neat about Mediacoder... look on the bottom left on the Generic tab. If you've got a dual core processor, you can set Mediacoder to use only one of your cores. This will slow down Mediacoder, but you'll be able to use your PC much more freely with one of your cores being free..



Click on the Video tab. Make sure the "Enable Video" checkbox is ticked. Otherwise, the output file will have no video... Select the format as H.264 and the mode as 2-pass. 2-pass encoding is much better than the standard single pass encoding.



In order to understand why, knowing what bitrate is is crucial..bitrate is the no. of bits allocated to each frame of the video. Higher the bitrate, higher the quality...this of course depends on the fact that the source must be of good quality as well. Just giving high bitrates when the original video is bad quality will not improve video quality.

On the first pass, it runs through the entire file once, and decides which parts of the video require a higher bitrate(Ex:Action sequences)and which ones don't. On the second pass, it allocates the required bitrate to the right frames. Else, it would've given all the parts of the video the same bitrate which results in waste of storage space.

In the box below the Mode option, type in the max. bitrate allowed. This will be the max. bitrate that will be allocated to any frame that requires it. Set it between 750 to 900 for standard video. If you're encoding an HD source, set it to around 1200.

In the source tab, set it as either ffmpeg or mencoder. This is what is used to decode the source video. If ffmpeg doesn't work, try again with mencoder or vice versa. Set the encoder as x264. Uncheck the "Auto Select" option before doing so. Click on the "Advanced" option under the x264 tab on the right. Some advanced options should be set here in order to get the best out of your video conversion. In the window that opens up, ensure that you set the highlighted options to the same values that is shown in the screenshots. DON'T touch the others!






I'm not going to explain everything about these options because I myself haven't managed to understand yet how all the components work. I will however, tell you what options to set to improve efficiency and get the best quality out your video. Just follow the order of options in the pictures and set the values.

Points to remember:
  • Tune the settings for whatever is required based on the video you are encoding.
  • Set the p-frame quantizer as 22. This gives a good tradeoff between quality and file zise. And for the mathematicians, the scale is a logarithmic scale, so a small change in the value here can give a considerable difference in quality.
  • Set the no. of predictors in B and P frames as 5. Set the no. to 10 or so if you're encoding animated videos.
  • Make sure that CABAC is enabled.
  • Ensure that motion search algorithm is of the type Uneven Multi Hexagon and set motion search radius around 16-24 for normal videos and 25-35 for action videos.
  • Set the subpel refinement quality to 7 or 8. 7 offers slightly higher encoding speed,while 8 offers slightly better quality.
Once you've set all the options, close the window and click on the audio tab.



Again, ensure that the "Enable Audio" checkbox is ticked. Select the source as either mencoder or ffmpeg. Set the encoder as FAAC. On the right, under the FAAC tab, select "Average Bitrate" and set it to around 128 for normal speech, and around 144 if the source contains music. You can set it to max of 256 if the source has high quality music and you wish to preserve it. Set the Container as MP4.

You're almost done(Yay!). Click on the container tab.


Select the container as Matroska, click on "Enabled" and select MKVMerge as the multiplexer. This will create an .mkv file as the container and MKVMerge is the multiplexer which merges the two audio and video streams together.

Note:If you want to convert the video for using on an Apple iPod, It can be done easily here. Select the container as MP4, and the multiplexer as MP4Box.




Now, onto the Picture tab...


Here, you can resize the video if you require. just uncheck it if you want to keep the same file size. Resize to 320x240 for iPods. Clicking on the "Effects" option will bring something really great...




Here, you can apply certain effects to the video if you want, increase the brightness, contrast, etc. Leaving them at the default will not change the video. Noisy or grainy videos can be cleaned under the "Denoiser" option. Select either the Temporal 3D or Normal 3D options.

I've used paint to blur whatever video I was editing. Nothing special about the video. just wanna remain safe.


You can also use the "Mark In" and "Mark Out" options to transcode only certain parts of the video(I can now extract certain parts from movies....Yeah!!). Click on "OK" when you're done.

Moving on....
 

 The options in the Sound tab can allow you to apply effects to Sound....duh! Leave the settings as they are if you don't want to change the audio. The Gain option will allow you to increase or decrease the volume of the audio. The scale is in decibels, so watch out!


You're done! Click on Start, and you'll begin transcoding. It takes quite a while to transcode video, so be prepared to wait a while. Converting .avi to .mkv can take upto 2 hrs of your time or even more, depending on your processor speed and no. of cores..


That's all for now... thanks for reading.. hope you found it useful.. Music buffs will find my next post especially useful... Wait for it.. it'll be coming later tonight..

Have a great day..
Vinay