forked from j62/ctbrec
Fix NPE in MergedHlsDownload
This commit is contained in:
parent
d48498e715
commit
5b2ddfb825
|
@ -11,6 +11,7 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.jcodec.containers.mp4.MP4Util;
|
import org.jcodec.containers.mp4.MP4Util;
|
||||||
import org.jcodec.containers.mp4.boxes.MovieBox;
|
import org.jcodec.containers.mp4.boxes.MovieBox;
|
||||||
|
@ -55,18 +56,18 @@ public class MergedHlsDownload extends HlsDownload {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postprocess(ctbrec.Recording recording) {
|
public void postprocess(ctbrec.Recording recording) {
|
||||||
File playlist = super.generatePlaylist(recording);
|
|
||||||
File dir = playlist.getParentFile();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
File playlist = super.generatePlaylist(recording);
|
||||||
|
Objects.requireNonNull(playlist, "Generated playlist is null");
|
||||||
|
|
||||||
postprocess(playlist, finalFile);
|
postprocess(playlist, finalFile);
|
||||||
String recordingsDir = Config.getInstance().getSettings().recordingsDir;
|
String recordingsDir = Config.getInstance().getSettings().recordingsDir;
|
||||||
String path = finalFile.getAbsolutePath().substring(recordingsDir.length());
|
String path = finalFile.getAbsolutePath().substring(recordingsDir.length());
|
||||||
recording.setPath(path);
|
recording.setPath(path);
|
||||||
|
File dir = playlist.getParentFile();
|
||||||
if (dir.list().length == 0) {
|
if (dir.list().length == 0) {
|
||||||
RecordingManager.deleteEmptyParents(dir);
|
RecordingManager.deleteEmptyParents(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
runPostProcessingScript(recording);
|
runPostProcessingScript(recording);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new PostProcessingException(e);
|
throw new PostProcessingException(e);
|
||||||
|
@ -93,7 +94,7 @@ public class MergedHlsDownload extends HlsDownload {
|
||||||
int exitCode = ffmpeg.waitFor();
|
int exitCode = ffmpeg.waitFor();
|
||||||
if (exitCode == 0) {
|
if (exitCode == 0) {
|
||||||
Files.delete(playlist.toPath());
|
Files.delete(playlist.toPath());
|
||||||
File[] segments = dir.listFiles((directory, filename) -> filename.endsWith(".ts"));
|
File[] segments = dir.listFiles((directory, filename) -> filename.endsWith(".ts") || filename.endsWith(".corrupt"));
|
||||||
for (File segment : segments) {
|
for (File segment : segments) {
|
||||||
Files.delete(segment.toPath());
|
Files.delete(segment.toPath());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue