Skip to main content

Posts

A script to extract audio from a bunch of video files

This sript extracts the soundtrack from any video format and converts it to mp3. Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos. It works like flv to mp3, mp4 to mp3, avi to mp3 etc. ================================== #!/bin/bash # convert-video-to-mp3 v2.0 by JOnes. # This sript extracts the soundtrack from any video format and converts it to mp3. # Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos. echo -e "\nThis sript extracts the soundtrack from any video format and converts it to mp3. Put all videos in a single folder and run this script on them. This works on all kinds of video. This is specially useful on those bunch of youtube videos.\n\n" if [ ! `which mplayer` ] ; then echo -e "Install mplayer \nsudo apt-get install mplayer" exit 0 fi if [ ! `wh...

Internal Field Separator (IFS)

Internal Field Separator (IFS): This internal variable in bash shell turns out to be an indispensable tool in these days of spaces and other weird characters in filenames. Anyone who has tried to script in bash which involved accessing lot of filenames have definitely come across the problem of spaces in filenames. The problem is this. It becomes impossible to split a directory listing "ls" into filenames using just the for $i in `ls` command. And the reason is simple. The directory listing separates filenames by spaces but the filenames themselves might have spaces. So the for command cannot figure out where the filename ends and where it begins. That is where this neat trick comes in. We have to tell bash to ignore all separation symbols other than newline while splitting up the directory listing into filenames. This means each line would be a new filename. And we have to make sure that each line has a new filename. This is easily achieved by the "ls -1" command...

mplayer shortcut to change aspect ratio while playing video

The following command tells the available commands for keyboard input. mplayer -input cmdlist The keyboard shortcuts to mplayer are stored in two locations - /etc/mplayer/input.conf and ~/.mplayer I prefer editing the /etc/mplayer/input.conf. Assign shortcuts to aspect aspect ratio switching as follows switch_ratio e.g. a switch_ratio 1.3333 # 4:3 s switch_ratio 0 # switches back to original aspect ratio b switch_ratio 1.7777 # 16:9 ratio put his at the end of /etc/mplayer/input.conf.

A script to automount external USB HDD with the executable bit set

Recent releases of Ubuntu mounts external USB HDD in userspace and hence it does not set the executable bit on the drive. As a result if I try to run softwares or scripts installed in the external HDD I have to pmount it manually. So I wrote a small script which would - 1. verify that drive is mounted. 2. it is not empty(from a previous manual mount unmount cycle) 3. then unmount the drive and re-mount it in userspace with the executable bit set. I wanted this script to be minimal. So I did not make it complicated which accepts a drive LABEL from the user and uses it. Just replace your drives LABEL in place of "passport-2" in the second line of the script. So if your external drive is called Sandisk replace passport-2 with Sandisk. If it turns out that the script fails due the use of $LABEL, then replace all $LABEL in the entire script with your drive label manually. ================================== #!/bin/bash $LABEL=passport-2 cd /media # check if $LABEL exists if [ ! -...

Minimal install LaTeX without documentation

The LaTeX package for Linux is the texlive package. The normal install of texlive is huge due to the documentation included can go upto 500MB itself. A leaner latex is what we all desire. It is not possible from inside Synaptic. Use this command to install latex without docs. sudo apt-get install --no-install-recommends texlive texlive-pstricks texlive-fonts-extra prosper

How to buy a laptop

Laptop is a  very specialized piece of equipment. It has to chosen carefully in order to suit your needs and not just by looking at benchmarks. That procedure is for desktops. I will not list laptop models or vendors here because the hardware and configurations change so fast that by next day it would be outdated. To figure which ones are topping the list go to pcmag.com, laptopreviews.com But remember the your final choice might be complete different than the ones they recommend. But if you sure that this is what I need then go ahead. Now let us see how to choose the right laptop. To select a laptop answer these first 1. Why do I need it ? 2. What do I expect from it? 3. How much spending can I afford ? 4. How much battery life I want? 5. How long do I want my laptop to be mainstream? CATEGORIES : A> Business - This means you have to make presentations with it. And travel a lot. Options : Business laptops are available to suit this niche. But personally I wo...

A simple laptop battery monitor script

The script displays alert when the battery falls below 20% or charges up beyond 80% which should be the optimal range of its working. The code is as below. Just copy and paste and save as any file name but preferably battery-notify.sh. The script can independent of what name it is given. Needs to have acpi  (default install) and  notify-send installed (sudo apt-get install notify-osd). ============================================ #!/bin/bash # battery-notify v1.2 by JOnes # It is a script to monitor battery and keep it between 20% to 80% the optimal battery working range. If the battery goe beyonds the set limit it gives pop-ups every 10 seconds. No sound warning as sound can easily be muted and ignored. # Things that could be added : 1> The flexibilty of range. But it is not recommended  hence not implemented. 2> Notification in form of email or sms. 3> Sound / beep for critical state of battery. # The script goes into background. To kill it at an...

How to choose a webcam

I am biased. I prefer Linux. So i am going to talk about webcams which work in Linux. The primary driver for webcam in Linux is the UVC driver. Goto the UVC site and look for the supported hardware - http://www.ideasonboard.org/uvc/#devices Other drivers available are SPCA drivers. The official website http://www.quickcamteam.net/software/linux/drivers/spca5xx-webcam-driver . describes the installation details. For supported hardware look at - http://mxhaard.free.fr/spca5xx.html . For step by step procedure, look at the video at http://www.linuxjournal.com/video/get-your-webcam-working-gspca . For Skype tested webcams - https://wiki.ubuntu.com/SkypeWebCams For more information go to https://help.ubuntu.com/community/Webcam To test my webcam and adjust its brightness I use vlc and v4l2ucp. Cheese and v4l2upc combo can also be used. Here's what I do. (vlc needs to be installed) vlc v4l2:///dev/video0 In another terminal open v4l2ucp, the Video 4 Linux v2...