Commands tagged mp3 (58)

  • youtube-dl has this functionality built in. If you're running an older version of youtube-dl, you can update it using `youtube-dl -U` (although if you have an older version, it probably doesn't download youtube videos anyway.) youtube-dl --help will show you other options that may come in useful.

    youtube-dl -t --extract-audio --audio-format mp3 YOUTUBE_URL_HERE
    menachem · 2011-11-15 20:11:20 12

  • 16
    for file in *.flac; do flac -cd "$file" | lame -q 0 --vbr-new -V 0 - "${file%.flac}.mp3"; done
    irae · 2010-04-11 05:35:06 7
  • 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 Show Sample Output

    arecord -q -f cd -r 44100 -c2 -t raw | lame -S -x -h -b 128 - `date +%Y%m%d%H%M`.mp3
    oracular · 2009-09-25 05:32:52 4
  • find . -type f -iname '*.flac' # searches from the current folder recursively for .flac audio files | # the output (a .flac audio files with relative path from ./ ) is piped to while read FILE; do FILENAME="${FILE%.*}"; flac -cd "$FILE" | lame -b 192 - "${FILENAME}.mp3"; done # for each line on the list: # FILE gets the file with .flac extension and relative path # FILENAME gets FILE without the .flac extension # run flac for that FILE with output piped to lame conversion to mp3 using 192Kb bitrate Show Sample Output

    find . -type f -iname '*.flac' | while read FILE; do FILENAME="${FILE%.*}"; flac -cd "$FILE" | lame -b 192 - "${FILENAME}.mp3"; done
    paulochf · 2010-08-15 19:02:19 2
  • Record audio to MP3 stream and video to MPEG-4 stream from webcam to AVI file using mencoder. Gives floating point exception in some mencoder versions.

    mencoder tv:// -tv driver=v4l2:width=800:height=600:device=/dev/video0:fps=30:outfmt=yuy2:forceaudio:alsa:adevice=hw.2,0 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1800 -ffourcc xvid -oac mp3lame -lameopts cbr=128 -o output.avi
    ivalladt · 2009-09-15 19:46:06 3
  • This will mv all your mp3 files in the current directory to $ARTIST/$ALBUM/$NAME.mp3 Make sure not to use sudo - as some weird things can happen if the mp3 file doesn't have id3 tags.

    for file in *.mp3;do mkdir -p "$(mp3info -p "%a/%l" "$file")" && ln -s "$file" "$(mp3info -p "%a/%l/%t.mp3" "$file")";done
    matthewbauer · 2009-08-05 17:04:34 6
  • Record from a webcam, audio using ALSA encoded as MP3, video as MPEG-4.

    ffmpeg -f alsa -r 16000 -i hw:2,0 -f video4linux2 -s 800x600 -i /dev/video0 -r 30 -f avi -vcodec mpeg4 -vtag xvid -sameq -acodec libmp3lame -ab 96k output.avi
    ivalladt · 2009-09-15 17:03:25 2

  • 5
    for f in *;do flac -cd $f |lame -b 192 - $f.mp3;done
    nickleus · 2010-10-19 07:55:11 2
  • Some MP3s come with tags that don't work with all players. Also, some good tag editors like, EasyTAG output tags that don't work with all players. For example, EasyTAG saves the genre as a numeric field, which is not used correctly in Sansa MP3 players. This command corrects the ID3 tags in MP3 files using mid3iconv, which comes with mutagen. To install Mutagen on Fedora use "yum install python-mutagen" Show Sample Output

    find -iname '*mp3' -exec mid3iconv {} \;
    schlaegel · 2010-10-29 05:35:46 4
  • Record audio to an MP3 file via ALSA. Adjust -i argument according to arecord -l output.

    ffmpeg -f alsa -ac 2 -i hw:1,0 -acodec libmp3lame -ab 96k output.mp3
    ivalladt · 2009-09-16 12:45:44 2
  • Rip DVD to YouTube ready AVI file, using MPEG-4 video codec and MP3 audio codec. Resizes to 320x240 and deinterlaces as needed.

    mencoder -oac mp3lame -lameopts cbr=128 -ovc lavc -lavcopts vcodec=mpeg4 -ffourcc xvid -vf scale=320:-2,expand=:240:::1 -o output.avi dvd://0
    ivalladt · 2009-09-25 19:29:25 2
  • Ever gone to a site that has an MP3 embedded into a pesky flash player, but no download link? Well, this one-liner will yank the names of those tunes straight out of FF's cache in a nice, easy to read list. What you do with them after that is *ahem* no concern of mine. ;) Show Sample Output

    for i in `ls ~/.mozilla/firefox/*/Cache`; do file $i | grep -i mpeg | awk '{print $1}' | sed s/.$//; done
    BoxingOctopus · 2010-04-11 23:14:18 6
  • Creates a 5 minute flv file, with the given sequence of images and audio with 0.5 fps. The images were created using the following command: for x in `seq 0 300`; do cp ../head.PNG head-`printf '%03d' $x`.png; done You can also inject metadata to seek easier using yamdi as follows: yamdi -i muxed.flv -o video.flv Show Sample Output

    ffmpeg -t 300 -r '0.5' -i head-%03d.png -i ../TvQuran.com__144.mp3 -acodec copy muxed.flv
    pykler · 2010-10-07 16:29:08 2
  • Just give it an artist and/or song at the end of the command as shown. Show Sample Output

    python2 -c 'import urllib2 as u, sys as s, json as j, subprocess as p;["mplayer", u.urlopen(j.loads(u.urlopen("" % "+".join(s.argv[1:])).read())["songs"][0]["url"]).geturl().split("#")[0]])' lenny kravitz fly away
    nagev · 2013-09-21 02:25:51 7
  • Extracts an MP3 encoded audio stream from an input video file.

    mencoder -of rawaudio -ovc copy -oac mp3lame -o output.mp3 input.avi
    ivalladt · 2009-09-15 11:28:01 2
  • This uses mpg123 to convert the files to wav before burning, but you can use mplayer or mencoder or ffmpeg or lame with the --decode option, or whatever you like.

    alias burnaudiocd='mkdir ./temp && for i in *.[Mm][Pp]3;do mpg123 -w "./temp/${i%%.*}.wav" "$i";done;cdrecord -pad ./temp/* && rm -r ./temp'
    eightmillion · 2009-11-21 19:57:18 2
  • Takes two input video files and an external audio track and encodes them together to an MPEG-4 DivX output video file with the correct size ready for uploading.

    mencoder -audiofile input.mp3 -oac copy -ovc lavc -lavcopts vcodec=mpeg4 -ffourcc xvid -vf scale=320:240,harddup input1.avi input2.avi -o output.avi
    ivalladt · 2010-01-28 21:14:03 5
  • Creates a new video file with video stream copied from input file and a different audio stream

    mencoder -ovc copy -audiofile input.mp3 -oac copy input.avi -o output.avi
    ivalladt · 2009-09-15 11:26:05 2
  • if you haven't already done so, install lame and flac: sudo apt-get install lame flac Show Sample Output

    flac -cd input.flac |lame -h - output.mp3
    nickleus · 2010-03-05 23:54:21 3
  • This normalizes volume in your mp3 library, but uses mp3gain's "album" mode. This applies a gain change to all files from each directory (which are presumed to be from the same album) - so their volume relative to one another is changed, while the average album volume is normalized. This is done because if one track from an album is quieter or louder than the others, it was probably meant to be that way.

    find . -type f -name '*.mp3' -execdir mp3gain -a '{}' +
    Mikelifeguard · 2010-03-21 22:23:44 2
  • Grab a list of MP3s (with full path) out of Firefox's cache Ever gone to a site that has an MP3 embedded into a pesky flash player, but no download link? Well, this one-liner will yank the *full path* of those tunes straight out of FF's cache in a clean list. Shorter and Intuitive version of the command submitted by (TuxOtaku) Show Sample Output

    find ~/.mozilla/firefox/*/Cache -exec file {} \; | awk -F ': ' 'tolower($2)~/mpeg/{print $1}'
    sata · 2010-04-19 06:59:55 2
  • A short variant if you have only one directory whit only audio files in it.

    ls -w 1 > list.m3u
    Tungmar · 2010-08-27 07:03:17 2
  • I use this to convert mp3 files to m4a files that can be used as ringtones on the iPhone. I've documented the process here:

    mplayer -vo null -vc null -ao pcm:fast:file=file.wav file.mp3; faac -b 128 -c 44100 -w file.wav
    llama · 2009-03-24 21:04:35 12
  • Gives MPEG-4/DivX output video file ready for uploading to YouTube from FLV file downloaded from the site and your own subtitle file UTF-8 encoded. No resizing needed. (?)

    mencoder -sub subs.ssa -utf8 -subfont-text-scale 4 -oac mp3lame -lameopts cbr=128 -ovc lavc -lavcopts vcodec=mpeg4 -ffourcc xvid -o output.avi input.flv
    ivalladt · 2009-09-12 09:24:24 4
  • Renames duplicates from MusicBrainz Picard, so you get the latest copy and not a bunch of duplicates. Show Sample Output

    for i in */*/*\(1\)*; do mv -f "$i" "${i/ (1)}"; done
    magenine · 2010-01-30 03:11:55 2
  •  1 2 3 > 

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Print every Nth line
Sometimes commands give you too much feedback. Perhaps 1/100th might be enough. If so, every() is for you. $ my_verbose_command | every 100 will print every 100th line of output. Specifically, it will print lines 100, 200, 300, etc If you use a negative argument it will print the *first* of a block, $ my_verbose_command | every -100 It will print lines 1, 101, 201, 301, etc The function wraps up this useful sed snippet: $ ... | sed -n '0~100p' don't print anything by default $ sed -n starting at line 0, then every hundred lines ( ~100 ) print. $ '0~100p' There's also some bash magic to test if the number is negative: we want character 0, length 1, of variable N. $ ${N:0:1} If it *is* negative, strip off the first character ${N:1} is character 1 onwards (second actual character).

convert ascii string to hex
Even adds a newline.

Exclude svn directories with grep
exclude-dir option requires grep 2.5.3

Remove spaces from filenames - through a whole directory tree.
An example of zsh glob qualifiers.

Get size of terminal
See the cols and lines and make sure the console it correctly configured for the screen size.

Google Spell Checker
I took matthewbauer's cool one-liner and rewrote it as a shell function that returns all the suggestions or outputs "OK" if it doesn't find anything wrong. It should work on ksh, zsh, and bash. Users that don't have tee can leave that part off like this: $spellcheck(){ typeset y=$@;curl -sd "$y"|sed -n '/s="[1-9]"/{s/]*>/ /g;s/\t/ /g;s/ *\(.*\)/Suggestions: \1\n/g;p}';}

Tired of switching between proxy and no proxy? here's the solution.
Replace with your largest local subnet. replace with your proxy information.. Note this only works with a proxy server configured for passive setup.. Now your firefox transparently proxy's stuff destined outside your network.. and Doesn't proxy stuff inside your network. as well as all your other favorite web applications. curl, wget, aria2 ect.

stringContains: Determining if a String Contains a Substring

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Puts every word from a file into a new line
Simply translates whitespace to newlines. Could be enhanced to compress out extra newlines, but that might be better handled in the next tool down the pipe, with eg uniq(1).

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: