4 September 2007 @ 17:45Make an mp3 out of your video

Have you ever wanted to make mp3′s out of your videos (e.g. music videos) so you can load the audio onto your iPod or listen to it in your favorite music player?

This simple Applescript droplet will do just that. Drop your video onto the Video to mp3.app icon, type in the desired bitrate, and it will immediately start converting the first audio track to a mp3. Give it a try. It works with many different video formats including VOB.

Video to mp3.app (video_to_mp3.zip)

Here is the Applescript source:

property bitrate : "160"

on open these_files

repeat with this_file in these_files
set ffmpeg_binary to ((path to me) as string)
set ffmpeg_binary to (ffmpeg_binary & "Contents:Resources:ffmpeg")
set ffmpeg_binary to (POSIX path of ffmpeg_binary)
set theuser to (do shell script "echo $USER")
set ginfo to (get info for this_file)
set disp_name to text 1 thru -((length of name extension of ginfo) + 2) of name of ginfo
set disp_name2 to name of ginfo
set POSIX_file to POSIX path of this_file
display dialog "Set the bitrate in kbit/s" default answer bitrate
set the bitrate to text returned of result

with timeout of 30000 seconds
tell application "Terminal"
--do shell script "\"" & ffmpeg_binary & "\" -y -i \"" & POSIX_file & "\""
do script ("\"" & ffmpeg_binary & "\" -y -i \"" & POSIX_file & "\" -vn -acodec mp3 -ab " & bitrate & " -ac 2 -ar 44100 \"" & POSIX_file & ".mp3\"")
end tell
end timeout
end repeat
end open

Note: the above example code requires ffmpeg binary if you are going to compile your own Applescript.

Shop for Applescript books

Be Sociable, Share!

by | 14 comments | Tags: ,
Posted in applescript, dvd, ffmpeg, itunes, music | Link to this

Comments:

  1. Ted | 11 Dec 2007 @ 22:41 #

    For those (few) of us that aren’t tech savvy enough to work with Applescript . . . a very big thank you for this amazing droplet!!!

  2. Jon | 11 Dec 2007 @ 22:58 #

    You’re welcome, Ted.

  3. gerard | 08 Nov 2008 @ 2:01 #

    This is really a good solution! I tried different other programs but if the .FLV contains only music and no video it doesn’t work. But yours works! Thanks!

  4. Jon | 08 Nov 2008 @ 8:18 #

    Glad it could help, gerard.

  5. Kyle | 22 Dec 2008 @ 8:04 #

    It doesn’t work.
    It flashes an error message saying,
    “Can’t get length of missing value”.
    Great idea though.

  6. Jon | 22 Dec 2008 @ 22:59 #

    Kyle,

    Tell me more about the error and what version of OS X you are running. I just downloaded the video_to_mp3.zip, unpacked it, and dropped a video file on it without any error.

  7. Kyle | 23 Dec 2008 @ 9:25 #

    Hi Jon,

    I managed to get 12 flash video files from You tube before it gave me that error message.
    I think google are on to me.
    I using 10.3.9.
    I think it’s my cpu not your program, i’ll reformat my hard drive and try again.
    Does it still work if you try the same video more than once, that could be it.
    Anyway the program has helped me very much, the videos i converted were very rare and i don’t think i would have been able to do it without video to mp3.
    thanks

  8. Jez | 14 Jan 2009 @ 14:10 #

    Well I’d like to be geekee enough to work this out for myself, but it doesn’t seem to work for me. It seems to convert the file but will not play the mp3 in my iTunes. My converted file has.flv.mp3 after the file name. Is that something to do with it? Or am I doing something obviously wrong and just can’t see it. I’m running Leopard 10.5, and thank you!

  9. Jon | 14 Jan 2009 @ 14:26 #

    Jez,

    The filename is normal and would not affect playback.

    If you would copy and paste the contents of the Terminal window her, I will take a look to see if I can tell what the problem is.

  10. Jez | 15 Jan 2009 @ 6:03 #

    Jon,
    I don’t know what to say, other than thank you so much. Using the keepvid bookmarklet works perfectly with your video to mp3 droplet. Just Spot on! There is always a solution on the mac thanks to the www and you. Cheers

  11. Jon | 15 Jan 2009 @ 6:34 #

    Glad I could help, Jez

    Jez had a Real Player file that wouldn’t convert with the Video to mp3 droplet, so I suggested finding the same video on YouTube, downloading that, and converting it with the droplet.

  12. A'damn | 25 Sep 2009 @ 20:28 #

    Hello, I am trying to export an mp3 from an FLV file. I have tried multiple programs and online tools, but have yet to succeed. It is a large-ish file (just under 300mb) and is just over 2 hours in length. When I tried your script, this is the error I got:

    [flv @ 0x54340c]Bad picture start code
    [flv @ 0x54340c]header damaged
    [flv @ 0x5597b8]Unsupported audio codec (6)

    Seems that stream 0 comes from film source: 1000.00 (1000/1) -> 25.50 (51/2)
    Input #0, flv, from ‘/Users/FuckYou/Desktop/FABULOUSRadio01.flv’:
    Duration: 02:04:01.3, bitrate: N/A
    Stream #0.0, 25.50 fps(r): Video: flv, yuv420p, 320×240
    Stream #0.1: Audio: 0×0006, 44100 Hz, mono
    Output #0, mp3, to ‘/Users/FuckYou/Desktop/FABULOUSRadio01.flv.mp3′:
    Stream #0.0: Audio: mp3, 44100 Hz, stereo, 224 kb/s
    Stream mapping:
    Stream #0.1 -> #0.0
    Unsupported codec (id=0) for input stream #0.1

    I’ve been able to open the file in VLC and it plays with the audio, so I know something works; however I wasn’t sure if there was anything you could maybe assist me with or provide more insight upon. The source audio is mono, so I wasn’t sure if that might be the problem and if it is, can I modify the script to circumvent that issue?

    I am running 10.5.8

    If you can’t help me out, I totally understand, just thought I would drop a line and ask!

    Thanks for your time.

  13. Jon | 25 Sep 2009 @ 22:31 #

    A’damn,

    As the log says, it appears that your video file is damaged. Since VLC is good at opening even damaged files, I would suggest that you try to use VLC to export or transcode the file into something useable. Look under the File menu for the Streaming/Transcoding Wizard (I think that’s what it’s called).

    Jon

  14. A'damn | 25 Sep 2009 @ 22:35 #

    Thank you. That was my thinking too, but wanted a second opinion. I appreciate you taking the time to reply. Cheers.

Add a Comment

Show who you are with a Gravatar.

 

Sign up for PayPal and start accepting credit card payments instantly.

Staples Logo

Get fed!

rss icon subscribe to Geek stuff

rss icon Geek stuff in your inbox

Add the "Geek stuff" Google Gadget to your homepage

Add the "Daily Deals" Google Gadget to your homepage

Apparel

Search Amazon

Search Amazon.com
Search Amazon.co.uk

Recent Forum Topics

    Advert

    Web hosting by ICDSoft