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