音频截取
public static void truncatedAudio(MultimediaObject audio, File dist, String start, String end) {
AudioAttributes audioattr = new AudioAttributes();
EncodingAttributes attrs = new EncodingAttributes();
attrs.setAudioAttributes(audioattr);
try {
new Encoder().encode(List.of(audio), dist, attrs, null, List.of(new ValueArgument(ArgType.OUTFILE, "-ss", ea -> Optional.of(start).map(Object::toString)), new ValueArgument(ArgType.OUTFILE, "-t", ea -> Optional.of(end).map(Object::toString))));
} catch (IllegalArgumentException | EncoderException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
MultimediaObject au = new MultimediaObject(new File("d:/a/b.mp3"));
truncatedAudio(au, new File("d://a/cc.mp3"), "00:00:13", "00:00:12");
}