Closed yangshc closed 1 year ago
Do you have a sample file and some sample code? Can you do the conversion with ffmepg?
Do you have a sample file and some sample code? Can you do the conversion with ffmepg?
Ffmepg use ====>>>>
PS C:\jave>.\ffmpeg-amd64-3.2.0.exe -i .\source.vox -hide_banner ---->> .\source.vox: Invalid data found when processing input
PS C:\jave>.\ffmpeg-amd64-3.2.0.exe -f vox -i .\source.vox -vn -acodec libmp3lame -ab 128000 -ac 1 -ar 44100 -vol 256 -f mp3 -y .\target.mp3 -hide_banner ---->> Unknown input format: 'vox'
Complete code example====>>>>
`package com.ftwj.common.utils;
import lombok.extern.slf4j.Slf4j; import ws.schild.jave.Encoder; import ws.schild.jave.MultimediaObject; import ws.schild.jave.encode.AudioAttributes; import ws.schild.jave.encode.EncodingAttributes; import ws.schild.jave.info.MultimediaInfo; import ws.schild.jave.progress.EncoderProgressListener; import java.io.File;
@Slf4j public class ConvertTest {
public static void main(String[] args) {
File source = new File("D:/jave/source.vox");
File target = new File("D:/jave/target.mp3");
boolean b = convertingAnyAudioToMp3WithAProgressListener(source,target);
System.out.println(b);
}
public static boolean convertingAnyAudioToMp3WithAProgressListener(File source, File target) {
ConvertProgressListener listener = new ConvertProgressListener();
boolean succeeded = true;
try {
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(128000);
audio.setChannels(1);
audio.setSamplingRate(6000);
audio.setVolume(new Integer(256));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setInputFormat("vox");
attrs.setOutputFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
encoder.encode(new MultimediaObject(source), target, attrs, listener);
} catch (Exception ex) {
ex.printStackTrace();
succeeded = false;
}
return succeeded;
}
public static class ConvertProgressListener implements EncoderProgressListener {
@Override
public void sourceInfo(MultimediaInfo info) {
System.out.println(info.toString());
}
public void progress(int permil) {
double progress = permil / 1000.00;
System.out.println(progress);
}
@Override
public void message(String message) {
System.out.println(message);
}
}
} ` Console printing====>>>> false ws.schild.jave.InputFormatException: Invalid data found when processing input at ws.schild.jave.MultimediaObject.parseMultimediaInfo(MultimediaObject.java:217) at ws.schild.jave.MultimediaObject.getInfo(MultimediaObject.java:165) at ws.schild.jave.Encoder.encode(Encoder.java:534) at ws.schild.jave.Encoder.encode(Encoder.java:351) at com.ftwj.common.utils.ConvertTest.convertingAnyAudioToMp3WithAProgressListener(ConvertTest.java:47) at com.ftwj.common.utils.ConvertTest.main(ConvertTest.java:22)
the last word: But the vox audio file, in fact, is normal. Can you give me some help? Thank you
Do you have a sample file and some sample code? Can you do the conversion with ffmepg?
I don't know how to give you a sample file
It looks like the VOX audio file is raw audio data, with no header describing the audio streams/layout. ffmepg can't convert this on it's own, without additional informations about the source.
You have to look at the ffmpeg project, how to do this with vanilla ffmpeg. Once you have the correct ffmpegs flags I can look on how to incorporate it in jave
(https://github.com/a-schild/jave2#converting-any-audio-to-mp3)Examples Examples is "Converting any audio to mp3", but cannot parse audio files that convert vox suffixes. Why can't I convert audio files with the vox suffix to MP3?