PMP AVC Mencoder for linux

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Khannie
Posts: 27
Joined: Tue Apr 25, 2006 9:12 pm
Location: Dublin, Ireland

PMP AVC Mencoder for linux

Post by Khannie »

I altered mencoder / x264 (groundwork done by Jonny and Magik, thanks lads) to create PMP compliant AVC files. I made a statically linked binary, so it should work on any i386 based linux install without the need for codec installs, etc.

Edit: You should NOT replace your installed version of mencoder with this one, though 99.9% of the code is just the SVN code. :)

This is basically a hack that I put together myself because I was having sound synch issues and this fixes them. But because I mostly made it for myself, the scale filter is used to determine the width and height to write to the input file for pmp_muxer_avc.pl (I will fix it up over the coming while, but my main focus for now is on looking at adding ogg vorbis support to PMP Mod AVC). My encode script is below. You should use a similar methodology (i.e. encode with sound, extact video, extract audio, pmp mux them).

Code: Select all

#usage <scriptname> inputfile outputfile

BITRATE=450

###########generated muxed video / sound##########
~/install/mencoder_psp/install/mencoder "$1" -vf scale=480&#58;272 -ovc x264 -x264encopts bitrate=$BITRATE&#58;pass=1&#58;turbo=1&#58;threads=2 -srate 44100 -oac mp3lame -lameopts vol=0&#58;mode=0&#58;cbr&#58;br=128 -o /dev/null

~/install/mencoder_psp/install/mencoder "$1" -vf scale=480&#58;272 -ovc x264 -x264encopts bitrate=$BITRATE&#58;pass=2 -srate 44100 -oac mp3lame -lameopts vol=0&#58;mode=0&#58;cbr&#58;br=128 -o "$2".temp

###########rename x264 file##########
mv x264file.txt "$2".264.txt

###########copy video out##########
~/install/mencoder_psp/install/mencoder "$2".temp -ovc copy -nosound -o "$2".264

###########copy sound out##########
~/install/mencoder_psp/install/mencoder "$2".temp -srate 44100 -oac copy -ovc copy -of rawaudio -o "$2".mp3

##########generate pmp file##########
~/install/pmpmux/pmp_muxer_avc.pl -v "$2".264 -a "$2".mp3 -o "$2".pmp -w 480 -h 272


#clean up&#58;
if &#91; -f "$2".pmp &#93;
then
        echo "Found PMP. Cleaning up temp files."
        rm "$2".264.txt "$2".264 "$2".mp3 "$2".temp
        exit 0
fi

echo "**********************************************"
echo "PMP file wasn't found. Temp files not deleted."
echo "**********************************************"

I have tested on ubuntu 6.06 and RHEL 4.

You can download version 0.0.1 here.

I'll make the source code available at some point over the next few days for those that wish to compile in their own codec support, etc.

One request: If anyone uses this, could they let me know by replying to this thread; It will determine whether or not I bother making updates publicly available.
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

Post by jockyw2001 »

Khannie: did you use the current version of x264? If it is the same version as used in the new VLC 0.8.6 then it may save me some time to patch that for PMP VLC. I would be grateful if I can use your x264 diff files :)
Khannie
Posts: 27
Joined: Tue Apr 25, 2006 9:12 pm
Location: Dublin, Ireland

Post by Khannie »

Yeah, I used the svn version of x264. You're more than welcome to my source files / diff. I'll send you off a link tomorrow (bit late now) :).
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

Post by jockyw2001 »

Wonderful !
Thx and take your time :)
Khannie
Posts: 27
Joined: Tue Apr 25, 2006 9:12 pm
Location: Dublin, Ireland

Post by Khannie »

For what it's worth, I've done > 50 encodes with this now, all of which have been in sound synch, so it seems solid enough.



jockyw2001: I haven't forgotten to post the source....It's just been a bit mental lately in the run up to Christmas (also did an OS wipe the other day so I'm still getting up and running.). I have a decent break coming my way over the festive season so I'll get the source up and some changes made to clean things up.

I might try and clean things up (so as not to interfere with the original encode options) and add the changes to the x264 svn so that PSP AVC would be an encoding option with the svn version of mencoder (for example).

I'm also looking at adding ogg support to PMP Mod AVC, though I may have bitten off more than I have time for, I'll at least give it a stab.
foo
Posts: 7
Joined: Mon Sep 25, 2006 8:38 pm

Post by foo »

So did you ever get around to releasing the sources? If so, can you post a link to them? :)

Off topic, but does anyone have perl sources for the cooleyes' latest pmp muxer avc (20070606 apparently)? I can only find windows binaries of it :(
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

foo wrote:So did you ever get around to releasing the sources? If so, can you post a link to them? :)

Off topic, but does anyone have perl sources for the cooleyes' latest pmp muxer avc (20070606 apparently)? I can only find windows binaries of it :(
In the main pmp muxer thread (toward the end), there is a long discussion about adding aac support to pmp, and all new muxers posted to add said support. Use the source for that.
Matrixdub
Posts: 60
Joined: Fri May 13, 2005 3:47 am

Post by Matrixdub »

J.F. wrote:
foo wrote:So did you ever get around to releasing the sources? If so, can you post a link to them? :)

Off topic, but does anyone have perl sources for the cooleyes' latest pmp muxer avc (20070606 apparently)? I can only find windows binaries of it :(
In the main pmp muxer thread (toward the end), there is a long discussion about adding aac support to pmp, and all new muxers posted to add said support. Use the source for that.
I also read here that native hardware XviD decoding was being added to this project, but I haven't seen anything materialise, have I simply missed the update?
foo
Posts: 7
Joined: Mon Sep 25, 2006 8:38 pm

Post by foo »

J.F. wrote: In the main pmp muxer thread (toward the end), there is a long discussion about adding aac support to pmp, and all new muxers posted to add said support. Use the source for that.
Yeah, I already have a aac capable muxer, but the 20070606 release apparently added support for 48khz audio track which I'd like to use, but cooleyes only posted windows binaries of it on cngba...
cooleyes
Posts: 123
Joined: Thu May 18, 2006 3:30 pm

Post by cooleyes »

here is the last source of pmp_muxer2
http://www.fx-world.org/cooleyes/downlo ... source.rar
it can mux a pmp version 2 file( pmp2(xvid+mp3), pmp2(xvid+aac), pmp2(avc+mp3) , pmp2(avc+aac) ) [/url]
foo
Posts: 7
Joined: Mon Sep 25, 2006 8:38 pm

Post by foo »

Ah great, thanks!
Khannie
Posts: 27
Joined: Tue Apr 25, 2006 9:12 pm
Location: Dublin, Ireland

Post by Khannie »

foo wrote:So did you ever get around to releasing the sources? If so, can you post a link to them? :)
Humble apologies, but I got lazy. :) I actually rediscovered this thread after looking for an alternative mencoder that uses updated x264 libraries myself. I'll definitely get my finger out and release the sources, but they're horribly out of date now. My plan is to hack the same changes into the current x264 svn and use them as the threading support is far far better.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Khannie wrote:
foo wrote:So did you ever get around to releasing the sources? If so, can you post a link to them? :)
Humble apologies, but I got lazy. :) I actually rediscovered this thread after looking for an alternative mencoder that uses updated x264 libraries myself. I'll definitely get my finger out and release the sources, but they're horribly out of date now. My plan is to hack the same changes into the current x264 svn and use them as the threading support is far far better.
That would be cool. Looking forward to it. :)
Khannie
Posts: 27
Joined: Tue Apr 25, 2006 9:12 pm
Location: Dublin, Ireland

Post by Khannie »

Hmmmm. Upon further reflection, the enhanced threading support in the newer x264 library would have no effect because using threading in the actual video encoding causes the resulting pmp to be unplayable (I remembered this from a conversation with Jonny and have been testing it out a bit myself this evening). I'm open to being corrected on this of course and would be happy to.

BUT....all is not lost. You can still avail of the improved x264 threading performance in the first pass of a 2 pass encode. I've altered my own conversion scripts quite a bit, and I regularly get 200fps in the first pass without turbo mode (turbo mode + threading doesn't seem to make any difference to me).

For what it's worth: I'm running gentoo. Latest x264 snapshot that the the OS installed mencoder is linked to was taken at 2007-09-24. I have a q6600 running at 2.7GHz.

My base conversion script looks like this:

Code: Select all

BITRATE=650
TEMPDIR=/tmp
FILENAME=`echo $2 | cut -d/ -f6`

###########generated muxed video / sound##########
/usr/bin/mencoder "$1" -vf scale=480&#58;272,harddup -ovc x264 -x264encopts bitrate=$BITRATE&#58;pass=1&#58;threads=5 -oac copy -o /dev/null

~/install/mencoder_psp/install/mencoder "$1" -vf scale=480&#58;272,harddup -ovc x264 -x264encopts bitrate=$BITRATE&#58;pass=2 -srate 44100 -oac mp3lame -lameopts mode=0&#58;abr&#58;br=128 -o "$2".temp

###########copy video out##########
~/install/mencoder_psp/install/mencoder "$2".temp -ovc copy -quiet -nosound -o $TEMPDIR/"$FILENAME".264

###########copy sound out##########
~/install/mencoder_psp/install/mencoder "$2".temp -quiet -srate 44100 -oac copy -ovc copy -of rawaudio -o $TEMPDIR/"$FILENAME".mp3

###########rename x264 file##########
mv x264file.txt $TEMPDIR/"$FILENAME".264.txt

##########generate pmp file##########
~/install/pmpmux/pmp_muxer_avc.pl -v $TEMPDIR/"$FILENAME".264 -a $TEMPDIR/"$FILENAME".mp3 -o "$2".pmp -w 480 -h 272


#clean up&#58;
if &#91; -f "$2".pmp &#93;
then
        echo "Found PMP. Cleaning up temp files."
        rm $TEMPDIR/"$FILENAME".264.txt $TEMPDIR/"$FILENAME".264 $TEMPDIR/"$FILENAME".mp3 "$2".temp
        exit 0
fi

echo "**********************************************"
echo "PMP file wasn't found. Temp files not deleted."
echo "**********************************************"
There is obviously quite a bit of custom stuff in there (I use /tmp for reading to the muxer because it's on a fast SSD), but the general jist should help people get faster 2 pass encodes. The first mencoder line is where the real performance improvement kicks in (i.e. using (num cores + 1) threads with the OS installed mencoder + recent x264 library).

If anyone needs help getting their own script working, shout and I'll try to help out.
Post Reply