Merging audio and video in java using JMF(Without xuggle, ffmpeg, etc..)

699 Views Asked by At

I struggle to find the error in my code.

I've tried several things I found online, but can't get any of them working.

Error

javax.media.NoProcessorException: Cannot find a Processor for: com.ibm.media.protocol.MergingPullDataSource@14514713 That should mean the data type of the merged source cannot be used, but I cannot find out why

I've already tried several formats also converting my audio file to .mov.

If someone could help me I would be very thankful.

Code

public static void main(String args[]){ 

    //Creating the files with my path
    File audio = new File("C:\\ffmpeg\\bin\\light.wav");
    File video = new File("C:\\ffmpeg\\bin\\output.mov");

    try {

        //Create the sources
        DataSource audioSource = Manager.createDataSource(audio.toURI().toURL());
        DataSource videoSource = Manager.createDataSource(video.toURI().toURL());

        //Merge them
        DataSource[] vidAud = new DataSource[2];
        vidAud[0] = videoSource;
        vidAud[1] = audioSource;
        DataSource finalVideo = Manager.createMergingDataSource(vidAud);

        //Choose the destination to put it
        MediaLocator dest = new MediaLocator("file:c:\\ffmpeg\\bin\\plsWork.mov");

        VideoFormat videoF = new VideoFormat(VideoFormat.INDEO50);
        AudioFormat audioF = new AudioFormat(AudioFormat.GSM_MS);

        Format outputFormat[] = new Format[2];
        outputFormat[0] = videoF;
        outputFormat[1] = audioF;

        FileTypeDescriptor outputType = new FileTypeDescriptor(FileTypeDescriptor.AIFF);

        ProcessorModel procModel = new ProcessorModel(finalVideo, outputFormat, outputType);
        Processor proc = null;

        proc = Manager.createRealizedProcessor(procModel);

        DataSource source = proc.getDataOutput();

        DataSink sink = Manager.createDataSink(source, dest);
        sink.open();

    } catch(Exception e) {
        e.printStackTrace();
    }
}

Best regards

0

There are 0 best solutions below