Stupid video tricks with mplayer and mencoder
For people out there as lazy as I am (and by lazy, I mean "will spend four hours searching forums via google to find someone else who wanted to accomplish something tricky with one command line, and asked smarter people rather than dig through documentation to come up with the solution") I'm putting together a short list of simple but (imho) interesting things to do with mplayer and mencoder because I have had to do them at one point or another, and why should you suffer the pain of broken google links and forced forum registrations?
First, get mplayer. I'm not going into the esoterics of how to set it up for your system, I use windows and cygwin, and the latest windows binary with the all codecs package works for me.
And now, in no particular order...
Converting a video file of arbitrary format to a sequence of images
- Creating a flash video (.flv) file for web streaming
- From a video source
mencoder inputfile -ffourcc FLV1 -of lavf -ovc lavc -lavcopts vcodec=flv:acodec=mp3:abitrate=56 -srate 22050 -o outputfile
From a sequence of images
mencoder mf://*.png -mf w=360:h=240:fps=12:type=png -of lavf -ffourcc FLV1 -ovc lavc -lavcopts vcodec=flv:acodec=mp3:abitrate=56 -srate 22050 -o outputfile
Obviously, replace the width, height, and frames per second above with the w/h/fps of your video. If you're using jpegs, use '*.jpeg' and 'type=jpeg' instead of png above. If you don't have any audio, use this:
mencoder mf://*.png -mf w=360:h=240:fps=12:type=png -of lavf -ffourcc FLV1 -ovc lavc -lavcopts vcodec=flv -o outputfile
- Creating a flash player for your streaming .flv file
- Jeroen's Free Flash Video Player
I really shouldn't have to say anything else about this great offering, the documentation in the zip file and his web page tell you everything you need to know. Basically once you have a .flv file, you want to embed it in flash (.swf) or, better yet, stream it off a server to avoid the lengthy download. Most users out there are able to view flash, and developers who post video in other formats (asf, quicktime, or whatever) have problems with some percentage of browsers, depending on their audience. Using flash avoids this issue, and using flv lets you stream the video without the expense of a dedicated streaming server. But coding a player from scratch is a pain in the ass, and although I attempted a compile of Ming for windows to try and use Klaus's method I realized (again, being lazy) there was an even easier way. Steal Jeroen's terrific code, point it at your .flv and you're done! He even gives you the .fla file if you want to mess with the flash application and integrate it with your own. The controls and UI are clean, and it's free for non-commercial use (donation for commercial purposes).
h o m e
b l o g
s o f t w a r e
t h i n g s