Converting movies to flv format.
August 19, 2007
I’ve decided to convert all movies to flv (flash video) format before saving them, inna youtube stylee.
This page seems to spell out how to do that – there’s a lot involved. Here goes.
Step 1: Get the source for ffmpeg from subversion. It involves a checkout, which seems odd…i don’t want to check anything back in (real open source coding is still scary to me), i just want a copy. Ah well, i’ll follow the instructions.
I made a new folder outside of my rails app (i hope this was the right thing to do) and in it typed this at the command line:
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
This copied over a load of stuff. Next step is to configure and compile it. This sounds complicated. First hurdle – the instructions are all for mac!
Mencoder looks promising as well…
OK, going with a different guide -
Step 1 – mencoder. DLd and installed mplayer and mencoder and associated codecs.
Step 2 – test mencoder, with this, at the command line:
mencoder input.avi -o output.avi -oac lavc -ovc lavc -lavcopts vcodec=xvid:acodec=mp3 > output.txt
I get this error:
Cannot find codec ‘xvid’ in libavcodec…
Couldn’t open video filter ‘lavc’.
Failed to open the encoder.
After a bit of mucking around i got it to work (blob_woman2.avi is my test video, converted to output.avi using the lavc codec). I had to remove the -oac lavc bit, and the -lavcopts vcodec etc bit as well.
mencoder blob_woman2.avi -ovc lavc -o output.avi > output.txt
It reduced to about 10% of previous size which is impressive, but i think it was an unoptimal avi in the first place. Let’s try with a 237 meg divx movie now: ok, it’s working….i’m getting messages about duplicate frames andthe occasional missing frame but it seems to be working away there…Finished! 237meg down to 130meg, that’s pretty good! I had to specify an audio codec as well this time: lavc as well.
Following the instructions in the guide, the next thing to do is to incorporate it into rails. Dmytro, who’s blog i’m using, sets up a helper method that takes a command line instruction, and generates a new type of exception (which is also defined but simply extends StandardError). To be continued.