Search in sources :

Example 1 with ReadLine

use of org.fagu.fmv.soft.exec.ReadLine in project fmv by f-agu.

the class FFExecutor method getErrReadLine.

/**
 * @return
 */
protected ReadLine getErrReadLine() {
    List<ReadLine> lines = new ArrayList<>();
    if (progressReadLine != null) {
        lines.add(progressReadLine);
    }
    ReadLine readLine = operation.getErrReadLine();
    if (readLine != null) {
        lines.add(readLine);
    }
    if (debug) {
        lines.add(errDebugConsumer::accept);
    }
    if (!libLogReadLine.isEmpty()) {
        lines.add(libLogReadLine);
    }
    if (!errReadLines.isEmpty()) {
        lines.addAll(errReadLines);
    }
    if (!readLines.isEmpty()) {
        lines.addAll(readLines);
    }
    return MultiReadLine.createWith(lines);
}
Also used : ArrayList(java.util.ArrayList) FFMPEGProgressReadLine(org.fagu.fmv.ffmpeg.operation.FFMPEGProgressReadLine) LibLogReadLine(org.fagu.fmv.ffmpeg.operation.LibLogReadLine) MultiReadLine(org.fagu.fmv.soft.exec.MultiReadLine) ProgressReadLine(org.fagu.fmv.ffmpeg.operation.ProgressReadLine) ReadLine(org.fagu.fmv.soft.exec.ReadLine) BufferedReadLine(org.fagu.fmv.soft.exec.BufferedReadLine)

Example 2 with ReadLine

use of org.fagu.fmv.soft.exec.ReadLine in project fmv by f-agu.

the class FFExecutor method getOutReadLine.

// ************************************************
/**
 * @return
 */
protected ReadLine getOutReadLine() {
    if (operation.containsGlobalParameter("nostats")) {
        return null;
    }
    List<ReadLine> lines = new ArrayList<>();
    ReadLine readLine = operation.getOutReadLine();
    if (readLine != null) {
        lines.add(readLine);
    }
    if (debug) {
        lines.add(outDebugConsumer::accept);
    }
    if (!outReadLines.isEmpty()) {
        lines.addAll(outReadLines);
    }
    if (!readLines.isEmpty()) {
        lines.addAll(readLines);
    }
    return MultiReadLine.createWith(lines);
}
Also used : ArrayList(java.util.ArrayList) FFMPEGProgressReadLine(org.fagu.fmv.ffmpeg.operation.FFMPEGProgressReadLine) LibLogReadLine(org.fagu.fmv.ffmpeg.operation.LibLogReadLine) MultiReadLine(org.fagu.fmv.soft.exec.MultiReadLine) ProgressReadLine(org.fagu.fmv.ffmpeg.operation.ProgressReadLine) ReadLine(org.fagu.fmv.soft.exec.ReadLine) BufferedReadLine(org.fagu.fmv.soft.exec.BufferedReadLine)

Example 3 with ReadLine

use of org.fagu.fmv.soft.exec.ReadLine in project fmv by f-agu.

the class SoftExecutor method execute.

// -------------------------------------------------------------
/**
 * @param executorService
 * @return
 * @throws IOException
 */
private <R> R execute(SoftExecutor.ForExec<R> forExec) throws IOException {
    ExecListener execListener = new Proxifier<>(ExecListener.class).addAll(execListeners).proxify();
    CommandLine commandLine = getCommandLine();
    String cmdLineStr = CommandLineUtils.toLine(commandLine);
    execListener.eventPrepare(cmdLineStr);
    List<String> readLineList = new ArrayList<>();
    ReadLine bufferedReadLine = new BufferedReadLine(readLineList);
    FMVExecutor fmvExecutor = createFMVExecutor(execFile.getParentFile(), bufferedReadLine);
    applyCustomizeExecutor(fmvExecutor);
    return forExec.exec(fmvExecutor, commandLine, execListener, readLineList);
}
Also used : BufferedReadLine(org.fagu.fmv.soft.exec.BufferedReadLine) FMVCommandLine(org.fagu.fmv.soft.exec.FMVCommandLine) CommandLine(org.apache.commons.exec.CommandLine) Proxifier(org.fagu.fmv.soft.utils.Proxifier) ArrayList(java.util.ArrayList) ReadLine(org.fagu.fmv.soft.exec.ReadLine) BufferedReadLine(org.fagu.fmv.soft.exec.BufferedReadLine) FMVExecutor(org.fagu.fmv.soft.exec.FMVExecutor)

