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.


No comments: