Find the answer to your Linux question:
Results 1 to 10 of 10
Im running ubuntu 9.10 and im trying to convert my music i bought off itunes from m4a to mp3. I use Banshee, iv seen a few things saying you can ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2010
    Posts
    80

    Convert m4a to mp3 with banshee?


    Im running ubuntu 9.10 and im trying to convert my music i bought off itunes from m4a to mp3. I use Banshee, iv seen a few things saying you can do it with mplayer or something like that. Is there a way to do it with banshee?

  2. #2
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    I don't use banshee, didn't realize it was able to convert media formats. But it's easy enough to do. Fortunately, other people have done all the hard work and written scripts to handle it.

    First make sure faad and lame are installed
    Code:
    sudo apt-get install faad lame
    Then do
    Code:
    gedit ~/m4a2mp3
    Paste the following in gedit and save.
    Code:
    #!/bin/sh
    #
    # m4a to mp3
    
    trap 'rm -f "$info" "$opts" "$wav" "$mp3"; exit 10' 1 2 3 15
    
    quality=5
    bitrate=192
    
    for m4a in "$@"; do
     info=` echo "$m4a"|sed -n 's/\.m4a$/.info/p'`
     opts=` echo "$m4a"|sed -n 's/\.m4a$/.opts/p'`
     wav=`  echo "$m4a"|sed -n 's/\.m4a$/.wav/p'`
     mp3=`  echo "$m4a"|sed -n 's/\.m4a$/.mp3/p'`
     [ -z "$mp3" ] && continue
    
     # study it
     faad -i "$m4a" 2>"$info"  #faad outputs info to stderr!
     cat "$info" | sed -n '
       s/["`$]/\\\&/g   # handle any escapes in titles
       s/^title: \(.*\)$/--tt "\1"/p
       s/^artist: \(.*\)$/--ta "\1"/p
       s/^album: \(.*\)$/--tl "\1"/p
       s/^track: \(.*\)$/--tn "\1"/p
       s/^date: \([12][0-9][0-9][0-9]\)$/--ty "\1"/p  # year?
      #s/^genre: \(.*\)$/--tg "\1"/p   # m4a genres dont match those of mp3
      ' - > "$opts"
    
     # convert it
     faad "$m4a"
     eval "lame -q $quality -b $bitrate "`cat "$opts"`" \"$wav\" \"$mp3\""
    
     # cleanup
     rm -f "$opts" "$wav" "$info"
    done
    Make it executable
    Code:
    sudo chmod +x ~/m4a2mp3
    You may want to put it in a directory in your $PATH.
    Code:
    sudo cp ~/m4a2mp3 /usr/bin
    Put the files you want to convert in a directory, open the terminal to said directory, and type
    Code:
    m4a2mp3

  3. #3
    Just Joined!
    Join Date
    Jan 2010
    Posts
    80
    Quote Originally Posted by reed9 View Post
    I don't use banshee, didn't realize it was able to convert media formats. But it's easy enough to do. Fortunately, other people have done all the hard work and written scripts to handle it.

    First make sure faad and lame are installed
    Code:
    sudo apt-get install faad lame
    Then do
    Code:
    gedit ~/m4a2mp3
    Paste the following in gedit and save.
    Code:
    #!/bin/sh
    #
    # m4a to mp3
    
    trap 'rm -f "$info" "$opts" "$wav" "$mp3"; exit 10' 1 2 3 15
    
    quality=5
    bitrate=192
    
    for m4a in "$@"; do
     info=` echo "$m4a"|sed -n 's/\.m4a$/.info/p'`
     opts=` echo "$m4a"|sed -n 's/\.m4a$/.opts/p'`
     wav=`  echo "$m4a"|sed -n 's/\.m4a$/.wav/p'`
     mp3=`  echo "$m4a"|sed -n 's/\.m4a$/.mp3/p'`
     [ -z "$mp3" ] && continue
    
     # study it
     faad -i "$m4a" 2>"$info"  #faad outputs info to stderr!
     cat "$info" | sed -n '
       s/["`$]/\\\&/g   # handle any escapes in titles
       s/^title: \(.*\)$/--tt "\1"/p
       s/^artist: \(.*\)$/--ta "\1"/p
       s/^album: \(.*\)$/--tl "\1"/p
       s/^track: \(.*\)$/--tn "\1"/p
       s/^date: \([12][0-9][0-9][0-9]\)$/--ty "\1"/p  # year?
      #s/^genre: \(.*\)$/--tg "\1"/p   # m4a genres dont match those of mp3
      ' - > "$opts"
    
     # convert it
     faad "$m4a"
     eval "lame -q $quality -b $bitrate "`cat "$opts"`" \"$wav\" \"$mp3\""
    
     # cleanup
     rm -f "$opts" "$wav" "$info"
    done
    Make it executable
    Code:
    sudo chmod +x ~/m4a2mp3
    You may want to put it in a directory in your $PATH.
    Code:
    sudo cp ~/m4a2mp3 /usr/bin
    Put the files you want to convert in a directory, open the terminal to said directory, and type
    Code:
    m4a2mp3
    Great thanks ill do this when i get home!

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Jan 2010
    Posts
    80
    Ok, the first command turns out this:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package fadd

    im already sutck. Im not quite sure what this error message is caused by?

  6. #5
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    E: Couldn't find package fadd
    faad, you have fadd

  7. #6
    Just Joined!
    Join Date
    Jan 2010
    Posts
    80
    Wow, I'm not really that stupid! I promise lol.

    It worked.

    Another question, are there any programs or utilitys that will search my drive and point me to a certain file type. Like say I wanted to see the name and location of every m4a file on my hard drive, or even just in a certain dir.

  8. #7
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    For a GUI search tool, I think Ubuntu uses Beagle by default.

    Probably one of the more powerful search tools in the find command. Basic usage is
    Code:
    find [path] [options]
    So you might do
    Code:
    find /home/username -name '*.mp3'
    You can also execute a command on files found, such as your conversion script.
    Code:
    find /home/username -name '*.m4a' -exec m4a2mp3 '{}' \;
    I don't have need of these tools much, so I'm not well versed in all their capabilities.

    https://help.ubuntu.com/community/FindingFiles
    How-To: Find files on your computer with find | Debian/Ubuntu Tips & Tricks
    Unix/Linux "find" Command Tutorial

  9. #8
    Just Joined!
    Join Date
    Jan 2010
    Posts
    80
    Quote Originally Posted by reed9 View Post
    For a GUI search tool, I think Ubuntu uses Beagle by default.

    Probably one of the more powerful search tools in the find command. Basic usage is
    Code:
    find [path] [options]
    So you might do
    Code:
    find /home/username -name '*.mp3'
    You can also execute a command on files found, such as your conversion script.
    Code:
    find /home/username -name '*.m4a' -exec m4a2mp3 '{}' \;
    I don't have need of these tools much, so I'm not well versed in all their capabilities.

    https://help.ubuntu.com/community/FindingFiles
    How-To: Find files on your computer with find | Debian/Ubuntu Tips & Tricks
    Unix/Linux "find" Command Tutorial
    alright great that worked perfect.

    the only problem now is that i have many files in many different directories that i need to convert. There is no way to convert all audio files in a directory to mp3 is there? like if i point it to my /hom/user/Music dir, could it convert everythingin there to mp3? or atleast try?



    EDIT: also having problems as what you had posted to convert is not converting. I am trying to convert aac(aka m4a) files to mp3. After typing in the m4a2mp3 command while in the artest directory and it returns nothing. It just jumps down to the next line and is ready for another command. The files are still .m4a.

  10. #9
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    Sorry, you need to specify the files you want to convert.

    Something like
    Code:
    m4a2mp3 *.m4a
    To target all files in the current directory ending in .m4a.

  11. #10
    Just Joined!
    Join Date
    Jan 2010
    Posts
    80
    ok, after that it looked like it was going to work. I cd'd to my itunes music dir and entered the command and got this:

    Code:
     *********** Ahead Software MPEG-4 AAC Decoder V2.6 ******************
    
     Build: Oct  8 2008
     Copyright 2002-2004: Ahead Software AG
     http://www.audiocoding.com
     Floating point version
    
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License.
    
     **************************************************************************
    
    Error opening file: *.m4a
    Could not find "*.wav".
    For this to work do i have to cd to the actual folder that the files are in i am wanting to convert? Like if i cd to ~/Music/iTunes Music , and enter the command it will not work? Do i have to be in ~/Music/iTunes Music/artest/album then enter the command? im unsure exactly what one is right.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •