Posts Tagged ‘mp3’
Just finished watching twin peaks…
say -v Alex "leits. ni. kcab. moc. oot. gni-og. sih. kile. hewew. . mug. tath. zoon. doog. tahg. hveye." -o foo.aiff && sox -V foo.aiff bar.wav reverse && mplayer bar.wav && rm -f foo.aiff bar.wav
I had a really annoying time trying to get Safari to load and play a small audio clip (mp3) I’d posted. The clip is only 2 seconds. Here’s the HTML I was using
<audio src="audio.mp3" autoplay preload="auto" controls loop>
But this resulting in nothing. Upon closer inspection I found out the the “onstalled” even was being fired so I added an “onstalled” even handler to try to load the clip again:
<audio onstalled="this.load();" src="audio.mp3" autoplay preload="auto" controls loop>
But this was to no avail, the “onstalled” event just fired each time recursively.
In the end I gave up on Safari’s ability to play/load small mp3 files. I’m not sure what the problem is since quicktime played the file fine. Also if my html and audio.mp3 files lived locally, Safari played it correctly.
I instead made use of HTML5 ability to specify fallback sources. For this I converted my mp3 file to a m4a:
First convert to wav with mplayer:
mplayer -quiet -vo null -vc dummy -ao pcm:waveheader:file="audio.wav" "audio.mp3"
Then convert to m4a with faac:
faac -o audio.m4a audio.wav
Finally use the .m4a file as a fallback source in the audio tag:
<audio autoplay preload="auto" controls loop> <source src="audio.mp3" > <source src="audio.m4a" > <audio>
When ever I set up the laptop with those little computer speakers I have to check the stereo setup: so I’m sure the right speaker is on the right and the left on the left. On the Mac I do this by going to System Preferences > Sound then switching the sound all the way to the right and flipping the volume up and down to make little bleeps. Then the same for the left.
Finally here’s a definitive webapp solution:
Found this resource about using mplayer or ffmpeg to extract the audio of an flv flash movie (like those from youtube etc.) and save it as an mp3 file.
I adapted the ffmpeg version with the
-ab flag that allows me to specify audio bitrate:
ffmpeg -i input.flv -f mp3 -ab 192 -vn ouputfile.mp3
Change the 192 to whatever bitrate you want.
Issue this command in a terminal to download all mp3s linked to on a page using wget
wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off [url of website]
OR if you want to download all linked mp3s from multiple pages then make a text file containing each url on a separate line, then issue:
wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off -i ~/mp3blogs.txt
If the site is behind basic http authentication you can use something like:
wget --http-user [username] --http-passwd [passwd] -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off "[url]"
This could probably get more elaborate and use the containing directories to set album and artist tags. For now here is a bash script to set the titles based on the current file name. This uses a program called
artist="Artist" album="Ablum" for filename in *.mp3; do title=`echo $filename | sed 's/.mp3$//g'`; tagmp3 set "%A:$arrtist %a:$album %t:$title" $filename; done
lame on a bunch of wav files I ended up with tons of files named:
song1.wav.mp3 song2.wav.mp3 song3.wav.mp3 song4.wav.mp3 ...
Now, obviously I could have avoided this in this case with the proper options and arguments to
lame, but it’s all in hindsight.
Here’s the bash line I use to strip out
.wav from the middle of all these files in the current directory:
for filename in *.mp3; do newname=`echo $filename | sed 's/\.wav\.mp3$/.mp3/g'`; mv $filename $newname; done
It’s long for one line but I think it’s still understandable and manageable. The result is:
song1.mp3 song2.mp3 song3.mp3 song4.mp3 ...
Note: I notice that I’m being overly carefully with my regexes and wildcards in the example above but it should make it more clear how to adapt it to your case.
Here’s the command I used to generate my new custom outgoing message for my iPhone’s voicemail:
say -o outgoing-message.aiff -v Vicki ". . . Ahlec Jacobson \ did not answer. Please try emailing him, at alec jacobson at \ gee mail dot com. That's A. . L. . E. . C. . J. . A. . C. . O. . B. . \ S. . O. . N. . AT. GEE MAIL. DOT. COM. Or send a text message \ to this number. Or finally leave a message after the beep. \ Thank you. . . . . . . . . Good bye. . . ."
Here’s the result after I used
lame to convert the aiff file to mp3 using this simple command:
lame outgoing-message.aiff outgoing-message.mp3
I gave up using iTunes to play music about year ago, but I haven’t found a free alternative to iTunes’s exceptional file management based on mp3 ID3 tags (If you know of one — I mean better than iTunes one — let me know). So occasionally I let iTunes organize my music library. I drop in folders containing new music and let iTunes go at it. The problem is that if I have folders containing an mp3 and an m3u playlist I get duplicates. If I don’t notice this right away the duplicates build up.
Here’s a bash script to delete all true duplicates. The files must be exactly the same and have almost the same name (the difference being the number iTunes appends on a copy: “song.mp3″ becomes “song 1.mp3″).
#!/bin/bash find "$1" -regex ".* [0-9][0-9]*\.[^.]*" -print0 | while read -d $'\0' copy do original=`echo "$copy" | sed "s/\(.*\) [0-9][0-9]*\(\.[^.]*\)/\1\2/"` # check that the hypothetical original exists if [ -e "$original" ];then # check that the original is exactly the same file as the copy if diff "$original" "$copy" >/dev/null ;then rm "$copy" echo "$copy deleted..." else echo "$copy is different..." echo " $copy not deleted..." fi else echo "$original does not exist..." echo " $copy not deleted..." fi done
#!/bin/bash find "$1" -regex ".* [0-9][0-9]*\.[^.]*" -print0 | while read -d $'\0' copy do original=`echo "$copy" | sed "s/\(.*\) [0-9][0-9]*\(\.[^.]*\)/\1\2/"` # check that the hypothetical original exists if [ -e "$original" ];then # check that the original is exactly the same file as the copy if diff "$original" "$copy" >/dev/null ;then rm "$copy" fi fi done