!7 lib 1013798 // jave import it.sauronsoftware.jave.*; p { L sources = map gudrun_silent(ll("hallo", "du")); File target = programFile("hallo-du.mp3"); mergeMP3s(source, target); printFileInfo(target); } svoid mergeMP3s(L sources, File out) ctex { new DefaultFFMPEGLocator locator; FFMPEGExecutor ffmpeg = locator.createExecutor(); ffmpeg.addArgument("-i"); ffmpeg.addArgument("concat:" + join("|", map f2s(sources))); if (codec != null) { ffmpeg.addArgument("-acodec"); ffmpeg.addArgument("copy"); } ffmpeg.addArgument(f2s(out)); ffmpeg.execute(); try { String lastWarning = null; long duration; long progress = 0; RBufferedReader reader = null; reader = new RBufferedReader(new InputStreamReader(ffmpeg .getErrorStream())); MultimediaInfo info = parseMultimediaInfo(source, reader); if (durationAttribute != null) { duration = (long) Math .round((durationAttribute.floatValue() * 1000L)); } else { duration = info.getDuration(); if (offsetAttribute != null) { duration -= (long) Math .round((offsetAttribute.floatValue() * 1000L)); } } if (listener != null) { listener.sourceInfo(info); } int step = 0; String line; while ((line = reader.readLine()) != null) { if (step == 0) { if (line.startsWith("WARNING: ")) { if (listener != null) { listener.message(line); } } else if (!line.startsWith("Output #0")) { throw new EncoderException(line); } else { step++; } } else if (step == 1) { if (!line.startsWith(" ")) { step++; } } if (step == 2) { if (!line.startsWith("Stream mapping:")) { throw new EncoderException(line); } else { step++; } } else if (step == 3) { if (!line.startsWith(" ")) { step++; } } if (step == 4) { line = line.trim(); if (line.length() > 0) { Hashtable table = parseProgressInfoLine(line); if (table == null) { if (listener != null) { listener.message(line); } lastWarning = line; } else { if (listener != null) { String time = (String) table.get("time"); if (time != null) { int dot = time.indexOf('.'); if (dot > 0 && dot == time.length() - 2 && duration > 0) { String p1 = time.substring(0, dot); String p2 = time.substring(dot + 1); try { long i1 = Long.parseLong(p1); long i2 = Long.parseLong(p2); progress = (i1 * 1000L) + (i2 * 100L); int perm = (int) Math .round((double) (progress * 1000L) / (double) duration); if (perm > 1000) { perm = 1000; } listener.progress(perm); } catch (NumberFormatException e) { ; } } } } lastWarning = null; } } } } if (lastWarning != null) { if (!SUCCESS_PATTERN.matcher(lastWarning).matches()) { throw new EncoderException(lastWarning); } } } finally { ffmpeg.destroy(); } }