Latest Entries »

#!/bin/bash

# for finding and executing music in mplayer
# replace ‘/my/Music/Collection/’with real path of the folder your music is stored. ‘/*/*/*’ are given to look into sub folders

song=$*

#for playing all songs in shuffled manner
if [[ "$song" == "all" ]];then
{
mplayer -shuffle /my/Music/Collection/* /my/Music/Collection/*/* /my/Music/Collection/*/*/* /my/Music/Collection/*/*/*/* /my/Music/Collection/*/*/*/*/* /my/Music/Collection/*/*/*/*/*/*
}
else  
#for finding and playing the song name given
{
find /my/Music/Collection/ -type f -iname “*$song*” -exec mplayer {} \;
}
fi

yt-chanrip() { for i in $(curl -s http://gdata.youtube.com/feeds/api/users/”$1″/uploads | grep -Eo “watch\?v=[^[:space:]\”\’\\]{11}” | uniq); do youtube-dl –title –no-overwrites http://youtube.com/”$i”; done }
Download Entire YouTube Channel – all of a user’s videos

create the function then run ‘yt-chanrip username’ to download that user’s entire channel.

uses youtube-dl and the GData API. similar to http://www.commandlinefu.com/commands/view/3154/download-youtube-playlist

montage 2007-08-25-3685.jpg +clone -clone 0-1 -clone 0-3 -geometry 500 -frame 5 output.jpg
 
Repeat a portrait eight times so it can be cut out from a 6″x4″ photo and used for visa or passport photos

Yes, You could do it in the GIMP or even use Inkscape to auto-align the clones, but the command line is so much easier.

NOTE: The +clone and -clone options are just to shorten the command line instead of typing the same filename eight times. It might also speed up the montage by only processing the image once, but I’m not sure. “+clone” duplicates the previous image, the following two “-clone”s duplicate the first two and then the first four images.

NOTE2: The -frame option is just so that I have some lines to cut along.

BUG: I haven’t bothered to calculate the exact geometry (width and height) of each image since that was not critical for the visa photos I need. If it matters for you, it should be easy enough to set using the -geometry flag near the end of the command. For example, if you have your DPI set to 600, you could use “-geometry 800×1200!” to make each subimage 1⅓ x 2 inches. You may want to use ImageMagick’s “-density 600″ option to put a flag in the JPEG file cuing the printer that it is a 600 DPI image.

BUG2: ImageMagick does not autorotate images based on the EXIF information. Since the portrait photo was taken with the camera sideways, I made the JPEG rotate using jhead like so: jhead -autorot 2007-08-25-3685.jpg

echo “You can simulate on-screen typing just like in the movies” | pv -qL 10

 

simulate typing

This will output the characters at 10 per second.

MIN=10;for ((i=MIN*60;i>=0;i–));do echo -ne “\r$(date -d”0+$i sec” +%H:%M:%S)”;sleep 1;done
2011-02-20 11:56:28
User: flatcap
Functions: echo sleep
11
Countdown Clock

Countdown clock – Counts down from $MIN minutes to zero.

I let the date command do the maths.

This version doesn’t use seq.

arecord -q -f cd -r 44100 -c2 -t raw | lame -S -x -h -b 128 – `date +%Y%m%d%H%M`.mp3
2009-09-25 05:32:52
User: oracular
Functions: arecord cd
10
Record microphone input and output to date stamped mp3 file

record audio notes or meetings

requires arecord and lame

run mp3gain on the resulting file to increase the volume / quality

ctrl-c to stop recording

mplayer -dumpstream -dumpfile “yourfile” -playlist “URL”

I use this command to save RTSP video streams over night from one of our national TV stations, so I won’t have to squeeze the data through my slow internet connection when I want to watch it the next day.

For ease of use, you might want to put this in a file:

#!/bin/bash

FILE=”`basename \”$1\”`”

mplayer -dumpstream -dumpfile “$FILE” -playlist “$1″

wget -q -O – `youtube-dl -b -g $url`| ffmpeg -i – -f mp3 -vn -acodec libmp3lame -| mpg123 -

This section explains how to retrieve a feed listing a specific user’s playlists. Note that some users may not have created any playlists.

To request a feed of the currently logged-in user’s playlists, send a GET request to the following URL. Note: For this request, you must provide an authentication token, which enables YouTube to identify the user.

https://gdata.youtube.com/feeds/api/users/default/playlists?v=2

To request a feed of another user’s playlists, send a GET request to the following URL. This request does not require authentication.

https://gdata.youtube.com/feeds/api/users/userId/playlists?v=2

In the URL above, you should replace the text userId with the user’s YouTube user ID. For backward compatibility purposes, the API also supports having the user’s YouTube username specified instead.

It’s a script-based alternative to online youtube-to-mp3 converters, but it’s much more faster, much more reliable and easy to customize. You don’t have to visit those spammy online converters anymore, and what’s more, you can run multiple instances of the same script so that you’ll be able to convert several youtube videos simultaneously.

I use this on my Ubuntu (Linux), but Windows and Mac users should be able to do the same by writing the equivalent shell script for their own command lines. Before you can use the script make sure you have “youtube-dl” and “ffmpeg” installed. We will use youtube-dl to download youtube videos, and ffmpeg to convert them into the mp3 format. Create a new file…

gedit youtube2mp3 

…and paste the following script:

x=~/.youtube-dl-$RANDOM-$RANDOM.flv youtube-dl --output=$x --format=18 "$1" ffmpeg -i $x -acodec libmp3lame -ac 2 -ab 128k -vn -y "$2" rm $x 

Save and close gedit. Now install the script somewhere easily accessible.

sudo install youtube2mp3 /usr/local/bin 

Now you can convert youtube videos into mp3 files by using the following command (including the double quotes):

youtube2mp3 "youtube-link" "mp3-file.mp3"


 
 

For this script to work, ffmpeg must be able to use the libmp3lame codec. As far as I know this is not provided with the ffmpeg on Ubuntu, but there are many tutorials on the internet that could help you do this. Also, the script is very verbose. Use the following command if you don’t want to see all the messages on your screen:

youtube2mp3 "youtube-link" "mp3-file.mp3" > /dev/null


You can also use the following command to make the script run in the background. This way you will be able to run multiple instances of the script at the same time.

youtube2mp3 "youtube-link" "mp3-file.mp3" > /dev/null & 

 

How it works

The way this script works is really simple. First it downloads the youtube video into a temporary file, converts the video to mp3 and then deletes the temporary file. Let’s go through this script step-by-step.

1. The first line of the script assigns a random .flv filename to the variable $x.

2. The second line downloads the youtube video into the temporary file named $x. It automatically downloads the HQ version of the video if it’s available.

3. The third line extracts the audio from the video and converts it into an mp3 file with the filename you specified.

4. The last line removes the temporary file created in step 2.

 
 
Follow

Get every new post delivered to your Inbox.