Tuesday, February 1, 2011

Using MeGUI to encode videos in x264

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. You can use x264 compression method to drastically reduce the size of video files without loss of quality. Here I will explain how to use ffmpeg to convert videos in  Windows .

Instructions:
First you need to install the following programs.
MeGUI is a front end for ffmpeg. You can use either the offline installer or zip file for MeGUI. After extracting or installing MeGUI run it. Go to Options>Settings. If you have access internet through a proxy server then give those settings as shown.

After that go to External Program Settings and choose the location for "neroAacEnc.exe". You can put that file anywhere you want, but it is better to keep it in tools folder in megui directory.

After extracting neroAacEnc.exe to tools folder give its path in External Program Settings.

Save and start updater by pressing Ctrl+U. Press the update button to download and install all the files necessary for MeGUI.
You will be asked to select the presets, select whatever necessary. Restart MeGUI to complete the update operation.

Now press Ctrl+R to open AVS script creator. Select the video file that you want to convert. A window will open close it. Keep the settings as shown in the figure. Update the scratchpad profile or save it under a new name. You can resize the video or crop it using the Crop&Resize settings.


Now go to the filters tab. Here you can select the source type. For auto detection use analyze button (this will take some time to detect). If the video is anime, select the Source is Anime checkbox. You can also include subtitles in your video from this window.


Then click the save button. A window will open again, close it.
Now press the config button for encoder settings. Choose the settings that suit you most. Don't worry about bitrate as the settings here will not affect the final output size. You can save this preset under a new name and use it afterwards.

Now in audio options select the same video file again for audio input. You can change the output bitrate of audio to your like. 128kbps is normally enough for good quality sound. You can decrease the audio bitrate further to lower the size of file. As usual you can save this preset under a new name.

Finally press the Auto Encode button. A window will open in which you can specify the format of the output file and its target size. The ideal setting is 405kbps for a video file of resolution 640*480. After you have done giving the input press Queue. If a window pops up saying that the color space is not YV12, press OK.
You can add all the files that you need to convert to the queue. After you are done adding the files go to the Queue tab and press start button to start the encoding (it will take about the length of video to convert the file). The process will start at low priority. But you can change its default behavior in the settings (suggested is in normal mode).
After converting the video files, you can delete the .avs files produced by MeGUI. That's it. You have successfully converted a video using x264 compression. If you have problems with audio use mkvmerge to add the audio tracks to the file. You can find it in tools folder in MeGUI directory. Its located in tools/mkvmuxer/mmg.exe . Add both the files and then deselect video of first and audio of second file and press Start Muxing button. After it is finished press Ok and close the window.

Here is a sample of snapshots of the input and the output files.
You can see that the size of the output file has decreased in half. If it was an avi file the size would further decrease (I used an mp4 file for the testing).
I will tell you how to use ffmpeg on Linux in my next post.

No comments:

Post a Comment