Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Converting wav's to mp3's  (Read 4438 times)
0 Members and 1 Guest are viewing this topic.
Offline eedok

Junior Newbie





« Posted 2009-09-29 22:16:41 »

I'm trying to make a tool to convert wav's to mp3's then send out a notification when it's done. (The wav's will always be 44100Hz 16-bit Stereo files)

My first attempt was to link to JMF then attempt to do this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   public void wavToMP3(String waveFileName, String mp3FileName) throws Exception
   {
      File file = new File(waveFileName);
      AudioInputStream in = AudioSystem.getAudioInputStream(file);
      AudioInputStream out;
      AudioFormat.Encoding encodedFormat = new AudioFormat.Encoding(javax.media.format.AudioFormat.MPEGLAYER3);
      out = AudioSystem.getAudioInputStream(encodedFormat, in);
      File outfile = new File(mp3FileName);
      AudioSystem.write(out, new AudioFileFormat.Type("MP3","mp3"), outfile);
   }


but that results in this error:

Exception in thread "main" java.lang.IllegalArgumentException: Unsupported conversion: mpeglayer3 from PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian

I can't seem to find what I need to change to fix this, any suggestions?
Offline Nate

JGO Kernel


Medals: 149
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2009-09-30 01:29:22 »

The JDK can't read MP3s. You can use the JavaZoom project. It isn't written very well, but works for most MP3s.

Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2009-09-30 06:25:35 »

And just on the off-chance - if you can get away with using Ogg Vorbis format instead of MP3, you can use the JOrbis library.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

JGO Kernel


Medals: 149
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #3 - Posted 2009-09-30 09:56:13 »

Indeed. OGG, FLAC, and APE have decent Java decoding libs.

Offline eedok

Junior Newbie





« Reply #4 - Posted 2009-09-30 19:51:29 »

the final format needs to be mp3 to be playable in flash(this is on the server) and as far as I know it doesn't support ogg, flac or ape

it also seems javazoom's domain is down
Offline eedok

Junior Newbie





« Reply #5 - Posted 2009-10-02 16:31:10 »

I found a link to JLayer and it only seems to be able to go from mp3->wav but has no way of going back again, is there a library to do this that doesn't require an EasyJNI license?
Offline Nate

JGO Kernel


Medals: 149
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #6 - Posted 2009-10-03 02:51:46 »

Don't think so. Stupid, eh?

Offline eedok

Junior Newbie





« Reply #7 - Posted 2009-10-06 21:55:05 »

I guess this will have to do:
1  
2  
3  
4  
5  
   public void wavToMP3(String waveFileName, String mp3FileName) throws Exception
   {
      Runtime runtime = Runtime.getRuntime();
      Process proc = runtime.exec(LAME_PATH+" "+waveFileName+" "+mp3FileName);
   }
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (39 views)
2014-10-17 03:59:02

Norakomi (31 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (57 views)
2014-10-14 00:39:48

TehJavaDev (58 views)
2014-10-14 00:35:47

TehJavaDev (48 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!