Example 4 with ReadLine

use of org.fagu.fmv.soft.exec.ReadLine in project fmv by f-agu.

the class PixelFormatGenerator method generate.

/**
 * @throws IOException
 */
@Test
@Ignore
public void generate() throws IOException {
    final Pattern PATTERN = Pattern.compile("(I|\\.)(O|\\.)(H|\\.)(P|\\.)(B|\\.)\\s(\\w+)\\s+(\\d+)\\s+(\\d+).*");
    List<String> arguments = Arrays.asList("-v", "quiet", "-pix_fmts");
    final Map<String, String> map = new TreeMap<String, String>();
    ReadLine readLine = new ReadLine() {

        /**
         * @see org.fagu.fmv.utils.exec.ReadLine#read(java.lang.String)
         */
        @Override
        public void read(String line) {
            StringBuilder buf = new StringBuilder();
            buf.append("public static final PixelFormat ");
            // System.out.println(line);
            Matcher matcher = PATTERN.matcher(line);
            if (matcher.matches()) {
                boolean supportedInput = "I".equals(matcher.group(1));
                boolean supportedOutput = "O".equals(matcher.group(2));
                boolean hardwareAccelerated = "H".equals(matcher.group(3));
                boolean paletted = "P".equals(matcher.group(4));
                boolean bitstream = "B".equals(matcher.group(5));
                String name = matcher.group(6);
                int nbComponents = Integer.parseInt(matcher.group(7));
                int bitsPerPixel = Integer.parseInt(matcher.group(8));
                if (Character.isDigit(name.charAt(0))) {
                    buf.append('_');
                }
                buf.append(name.toUpperCase());
                buf.append(" = new PixelFormat(").append(supportedInput).append(", ").append(supportedOutput).append(", ");
                buf.append(hardwareAccelerated).append(", ").append(paletted).append(", ");
                buf.append(bitstream).append(", \"").append(name).append("\", ");
                buf.append(nbComponents).append(", ").append(bitsPerPixel).append(");");
                map.put(name, buf.toString());
            }
        }
    };
    // 
    FFMpeg.search().withParameters(// 
    arguments).addCommonReadLine(// 
    readLine).execute();
    for (String str : map.values()) {
        System.out.println(str);
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ReadLine(org.fagu.fmv.soft.exec.ReadLine) TreeMap(java.util.TreeMap) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ReadLine (org.fagu.fmv.soft.exec.ReadLine)4 ArrayList (java.util.ArrayList)3 BufferedReadLine (org.fagu.fmv.soft.exec.BufferedReadLine)3 FFMPEGProgressReadLine (org.fagu.fmv.ffmpeg.operation.FFMPEGProgressReadLine)2 LibLogReadLine (org.fagu.fmv.ffmpeg.operation.LibLogReadLine)2 ProgressReadLine (org.fagu.fmv.ffmpeg.operation.ProgressReadLine)2 MultiReadLine (org.fagu.fmv.soft.exec.MultiReadLine)2 TreeMap (java.util.TreeMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 CommandLine (org.apache.commons.exec.CommandLine)1 FMVCommandLine (org.fagu.fmv.soft.exec.FMVCommandLine)1 FMVExecutor (org.fagu.fmv.soft.exec.FMVExecutor)1 Proxifier (org.fagu.fmv.soft.utils.Proxifier)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1