Welcome, Guest. Please login or register.

Login with username, password and session length
February 07, 2012, 10:37:15 PM
[Less]
  • News: We have moved our site to a new web hosting provider. Report any bugs!

  •  
linktree ATokar.net  >  Coding  >  Tutorials
linktree Topic: How to: Convert video or audio file to mp3 on Ubuntu
Pages: [1]   Go Down
  Print  
Author Topic: How to: Convert video or audio file to mp3 on Ubuntu  (Read 1347 times)
0 Members and 1 Guest are viewing this topic. Bookmarked by 0 members.
Cleo
Administrator
Developer
Karma: +6/-0
Offline Offline

Gender: Male
Posts: 172




WWW
« on: December 26, 2008, 10:38:35 PM »

I recently found myself with some video songs and audio files of other type than mp3. I wanted them to convert them to mp3, so I came up with this.

First of all you will need to install some packages. To do this, do:
Quote
sudo apt-get install gstreamer0.10-plugins-ugly-multiverse ffmpeg


Now you should be ready to go.

Go to your home directory, then .gnome2 directory and then nautilus-scripts directory. There you create new document, and name it MP3 Convert. Go to properties of this file, click permissions tab, and tick "Allow executing file as program" check box. Now edit it and insert the following code:

Code: [Select]
#!/bin/bash
the_file=$1
if [ "$NAUTILUS_SCRIPT_CURRENT_URI" != "file://$HOME/Desktop" ]; then
if [ "$NAUTILUS_SCRIPT_CURRENT_URI" == "x-nautilus-desktop:///" ]; then
files_path=$HOME"/Desktop"
else
files_path=`echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed -e 's/^file:\/\///; s/%20/\ /g'`
fi
else
files_path=""
fi
new_file=`echo $the_file | cut -d'.' -f1`


ffmpeg -i "$files_path/$the_file" -f mp3 -vn -acodec copy "$files_path/$new_file".mp3

if (( $? != 0 )); then
zenity --error --text "Failed converting. The following could have happened:\nYou don't have ffmpeg installed;\nThe file you used is not supported;\nOR\nThe file has already been converted." --title "Error";
fi


Now, you can convert any video or audio file to MP3 by right clicking it, selecting Scripts and MP3 Convert! If anything does not work, post here. ;)
« Last Edit: January 01, 2009, 05:45:19 PM by Cleo » Logged

Nobbit
Global Moderator
Karma: +4/-0
Offline Offline

Gender: Male
Posts: 148




« Reply #1 on: December 27, 2008, 01:26:21 PM »

Works great, thank you, Cleo.

For idiots like me it might be helpful to know that "your home" (as stated above by Cleo) and "home" in ubuntu are two different things. So you got to go to home/'user'/

to view the .gnome2 folder, you hit ctrl+H ;)
Logged

And after they killed the Hobbit, it went even worse 'cause there appeared ... the Nobbit
Cleo
Administrator
Developer
Karma: +6/-0
Offline Offline

Gender: Male
Posts: 172




WWW
« Reply #2 on: January 01, 2009, 05:45:37 PM »

Nobbit's right. Just updated the script to support converting on Desktop too. :)
Logged

Nobbit
Global Moderator
Karma: +4/-0
Offline Offline

Gender: Male
Posts: 148




« Reply #3 on: January 10, 2009, 12:49:46 PM »

Errrrm - I updated my file and now it won't work anymore :(

Quote
Failed converting. The following could have happened:
You don't have ffmpeg installed;
The file you used is not supported;
OR
The file has already been converted.


But ffmpeg is installed

Quote
gstreamer0.10-plugins-ugly-multiverse ist schon die neueste Version.
ffmpeg ist schon die neueste Version.


So, what did u do?!  :o

Edit: Cleo did nothing. Everything works well, besides the fact that .oga files are not to be converted.
« Last Edit: January 10, 2009, 04:48:02 PM by Nobbit » Logged

And after they killed the Hobbit, it went even worse 'cause there appeared ... the Nobbit
Pages: [1]   Go Up
  Print  
 
Jump to:  


Copyright © 2007–2010 ATokar.net. All trademarks are property of their respective owners.
Powered by SMF | SMF © 2006–2007, Simple Machines LLC
Page created in 0.659 seconds with 27 queries.
Contact Us - ATokar.net - XML - Sitemap - Top
Valid HTML 4.01! Valid CSS! Valid RSS! Powered by Linux Powered by MySQL Powered by PHP Powered by Apache 2.2