2 * Meviz - Various tools collection to work with multimedia.
3 * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
10 package eu.svjatoslav.meviz.encoder;
14 import eu.svjatoslav.meviz.encoder.converters.AbstractConverter;
16 public class EncodingTask {
19 * Source file to encode
21 private final File source;
26 private final File target;
28 private final AbstractConverter converter;
30 private boolean useTerminal;
32 public EncodingTask(final File source, final File destination,
33 final eu.svjatoslav.meviz.encoder.converters.AbstractConverter converter) {
37 this.converter = converter;
42 * @return the useTerminal
44 public boolean doUseTerminal() {
48 public String encodeApostrophes(final String input) {
49 final StringBuffer result = new StringBuffer();
51 for (final char c : input.toCharArray()) {
53 result.append("'\\''");
59 return result.toString();
62 public void execute(final EncodingOptions encodingOptions) {
64 String command = getCommand(encodingOptions);
67 command = "xterm -e '" + encodeApostrophes(command) + "'";
69 System.out.println("Executing command: " + command);
71 final Runtime run = Runtime.getRuntime();
73 pr = run.exec(new String[] { "/bin/bash", "-c", command });
77 } catch (final Exception e) {
78 System.out.println(e.toString());
84 public String getCommand(final EncodingOptions encodingOptions) {
85 return converter.getCommand(source, target, encodingOptions);
90 * the useTerminal to set
92 public void setUseTerminal(final boolean useTerminal) {
93 this.useTerminal = useTerminal;