Fix call of user defined pp script
This commit is contained in:
parent
8dfc4c775f
commit
67c69e3c1b
|
@ -10,18 +10,12 @@ import ctbrec.Config;
|
|||
import ctbrec.OS;
|
||||
import ctbrec.Recording;
|
||||
import ctbrec.io.StreamRedirectThread;
|
||||
import ctbrec.recorder.download.hls.AbstractHlsDownload;
|
||||
|
||||
public abstract class AbstractDownload implements Download {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractHlsDownload.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractDownload.class);
|
||||
|
||||
@Override
|
||||
public void postprocess(Recording recording) {
|
||||
runPostProcessingScript(recording);
|
||||
}
|
||||
|
||||
private void runPostProcessingScript(Recording recording) {
|
||||
protected void runPostProcessingScript(Recording recording) {
|
||||
String postProcessing = Config.getInstance().getSettings().postProcessing;
|
||||
if (postProcessing != null && !postProcessing.isEmpty()) {
|
||||
File target = recording.getAbsoluteFile();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ctbrec.recorder.download.dash;
|
||||
|
||||
import static ctbrec.Recording.State.POST_PROCESSING;
|
||||
import static ctbrec.Recording.State.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
|
@ -351,7 +351,7 @@ public class DashDownload extends AbstractDownload {
|
|||
new FfmpegMuxer(dir, file);
|
||||
targetFile = file;
|
||||
recording.setPath(path.substring(0, path.length() - 5));
|
||||
super.postprocess(recording);
|
||||
runPostProcessingScript(recording);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error while merging dash segments", e);
|
||||
recording.setStatus(State.FAILED);
|
||||
|
|
|
@ -179,13 +179,13 @@ public class HlsDownload extends AbstractHlsDownload {
|
|||
recording.setStatusWithEvent(State.GENERATING_PLAYLIST);
|
||||
generatePlaylist(recording);
|
||||
recording.setStatusWithEvent(State.POST_PROCESSING);
|
||||
super.postprocess(recording);
|
||||
runPostProcessingScript(recording);
|
||||
}
|
||||
|
||||
protected void generatePlaylist(Recording recording) {
|
||||
protected File generatePlaylist(Recording recording) {
|
||||
File recDir = recording.getAbsoluteFile();
|
||||
if(!config.getSettings().generatePlaylist) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
PlaylistGenerator playlistGenerator = new PlaylistGenerator();
|
||||
|
@ -197,6 +197,7 @@ public class HlsDownload extends AbstractHlsDownload {
|
|||
playlistGenerator.validate(recDir);
|
||||
}
|
||||
recording.setProgress(-1);
|
||||
return playlist;
|
||||
} catch (IOException | ParseException e) {
|
||||
LOG.error("Couldn't generate playlist file", e);
|
||||
} catch (PlaylistException e) {
|
||||
|
@ -217,6 +218,8 @@ public class HlsDownload extends AbstractHlsDownload {
|
|||
LOG.error("Couldn't delete playlist {}", playlist, e1);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean splitRecording() {
|
||||
|
|
|
@ -47,12 +47,8 @@ public class MergedHlsDownload extends HlsDownload {
|
|||
|
||||
@Override
|
||||
public void postprocess(ctbrec.Recording recording) {
|
||||
super.postprocess(recording);
|
||||
File dir = new File(Config.getInstance().getSettings().recordingsDir, recording.getPath());
|
||||
File playlist = new File(dir, "playlist.m3u8");
|
||||
if (!playlist.exists()) {
|
||||
super.generatePlaylist(recording);
|
||||
}
|
||||
File playlist = super.generatePlaylist(recording);
|
||||
File dir = playlist.getParentFile();
|
||||
|
||||
try {
|
||||
postprocess(playlist, finalFile);
|
||||
|
@ -62,6 +58,8 @@ public class MergedHlsDownload extends HlsDownload {
|
|||
if (dir.list().length == 0) {
|
||||
RecordingManager.deleteEmptyParents(dir);
|
||||
}
|
||||
|
||||
runPostProcessingScript(recording);
|
||||
} catch (PostProcessingException | IOException e) {
|
||||
LOG.error("An error occurred during post-processing", e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue