Me & 3M

My Mundane Musings

Media conversion in Linux: Using mencoder/ffmpeg/transcode and other media related scripts

Fedora doesn’t provide any ready to use media player or converted. But installing mplayer and xmms will fill that gap.
Here I will blog some scripts that eased my Any to XVid conversion and other media related stuff

Mencoder/ffmpeg/transcode other media relared scripts

Capturing images from PTP camera (Canon)
Use gnocam, gtkam or digicam
Use gphoto2 –get-all-files

AVI to Mpeg4
mencoder input.avi -ovc lavc -lavcopts vcodec=mpeg4 -o output.mpg4 -oac lavc -af lavcresample=48000:srate=48000

mencoder -ovc lavc -oac lavc -o

mencoder source.mpg -of avi -oac mp3lame -o file.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1400:vhq:vpass=1
mencoder source.mpg -of avi -oac mp3lame -o file.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1400:vhq:vpass=2

mencoder source.mpg -of avi -oac mp3lame -lameopts abr:br=128 -o /dev/null -ovc xvid -xvidencopts vhq=4:pass=1
mencoder source.mpg -of avi -oac mp3lame -lameopts abr:br=128 -o file.avi -ovc xvid -xvidencopts vhq=4:bitrate=1100:pass=2

One pass
mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=687 -o
mencoder -ovc xvid -oac mp3lame -lameopts abr:br=92 -xvidencopts bitrate=150 -o
mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=-700000 -o
mencoder -ovc xvid -oac mp3lame -xvidencopts fixed_quant=4 -o

mencoder infile.wmv -ofps 23.976 -ovc lavc -oac copy -o outfile.avi’

Two pass
nice -n 19 mencoder file.wmx -ofps 23.976 -oac mp3lame -lameopts abr:br=92 -ovc xvid -xvidencopts pass=2:bitrate=150 -o audiofix-150bit-xvid.avi

mencoder file.wmx -ofps 23.976 -oac mp3lame -ovc xvid -xvidencopts pass=1 -o /dev/null
mencoder file.wmx -ofps 23.976 -oac mp3lame -ovc xvid -xvidencopts pass=2:bitrate=250 -o 250bit-xvid.avi

To get an idea of bitrate # mencoder -ovc frameno -o frameno.avi -oac mp3lame -lameopts abr:br=128 vts_19_1.vob
single file # mencoder -oac mp3lame -o 6in1.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vqmin=2:vqmax=31 vts_19_1.vob
Multiple VOB files
# nice -+19 cat /media/cdrom/*vob | nice-+19 mencoder -ovc frameno -o $1 -oac mp3lame -lameopts abr:br=128 –
# cat /space/*vob | nice -+19 mencoder -oac copy -o /dev/null -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=1:vqmin=2:vqmax=31 -npp lb –
# cat /space/*vob | nice -+19 mencoder -oac copy -o $1 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vpass=2:vqmin=2:vqmax=31 -npp lb –
FFMPEG on the command line:
Values for -target “vcd”, “svcd”, “dvd”, “dv”, “pal-vcd”, “ntsc-svcd”
ffmpeg -i “$movie” -f avi -vcodec xvid -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 -y “$xvid_file”

Following is working fine for me (all encompassed in dat2divx script)
Use cdxa2mpeg (from GNUVcdImager) to convert DAT to mpg
$ cdxa2mpeg -v AVSEQ01.DAT AVSEQ01.mpg
A sample XVid conf file was copied from /usr/lib/transcode/xvid4.cfg to ~/.transcode/, modifiy it to taste
$ transcode -i AVSEQ01.mpg -o AVSEQ01.avi -y xvid -R1
$ transcode -i AVSEQ01.mpg -o AVSEQ01.avi -y xvid -R2


