?
Solved

CONCATENATING mp3 FILES USING JAVA

Posted on 2003-02-24
13
Medium Priority
?
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month9 days, 6 hours left to enroll

764 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