ffmpeg with h.264 3gp/amr xvid lame/mp3 a52/ac3 dts aac

June 17th, 2008 by thejerk

I was going through the source for mythweb to find a good spot to insert code to setup and return VLC VOD links instead of simple http streams.  I followed the code for flash video .flv on the fly conversion and streaming with http range based seeking.  I was surpised to find a very simple and elegant ffmpeg based  CGI script doing all the work.  In /var/www/mythweb/modules/stream/handler.pl I found the following:

elsif ($ENV{'REQUEST_URI'} =~ /\.flv$/i) {
# Print the movie
$ffmpeg_pid = open(DATA,
"$ffmpeg -y -i ".shell_escape($filename)
.' -s '.shell_escape("${width}x$height")
.' -r 24 -f flv -ac 2 -ar 11025
.' -ab '.shell_escape("${abitrate}k")
.' -b '.shell_escape("${vbitrate}k")
.' /dev/stdout 2>/dev/null |'
);
unless ($ffmpeg_pid) {
print header(),
"Can't do ffmpeg:  $!";
exit;
}
print header(-type => 'video/x-flv');
my $buffer;
while (read DATA, $buffer, 262144) {
print $buffer;
}
close DATA;
exit;
}

Pretty cool. I’m going to use this as a template for generating VLC VOD media on the fly using nectcat. More to follow.

Anyway what happened is that I realized the flash video was working great but there was no audio. Playing with ffmpeg on the command line using the parameters above clued me in. ffmpeg didn’t know how to decode AC3 and it also didn’t know how to encode mp3.

I was surpised to find that the Medibuntu ffmpeg was missing some codecs that I know ffmpeg supports. I looked around the web for a way to compile ffmpeg with the missing codecs.

I found a bunch of apt-get source ffmpeg style how to’s and figured out the DEBIAN_BUILD_OPTIONS=”risky” part.

Had to install fakeroot to make the source by hand.

Another site had the details for getting AMR/3GP/3GPP/3GP2 AKA AMR narrow band and wide band. Found the how to for ffmpeg for Debian at this page. And the HOWTO with AMR at this page

I performed the following:

apt-get build-dep ffmpeg
aptitude install fakeroot liblame-dev liba52-0.7.4 liba52-dev libdts-dev libfaac0 libfaac0-dev libfaad0 libfaad-dev libxvidcore4 libxvidcore4-dev libx264-57 libx264-dev
apt-get source ffmpeg
wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip
wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip
unzip -q 26104-510.zip
unzip -q 26204-510.zip
cd ffmpeg-0.cvs20070307
mkdir libavcodec/amr_float
mkdir libavcodec/amrwb_float
cd libavcodec/amr_float
unzip -q ../../../26104-510_ANSI_C_source_code.zip
cd ../../libavcodev/amrwb_float
unzip -q ../../../26204-510_ANSI-C_source_code.zip
cd ../..

Ended up changing the following section in ffmpeg-0.cvs20070307/debian/rules in the source directory from this:

confflags += --enable-gpl --enable-pp --enable-swscaler --enable-pthreads
confflags += --enable-libvorbis --enable-libtheora --enable-libogg --enable-libgsm

to this:

confflags += --enable-gpl --enable-pp --enable-swscaler --enable-pthreads
confflags += --enable-libvorbis --enable-libtheora --enable-libogg --enable-libg
confflags += --enable-x264 --enable-liba52 --enable-libdts --enable-amr_nb
confflags += --enable-amr_wb

And finally I performed the following in the extracted source directory:

DEBIAN_BUILD_OPTIONS="risky" fakeroot debian/rules binary
cd ..
dpkg -i *.deb
Blogged with the Flock Browser

Tags: , , , , , , , , , , , , , , ,

The Top 10 Commands In Your Shell History

May 8th, 2008 by thejerk

The Prokrammer » Blog Archive » Top 10 Commands In Your Shell History

I saw this post about the top ten commands in your shell history.  The blog author wrote the query like so:

<quote>
$  history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn
| head
114 cd
84 ls
79 irb
39 git
31 pedump
10 ps
10 objdump
10 e
8 ssh
8 dd

</quote>

I thought I could write something simpler using the base utilities:

<quote>
~ $ history 1000|sort -k2,2 | uniq -c -f1 | sort -rn|head|awk ‘{print $1″ “$3}’
4 ls
3 du
2 sudo
2 open
2 wget
2 rm
2 less
2 df
2 top
1 history
</quote>

But all I could think of after I ran my version was how pitiful my command history looked compared to the other guys.  I know I have need to tweak my bashrc so it merges my history across open shells.  But even taking that into consideration I realized that I am I doing all of my programming in the GUI.

Dang.

Blogged with the Flock Browser

Tags:

The Brass Man by Neal Asher

May 29th, 2007 by thejerk

picture

Another book in the Polity series by Neal Asher.  Done as a tip of the iceberg story about a Pandora’s box of nanotechnology potentially created by an unknown ancient race to destroy any form of life uncautious enough to use it.

I found the author’s blog, The Skinner , through the author’s Wikipedia entry, Neal Asher.  I also found some more of his books that I haven’t read and didn’t know about.  As well as two free online stories by Neal Asher and one by another cyberpunk author, David Marusek, at Free Speculative Fiction Online: Links to Science Fiction & Fantasy Stories Online Website.

technorati tags:

Blogged with Flock

The Amy Fisher Story

December 27th, 2005 by thejerk

By Amy Fisher

Excellent, excellent, novel. It’s nice to hear the story from the source.

The Diamond Age or A Young Lady’s Illustrated Primer

December 27th, 2005 by thejerk

By Neal Stephenson

A must read for any scifi aficionado who made the mistake of reading Prey without having read The Diamond Age first. This is the same author of Snow Crash, Zodiac, Crytonomicon, and The Baroque Age series of fictional first person accounts of real history.

Counting Heads

December 27th, 2005 by thejerk

Nice first scifi novel by David Marusek

Covers all the bases of the near future. Even an unexpected one of what happens to the little people when the greedy become all powerful resource hogs whose only enemies are other powerful entities working at cross purposes.

Skinner

December 27th, 2005 by thejerk

Skinner by Neal Asher

Excellent scifi that covers an issue that is only now being imagined in the collective unconscious. Just because you can live forever doesn’t necessarily mean you will want to or have the will to after a couple of centuries of life kicking you around. Covers many bases and is an excellent follow up to his first scifi novel.

Prey

September 8th, 2005 by thejerk

Formulatic horror movie stuff with a worthwhile introduction to nanotechnology for the layman sprinkled liberally throughout. Worth a read just for the basics of nanotechnology wrapped up very nicely in a techno-thriller.

For a more entertaining and insightful and intelligent introduction to the potentials of nanotechnology check out “The Diamond Age or A Young Lady’s Illustrated Primer”
by Neal Stephenson.

Tenesse House

August 20th, 2005 by thejerk

Located on the corner of Spring and Wooster in SoHo. This place is great for early to late night hanging out around a dinner table and gorging yourself on drinks and food. The portions are ginormous and greasy so watch out because that the regular size. The next size up on portions is called unbelievable or incredible. Anyway it’s good beer and drink and good food. Not the place you want to go on a diet. Especially since they bread and deep fry the crab cakes and give you a choice of vegetarian chili or pulled chicken or pulled pork as a free included toping that comes with your nachos. A little on the expensive side.

The Secret Language of Birthdays

July 7th, 2005 by thejerk

Want to know what makes someone tick? Or maybe you just want to know the personality type of everyone you know without having to ask too many questions. This is the book for you.

If you doubt the science just flip to the pages for your birthday to get that creepy feeling like someone’s been telling all your secrets and they have gotten in your head.

Better to know now if your significant other or friend is predisposed to being a complete lunatic or just a quirky bastard or a weepy tragic mf or like me a success at being who ever I want to be.

It would be a big help at the moment if I could figure out who I want to be. A little too much soul searching lately has me making mental downward spirals out of the raison d’être. Sort of like a dog periodically biting the imaginary fleas and occasionally chasing it’s tail.