September 25, 2006 - Posted by | Tech Babble


  1. Very useful snippets here. Although I believe your ffmpeg command uses the bitrate as defined “-b 800” which is actually 800 BITS and not 800KBits, Unless thats what you wanted to do.
    my 2 cents.

    Comment by vangel | May 15, 2007 | Reply

  2. sorry for the typo above , I meant bits and kbits. Not to be confused with the B and KB which translates to bytes.

    Comment by vangel | May 15, 2007 | Reply

  3. hmmmm…very interesting!
    Thanks google

    Comment by endeapono | January 17, 2008 | Reply

  4. good afternoon,,,
    my name’s rerey..
    i want to ask you, Sir…
    how do we can convert .DAT to .MPEG with ffmpeg in Slackware 12.0???

    I need your reply as soon as possible..
    i hope, you’ll send a reply to my e-mail

    thank you so mch for your attention..

    Comment by rereynanda | May 28, 2008 | Reply

  5. Is this where I should post my intro?. Hi I am Leon. My Hobbies are make money on the internet read more about it here diet program online. I’m going to reading more about this website

    Comment by tutbrotte | January 16, 2011 | Reply

  6. I am curious to find out what blog system you have
    been using? I’m experiencing some small security issues with my latest website and I’d
    like to find something more secure. Do you have any recommendations?

    Comment by Haytham Ahluwalia | February 28, 2013 | Reply

  7. Way cool! Some very valid points! I appreciate you penning this post plus the rest of the site is really good.

    Comment by Kristine | May 8, 2013 | Reply

  8. I have a massive video library. I wrote this script to recode all my stuff. hoping this might help someone. you can mod the ffmpeg line to be your desired output. if not making it an avi, then you will need to mod the line where it changes the 3 characters of the file name to avi, to be your desired format. This script will recode all files with spaces, periods, dashes etc in the filenames.
    havent fixed this issue yet, if you need to stop the script, rename the dir of what is being recoded BEFORE you “ctrl C” to stop the script. otherwise, it will start deleting all the files in the filelist file.
    also keep an eye on the filesizes file. recomend for first run – as long as you have the space – comment out the following line “rm -f “${LINE}”” I was pretty much at 100% disk usage, amnd only enough free space to recode 1 or 2 things. thats why i wrote to recode, then delete the orginal.

    find ./ | grep -i mp4 > filelist
    find ./ | grep -i mpg >> filelist
    find ./ | grep -i mkv >> filelist
    find ./ | grep -i wmv >> filelist
    find ./ | grep -i vob >> filelist
    find ./ | grep -i m2v >> filelist
    find ./ | grep -i mpeg >> filelist
    find ./ | grep -i flv >> filelist
    find ./ | grep -i m4v >> filelist
    find ./ | grep -i divx | grep -vi mp4 | grep -v new.avi >> filelist
    find ./ | grep -i avi | grep -v new.avi >> filelist

    while read LINE; do
    if echo “${LINE}” | grep -i mpeg; then
    NEW_FILE=`echo “${LINE}” | sed -e ‘s/….$//’`new.avi
    elif echo “${LINE}” | grep -i avi; then

    NEW_FILE=`echo “${LINE}” | sed -e ‘s/…$//’`new.avi
    NEW_FILE=`echo “${LINE}” | sed -e ‘s/…$//’`new.avi
    echo Converting “${LINE}” to “${NEW_FILE}”
    /usr/bin/ls -lh “${LINE}” >> filesizes
    ffmpeg -y -i “${LINE}” -vcodec libxvid -acodec libmp3lame -threads 5 -qmin 4 -qmax 5 “${NEW_FILE}” > filesizes
    done < filelist
    rm -f filelist

    Comment by Tommy | December 14, 2014 | Reply

  9. I have noticed you don’t monetize your blog, don’t waste your traffic, you can earn extra bucks every month because you’ve
    got hi quality content. If you want to know how to make extra $$$, search for:
    Mertiso’s tips best adsense alternative

    Comment by LastCharline | January 4, 2018 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: