Create FLVs with Mencoder on Windows

Putting videos on your website or on your blog can become pretty annoying as some people don’t have one particular player, this one particular codec or this particular browser.

What most people have though, is flash. If you make videos and want people to be actually able to play them on your website without having to download them, flash is the way to go.

I did not want to download and try some of those hundreds of thousands of closed source applications to do this If I’m already familiar with open source applications doing the same. I don’t need some stupid, shiny GUI for such a trivial task.

So I got Mplayer for windows. Mplayer is a command line media player pretty popular on Linux. But why would I get a player if all I want to do is encode some video files. Mplayer comes with Mencoder, another command line app, but this one, as you might have already guessed, does encoding.

Ok, let’s get started, first you need Mplayer, you can get it here (Mplayer 1.0rc2 Windows), just chose the mirror you like and extract the files wherever you like.

Next step is to get the binary codecs. Get the windows package and extract all files it contains to the codecs/ folder of Mplayer.

You already got all you need but in order to speed up the process, especially if you have to encode several files and don’t want to mess around with the Windows command line there’s one thing missing to automate the encoding of multiple files for what I made a batch file doing all of the work for me.

  1. Go to the Mplayer folder
  2. create the folder batch2flv
  3. in batch2flv create the folder output

Open you text editor to create the batch file batch2flv.bat, here’s the code:

for %%f in (*.*) do ..\mencoder.exe -forceidx -of lavf -oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=360:240 "%%f" -o "output\%%~nf.flv"

Ok, now we’re done. All you have to do to get the FLV files is to put the video files you want to encode into the batch2flv folder and double click the batch file.
Windows command will pop up and you’ll see the progress — all finished files will show up in the output folder.

[flash http://www.ainotenshi.org/wp-content/uploads/loltest.flv]

You might also like

2 thoughts on “Create FLVs with Mencoder on Windows

  1. Hi,

    First, thank you very much for sharing. I tried your batch file code it is working perfectly fine except, for some reason my flv files are not being saved in the output folder.

    Please advice for any possible solutions to make this function work.

    Thanks,
    Michael

  2. I found the reason. There was an error in the code which I just fixed.

    Now it should be working as intended.

    1
    
    for %%f in (*.*) do ..\mencoder.exe -forceidx -of lavf -oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=360:240 "%%f" -o "output\%%~nf.flv"