Rino Raj
Rino Raj

Reputation: 6264

Convert a MP3 file to FLAC using coldfusion

What I am trying to achieve

I want a generic function in ColdFusion through which I can convert audio files to different format.

What I have tried

After referring this java code I was trying to implement this in ColdFusion. I have included the .jar file from this link.

The code I have tried is included below.

component { 
    remote void function foo() { 
        WriteOutput("Method foo() called<br>"); 
        // local.path = expandPath("../lib/jave-2.0.jar");
        local.javaObj = createObject( 'java', 'java.io.File');
        local.AudioAttributes = createObject("java", "it.sauronsoftware.jave.AudioAttributes");
        local.Encoder = createObject("java", "it.sauronsoftware.jave.Encoder");
        local.EncodingAttributes = createObject("java", "it.sauronsoftware.jave.EncodingAttributes");

        local.EncodingAttributes.setFormat('flac');
        // local.AudioAttributes.setCodec('libmp3lame');
        //local.EncodingAttributes.setAudioAttributes(audioAttr);
        local.mp3file = createObject("java", "java.io.File").init("Manavayanatim.mp3");
        local.flacFile = createObject("java", "java.io.File").init("Manavayanatim.flac");
        try{
            local.Encoder.encode(local.mp3file, local.flacFile, local.EncodingAttributes);
        }catch(Exception e){
            writeDump("Encoding Failed");
        }
    } 
}

Encoder Object

enter image description here

Error I am getting

enter image description here

After searching about the error it was seen that ffmpeg-amd64.exe file was missing in the location C:\Windows\System32. So I downloaded and added that. But still I am not able to solve the error.

Upvotes: 2

Views: 353

Answers (1)

SOS
SOS

Reputation: 6550

I think this is the same project. The usage docs say you also need to download the native jar for your environment. From what I can tell, the library loads and extracts the ffmpeg executable from the native jar (automatically).

  1. You need the jave-2.0.jar file which is your java interface to use
  2. In addition you need one of the native libraries, matching your platform. So for linux 64 bit you download also jave-2.0-linux64.jar. This file contents the binary executable for linux 64 bit

That might also explain the error. If the library only searches within the native jar, that would explain why copying it to C:\Windows\... doesn't help.

Upvotes: 1

Related Questions