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.


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

  • 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 10
  • 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


    11
    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 8
  • 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


    8
    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 3
  • 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.


    6
    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 5
  • 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.


    5
    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 8
  • Record from a webcam, audio using ALSA encoded as MP3, video as MPEG-4.


    5
    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 5

  • 5
    for f in *;do flac -cd $f |lame -b 192 - $f.mp3;done
    nickleus · 2010-10-19 07:55:11 3
  • 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


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


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


    4
    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 3
  • 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


    4
    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 7
  • 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


    4
    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 3
  • Just give it an artist and/or song at the end of the command as shown. Show Sample Output


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


    3
    mencoder -of rawaudio -ovc copy -oac mp3lame -o output.mp3 input.avi
    ivalladt · 2009-09-15 11:28:01 3
  • 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.


    3
    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 3
  • 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.


    3
    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 6
  • Creates a new video file with video stream copied from input file and a different audio stream


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


    2
    flac -cd input.flac |lame -h - output.mp3
    nickleus · 2010-03-05 23:54:21 4
  • 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.


    2
    find . -type f -name '*.mp3' -execdir mp3gain -a '{}' +
    Mikelifeguard · 2010-03-21 22:23:44 3
  • 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


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


    2
    ls -w 1 > list.m3u
    Tungmar · 2010-08-27 07:03:17 3
  • * grep -i leaves only mp3 files (case insentitive) * sort -R randomizes list (may use GNU 'shuf' instead). * the sed command will add double quotes around each filename (needed if odd characters are present)


    2
    ls | grep -i mp3 | sort -R | sed -e 's/.*/"&"/' | xargs mpg123
    retrodanny · 2012-03-10 20:51:36 5
  • 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: http://www.control-d.com/?p=60


    1
    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 14
  • 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. (?)


    1
    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 5
  •  1 2 3 > 

What's this?

commandlinefu.com 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

Calculate N!
Same as the seq/bc solution but without bc.

set history file length
set how many commands to keep in history Default is 500 Saved in /home/$USER/.bash_history Add this to /home/$USER/.bashrc HISTFILESIZE=1000000000 HISTSIZE=1000000

Find default gateway

Batch file name renaming (copying or moving) w/ glob matching.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Upgrade all perl modules via CPAN

Happy Days
This never gets old

display typedefs, structs, unions and functions provided by a header file
will display typedefs, structs, unions and functions declared in 'stdio.h'(checkout _IO_FILE structure). It will be helpful if we want to know what a particular header file will offer to us. Command 'cpp' is GNU's C Preprocessor.

Google text-to-speech in mp3 format
Usage: t2s 'How are you?' Nice because it automatically names the mp3 file up to 15 characters Modified (uses bash manip instead of tr) t2s() { wget -q -U Mozilla -O $(cut -b 1-15

List the Sizes of Folders and Directories
I wanted an easy way to list out the sizes of directories and all of the contents of those directories recursively.


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: