?
Solved

CONCATENATING mp3 FILES USING JAVA

Posted on 2003-02-24
13
Medium Priority
?
311 Views
Last Modified: 2012-08-13
hi all.
i need to concatenate mp3 files on-the-fly for my application, based on user inputs. is this possible? if so, how?
i have read that Java will not support mp3 in which case im buggered.  

having concatenated all the files the user requires, i need to save it into one large file which can then be downloaded to an mp3 player by the user.

please help

bub
0
Comment
Question by:bublathejuggler
  • 6
  • 5
  • 2
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 8008115
Do you mean you want them to be able to play just one file instead of several separate files?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8008123
0
 

Author Comment

by:bublathejuggler
ID: 8008182
in response to CEHJ, yes. there will be several mp3 files that can be played individually, but if requested by the user, i wud like to concatenate them into one big file (in order) that they can then download from my web page
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:bublathejuggler
ID: 8008207
In response to Tim Yates, yes I have looked at that code BUT i have read that Java cannot deal with mp3 - only .wav, .au, .aiff, etc. Therefore, I didnt proceed with it
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8008683
did you try it?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8008684
I haven't....just wondering tho ;-)
0
 

Author Comment

by:bublathejuggler
ID: 8008869
hi Tim. i have tried the code from the link you gave me. it works fine for concatenating .wav files only. there is further code from the same site that allows conversion to other sound formats but it doesnt specify which.  

there is one other problem i am not familiar with. the code i have downloaded is a program in itself and needs to be passed the input and output file names at runtime. is there anyway i can initiate this program whilst mine is running and at the same time pass it all the parameters it requires? for example, could I use the command:

javac AudioConcatenate.java output_file_name.wav [array of input_file_names.wav]

as part of my program?

please help and the points are yours
0
 
LVL 35

Accepted Solution

by:
TimYates earned 200 total points
ID: 8009039
Assuming your array of input filenames is called "filenames" ;-)


 try
 {            
   Runtime runtime = Runtime.getRuntime();

   String runStr = "javac AudioConcatenate.java output_file_name.wav " ;

   for( int i = 0 ; i < filenames.length ; i++ )
     runStr += filenames[ i ] ;


   Process process = runtime.exec( runStr );
   int exitCode = process.waitFor();
   System.out.println("ExitCode " + exitCode);
 }
 catch (Throwable t)    
 {
   t.printStackTrace();
 }


Hope this helps :-)
0
 

Author Comment

by:bublathejuggler
ID: 8010323
thanks tim. it works but i still need to convert to mp3!
0
 

Author Comment

by:bublathejuggler
ID: 8012904
hey if you work out that mp3 conversion thing please post the answer.

ps. do you know how to delete a file using Java? my current application will not overwrite old files with the same name :0(
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8015332
new File( "filename" ).delete() ;

should do it...

So long as they are not read only :-)

I reckon you need to find a program that concatenates MP3 files from the command line (if such a thing exists)...  does the LAME encoder have this function?

Then call that from the command line like you are calling the AudioConcatenate program :-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8015802
You need to find a Java library that can handle MP3. Maybe you can come back if and when you've done that.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8016073
MP3 support was removed from most Java libraries when they started charging a fee per decoder

Switch to Ogg-Vorbis it's the only way...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

616 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question