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 private String targetFormat;
36 final File destination,
37 final eu.svjatoslav.meviz.encoder.converters.AbstractConverter converter,
38 String targetFormat) {
42 this.converter = converter;
43 this.targetFormat = targetFormat;
47 * @return the useTerminal
49 public boolean doUseTerminal() {
53 public String encodeApostrophes(final String input) {
54 final StringBuffer result = new StringBuffer();
56 for (final char c : input.toCharArray()) {
58 result.append("'\\''");
64 return result.toString();
67 public void execute(final EncodingOptions encodingOptions) {
69 String command = getCommand(encodingOptions);
72 command = "xterm -e '" + encodeApostrophes(command) + "'";
74 System.out.println("Executing command: " + command);
76 final Runtime run = Runtime.getRuntime();
78 pr = run.exec(new String[] { "/bin/bash", "-c", command });
82 } catch (final Exception e) {
83 System.out.println(e.toString());
89 public String getCommand(final EncodingOptions encodingOptions) {
90 return converter.getCommand(source, target, encodingOptions,
96 * the useTerminal to set
98 public void setUseTerminal(final boolean useTerminal) {
99 this.useTerminal = useTerminal;