Posts

Showing posts from 2011

Using ffmpeg to manipulate audio and video files

Image
INTRODUCTION I recently became curious about converting between video formats, wondering if there was anything I could do to reduce the size of the various .mpg, .flv, .avi and .mov files that I have lying around. I also wondered if it would be possible to convert some of these files to the .3gp format used by 3G cellphones, and if it would be possible to rip a DVD-Video to DivX. Finally, I wanted to know if I could rip DVDs of concerts and operas that I have and listen to them on my MP3 player. Best of all would be the ability to do all of this with a single tool.

Batch resize photos

One of the things I like best about linux is that there exists a one-liner that would take ages to complete using free programs. Commercially available programs does certainly do but, they are commercial! . When you take pictures with your camera, smartphone or whatever, you will have files of at least 1-2 MB. When you take a lot of them, and want to upload them to web albums (e.g., Picasa web, or Flickr) then you would have trouble uploading all of them. For web viewing, resizing them is a great idea. To quickly resize all the pictures, use the following (ImageMagick has to be installed to be able to do this): mogrify -resize 640 *.jpg

Batch rename files

When renaming a number of files at the same time, it is more convenient to use a GUI for the job. Métamorphose is one such program that does the job brillianty, and freely. There are others Flash Renamer was another (not free) great program. However, sometimes it is fun to do the same stuff using command-line. Below are a couple of ways to do batch renaming.

Securely delete files in a harddisk

The following command will erase files in the entire disk. So be careful when using this. I once accidentally erased a partition other than the one I intended. Make sure the sd# is correct. shred -vfz -n 10 /dev/sd# /dev/sd# is the entire harddisk. -n 10 refer to the passes the entire harddisk is overwritten with zeros (-z). -f tells shred to force the write by changing the permissions wherever necessary.

Apple Keyboard on PC - Getting the keys to work

Enabling Buttons on Apple Keyboard in Windows apple-keyboard I recently picked up, and am liking, the new “wafer thin” aluminum keyboard from Apple. Its very small, I like the key action and it’s very solid considering it’s size and thickness. But, I use it on Windows, and there’s no driver available other than the standard keyboard one, so the extra keys like media controls aren’t enabled. I came across a freeware macro program called AutoHotKey that works very nicely, and wrote up a few little scripts for it. You can download AutoHotKey and run the scripts yourself, or you can download the compiled version here [enable_mac_aluminum.zip, 193KB] and just pop it into your Startup folder.

Downloading from web folders without index.html file

Using the following wget 1-liners, it is possible to download a folders/files when there is no index.html files present. wget -r --no-parent http://www.site.com/folder_with_no_index/ (tested and working) wget -r -nH --cut-dirs=2 --no-parent --reject="index.html*" http://mysite.com/dir1/dir2/data

Count number of lines in a file

The following counts the number of lines in a given file: sed -n '$=' NAP_Books.txt

Delete lines based on a length limit

The following command deletes lines which have less than 10 characters. sed '/.\{10\}/!d'

Create qrcode under linux

This is achieved using the following command: qrencode -o $FILENAME -l M "$MESSAGE_GOES_HERE" M is the level of error correction (L (lowest) to H(highest)). (default=L)

Webcam as barcode reader

zbar is a great program under linux to achieve this. There are two ways to scan a barcode: directly from the webcam by using zbarcam from an image of the barcaode (or qrcode): zbarimg image.png

Syncronize two folders

The following command syncronizes two folders. rsync -avr --size-only --stats /source_folder/ /destination_folder/

Compare two folders

Use the following command to compare the following folders (note the trailing /): diff -rq /folder_1/ /folder_2/

Change GNOME border width

To change border widths, simply open up the theme's Metacity XML file. For example, Human's theme is located in /usr/share/themes/$THEME_NAME/metacity-1/metacity-theme-1.xml Then, change the values in the following lines: <distance name="left_width" value="3"></distance> <distance name="right_width" value="3"></distance> <distance name="bottom_height" value="4"></distance>

Change Library Icons

1. Open a text editor (Notepad will do) 2. Go to the following Windows directory: %appdata%\microsoft\windows\libraries 3. Drag the Library icon you want to change into Notepad

Make Firefox warn when there is active download

about:config browser.download.manager.quitBehavior Change the value to 2