You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Encoding videos With Mencoder For Flowplayer A Flowplayer tutorial

This tutorial will assume the following

This is a continuation of Liam's FFMPEG Hi-Definition encoding tutorial. In my version there are some changes, and hopefully this will provide you with another method of encoding video which is stremable with flowplayer. This tutorial assumes you have the following installed:

Important resources

Introduction

In this tutorial I hope to show another way at encoding video for use with flowplayer. Unlike in Liam's tutorial I will be using mencoder. The videos will first have the audio extracted from them, which will be encoded with NeroAACenc. I decided to use Nero because in listening tests it has been seen to perform better, and when I listened it sounded better to me.

I am using 2 pass Mencoder encoding to encode the video. I will explain to you what each setting does in more detail later on.

But why use mencoder? Well firstly, there will always be a file which either mencoder or ffmpeg is unable to convert. With these new options you can always try a file on mencoder if it doesn't work on ffmpeg. At the end of the day, in both cases both the video and audio is being converted by external libraries- x264, faac and neroaacenc. Another reason to choose mencoder over ffmpeg is the documentation is better. While this may change in the future it is nicer to have more information on software which has a vast ammount of options.

To make the video streamable without having to load the whole video first, I am using MP4Box. I am also using it to mux the audio and video tracks together.

Encoding H.264 Video and AAC Audio

I'm not going to explain all about what H.264 and AAC is, because that is not the point of this tutorial. However, if you'd like to do some extra reading I recommend this page for H.264: Apple Page on H.264 Video and this page for AAC Apple Page on AAC Audio

Audio

First let's start by extracting the audio. To do this we use mplayer, so execute this command.

mplayer infile.mov -vc dummy -ao pcm:fast:file=audio.wav

Now that we have the audio, it's most likely quite a big file. So let's encode the audio with NeroAAC, the setting to control the quality is -q. This is any number between 0 and 1. In my example I've used the highest quality, and so now let's execute this command:

neroaacenc -q 0.99 -if audio.wav -of outfile.m4a

Now that we have the audio encoded, let's leave it to one side and encode the video.

Video

We do not need to extract the video this time so let's get started. I will be encoding at a resolution of 1280x720, which is also known as 720p. So let's first execute the command to do the first pass.

mencoder infile.mov -of rawvideo -nosound -ovc x264 -x264encopts subq=1:frameref=1:bitrate=900:bframes=1:pass=1 -vf scale=1280:720 -o outfile.264

Now once that is encoded let's execute the second pass.

mencoder infile.mov -of rawvideo -nosound -ovc x264 -x264encopts subq=6:frameref=5:bitrate=900:me=umh:partitions=all:bframes=1:me_range=16:cabac:weightb:deblock:pass=2 -vf scale=1280:720 -o outfile.264

Okay now the video is encoded we have the video and the audio as two seperate files, so we have to mux them together. Please take note of the FPS value. This must equal that of the video, or the video and audio will be out of sync.

mp4box -add outfile.264 -add outfile.m4a -fps 23.976 finalout.mp4

So now you have a video which can be playable using flowplayer, and is high quality

Parameters

So I've now shown you how I encoded my video, but what do all the options mean? Well I'll try to explain them.

parameter value description
subq 6 This determines which algorithms to use. 1 is the lowest, and the quality goes higher as you increase it
nosound -nosound Don't encode the video with sound
Bitrate 900 What bitrate value to aim for
me umh Don't quite understand, but is used for quality and speed of the video.
partitions all Don't understand again, but enables something which makes the quality better
bframes 1 How many bframes to use. Note the iPod doesn't support Bframes
-vf scale 1280x720 The resolution of the output
me_range 16 Determines the max range for motion search. For HD footage and high-motion video, a higher number is better
cabac Although it means slower encoding and decoding, it offers 10-15% improved compression.
weightb Allows b_frames to use weighted predictions.
deblock This needs some CPU decoding, but the quality is improved in nearly all cases
pass 1 or 2 How many passes to make. The first pass gets information about high and low detail and motion scenes. Then on the second pass it knows how to distribute the bandwidth accordingly. It takes more time to encode, but leads to better quality.

Now you've sen how to encode using mencoder, to create high quality video. Please note, H.264 requires CPU, so saying it makes me laggy or whatnot, simply means that the CPU is not good enough. I've run it on a Quad core at school, and it's played back fine.

Examples

Transformers II

19mb File

Angels and Demons

20mb File

The fast and the Furious

21mb File

I don't know the original file sizes, but they were over 100mb.

Author

Author: Denis Ogun
Website: Pwn-Tube: Video Sharing Site for Gamers

Thanks goes to Liam Golding for the original tutorial.