0

I am trying to convert a audio (mp3) file to a video file (ideally flv or anything that youtube will accept). Looking around on here I thought that JAVE might be able to do the job and have been playing around with it but most of the support is about extracting the audio from a video rather than the other way around. I was guessing that I might need a blank image or something to form the pictures part of the video but can't seem to work it out. Thanks for any and all help!

My current code looks like :

        File source = new File("voicetomstest.mp3");
        File target = new File("target.flv");
        AudioAttributes audio = new AudioAttributes();
        audio.setCodec("libmp3lame");
        audio.setBitRate(new Integer(64000));
        audio.setChannels(new Integer(1));
        audio.setSamplingRate(new Integer(22050));
        VideoAttributes video = new VideoAttributes();
        video.setCodec("flv");
        video.setBitRate(new Integer(160000));
        video.setFrameRate(new Integer(15));
        video.setSize(new VideoSize(400, 300));
        EncodingAttributes attrs = new EncodingAttributes();
        attrs.setFormat("flv");
        attrs.setAudioAttributes(audio);
        attrs.setVideoAttributes(video);
        Encoder encoder = new Encoder();
        encoder.encode(source, target, attrs);

And currently has the following error

Apr 01, 2018 3:13:34 PM testvoice2video.TestVoice2Video main
SEVERE: null
it.sauronsoftware.jave.InputFormatException
at it.sauronsoftware.jave.Encoder.parseMultimediaInfo(Encoder.java:659)
at it.sauronsoftware.jave.Encoder.encode(Encoder.java:840)
at it.sauronsoftware.jave.Encoder.encode(Encoder.java:713)
at testvoice2video.TestVoice2Video.main(TestVoice2Video.java:74)

where line 74 is "encoder.encode(source, target, attrs);"

maksimov
  • 5,792
  • 1
  • 30
  • 38

1 Answers1

0

I don't work with this code, but it appears to me from looking at the Encoder.parseMultiMediaInfo() source code that the InputFormatException thrown at line 659 is a result of not being able to create a MultimediaInfo file from your target. It's looking for this regexp at the beginning of the target:

^\\s*Input #0, (\\w+).+$\\s*"

The target file is opened as an ffmpeg executable, where various arguments are then added as per your attributes. I don't know what ffmpeg argument results in a "Input #0" type header but I have to assume it's the

...
ffmpeg.addArgument("-i");
ffmpeg.addArgument(source.getAbsolutePath());
...

Are you sure your source file is being found?

RBH
  • 261
  • 1
  • 10