Remove state from Remux post-processor
Post-processors have to be thread safe and can't have any state
This commit is contained in:
parent
605269b4a0
commit
cdaeaa746b
|
@ -22,8 +22,6 @@ public class Remux extends AbstractPostProcessor {
|
|||
|
||||
public static final String FFMPEG_ARGS = "ffmpeg.args";
|
||||
public static final String FILE_EXT = "file.ext";
|
||||
private transient File inputFile;
|
||||
private transient File remuxedFile;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -32,12 +30,14 @@ public class Remux extends AbstractPostProcessor {
|
|||
|
||||
@Override
|
||||
public boolean postprocess(Recording rec, RecordingManager recordingManager, Config config) throws IOException, InterruptedException {
|
||||
inputFile = rec.getPostProcessedFile();
|
||||
if (inputFile.isDirectory()) {
|
||||
inputFile = new File(inputFile, "playlist.m3u8");
|
||||
final File inputFile;
|
||||
if (rec.getPostProcessedFile().isDirectory()) {
|
||||
inputFile = new File(rec.getPostProcessedFile(), "playlist.m3u8");
|
||||
} else {
|
||||
inputFile = rec.getPostProcessedFile();
|
||||
}
|
||||
String fileExt = getConfig().get(FILE_EXT);
|
||||
remuxedFile = new File(rec.getPostProcessedFile().getAbsolutePath() + '.' + fileExt);
|
||||
File remuxedFile = new File(rec.getPostProcessedFile().getAbsolutePath() + '.' + fileExt);
|
||||
String[] cmdline = prepareCommandline(inputFile, remuxedFile);
|
||||
File executionDir = rec.getPostProcessedFile().isDirectory() ? rec.getPostProcessedFile() : rec.getPostProcessedFile().getParentFile();
|
||||
LOG.info("Executing {} in working directory {}", Arrays.toString(cmdline), executionDir);
|
||||
|
@ -46,14 +46,14 @@ public class Remux extends AbstractPostProcessor {
|
|||
FFmpeg ffmpeg = new FFmpeg.Builder()
|
||||
.logOutput(config.getSettings().logFFmpegOutput)
|
||||
.logFile(ffmpegLog)
|
||||
.onExit(exitCode -> finalizeStep(exitCode, rec))
|
||||
.onExit(exitCode -> finalizeStep(exitCode, rec, inputFile, remuxedFile))
|
||||
.build();
|
||||
ffmpeg.exec(cmdline, new String[0], executionDir);
|
||||
int exitCode = ffmpeg.waitFor();
|
||||
return exitCode != 1;
|
||||
}
|
||||
|
||||
private void finalizeStep(int exitCode, Recording rec) {
|
||||
private void finalizeStep(int exitCode, Recording rec, File inputFile, File remuxedFile) {
|
||||
if (exitCode != 1) {
|
||||
try {
|
||||
rec.setPostProcessedFile(remuxedFile);
|
||||
|
|
Loading…
Reference in New Issue