Showing posts with label Video. Show all posts
Showing posts with label Video. Show all posts

Thursday, February 26, 2009

Watch Battlestar Galactica on Your Phone.

I have a crappy Nokia flip phone. There is nothing special about it. It does have a camera and can take really poor quality video if you happen to be standing in reasonable light. It does have have a media player to watch these videos which are formatted in .3gp, which I guess is very common in these small portable devices. I also have a 1 Gb micro SD card for storage on my phone. So far nothing too outlandish about this phone or it's features. These features are found on the most basic "free" phone given to you by carriers when you sign away your 1st born with one of their contracts. This is definately not a iPhone or some other overpriced "smartphone".

Anyway I wanted to see if I could watch Battlestar Galactica on my phone while on the bus to work each morning and found that it's not that difficult with Free open source software. My Battlestar Galactica episodes in .avi format, so I just needed a way to convert my .avi file to .3pg. Then put that newly created .3pg file on my microSD card and fire up my media player on my phone and I should be good to go. Here is how I did it.

Install the following: ffmpeg, amrnb, amrwb and sox. In debian based distros it's pretty straight forward with apt-get and each of these applications are in the Ubuntu repos. Then issue the follow command:

ffmpeg -i inputfile.avi -s qcif -vcodec h263 -acodec aac -ac 1 -ar 44100 -r 25 -ab 192 -y outputfile.3gp
Here is a brief breakdown of the ffmpeg command. You can find more detail on the ffmpeg man page.

-i input file
-s video size (qcif=176x144, see man page)
-vcodec video codec (needed for the conversion)
-acodec audio codec
-ac # if audio channels
-ar Audio frequency
-r Frame rate
-ab audio bitrate
-y output file

You may have to fiddle with the frame rate a bit to what works best for you on your device. I've converted one file and played it on 2 different devices and the audio and video sync was off on one and not the other, which tells me that something funky is going on with different media players. I would recommend that you keep the audio quality (freq and bitrate) high because the speakers on most of these low quality device are pretty crappy. You will want to have goo sound quality if you expect to hear anything.

A one hr long episode of Battlestar Galatica in .avi is about 350 mb, once converted to .3pg with the above configuration rates is about 80 mb.

If you have mpeg files you would like to convert, use the following:

ffmpeg -i inputfile.mpg -s qcif -vcodec h263 -acodec aac -ac 1 -ar 8000 -r 25 -ab 32 -y outputfile.3gp
If you're try to get videos off your phone to watch on your computer, here convert your files the other way.

ffmpeg -i clip.3gp -f avi -vcodec xvid -acodec mp3 -ar 22050 file.avi
Enjoy!

Monday, September 3, 2007

Images and Videos on the Command Line? YES!

Want to watch a movie? Perhaps you would like to view and edit your photographs? It's easier than you may think using the command line and framebuffer.

You will first need to activate framebuffer in grub at start up on your favorite Linux distro. You will need to edit the /boot/grub/menu.lst file. I use nano to edit files but any will do, so I type:
sudo nano /boot/grub/menu.lst

You'll need root privileges to edit menu.lst. Find the line that looks like the following

kernel /boot/vmlinuz-2.6.17-12-generic root=/dev/hdb1 ro quiet splash

Yours may look a little different depending on your distro or kernel being used, but it should start with 'kernel' and have similar information. At the very end of the line add the following, 'vga=791', so that it looks like this:

kernel /boot/vmlinuz-2.6.17-12-generic root=/dev/hdb1 ro quiet splash vga=791

The 'vga=791' will activate framebuffer to run at 1024x768x64k resolution, here are other resolution options. Just replace the '791' with whatever will work with your video card and monitor.

# VESA framebuffer console @ 1024x768x64k
# vga=791
# VESA framebuffer console @ 1024x768x32k
# vga=790
# VESA framebuffer console @ 1024x768x256
# vga=773
# VESA framebuffer console @ 800x600x64k
# vga=788
# VESA framebuffer console @ 800x600x32k
# vga=787
# VESA framebuffer console @ 800x600x256
# vga=771
# VESA framebuffer console @ 640x480x64k
# vga=785
# VESA framebuffer console @ 640x480x32k
# vga=784
# VESA framebuffer console @ 640x480x256
# vga=769



Now reboot so your kernel can start in framebuffer.

To watch movies, install mplayer-nogui, in Ubuntu simply type:

sudo apt-get install mplayer-nogui

Once installed go to the directory of your favorite video and type:

sudo mplayer -vo sdl videofile.avi

Shazaam! There you go. Make sure you have the necessary codecs/plugins to view your video format. But now you want to watch a DVD do you? Well then type:

sudo mplayer -vo sdl dvd://1

The '1' on the end indicates the title number on the DVD.

Say you want to view your Aunt Thema's lastest Christmas picture. You'll need to install 'fbi'. No, not the government agency, but the framebuffer image viewer. In Ubuntu simply type:

sudo apt-get install fbi

to install the viewer.

Next go to a directory containing Aunt Thema's pics and type:

fbi *

You should now be able to see Thema in all her glory. Use the space bar to view the next image.

If you want to edit Thema's picture, perhaps you would like to add some contrast or brighten the picture up a bit, then imagemagick is the tool of for you. You guessed it...

sudo apt-get install imagemagick

will install the app. I'll go into some of the cooler features of imagemagick, especially it's convert command in a later blog, but for now you can read the man page for info as to how to use imagemagick (man imagemagick).

No more do you need to rely on the heavy GUI environment for your graphical needs, the CLI is here for you.

Enjoy!