forked from j62/ctbrec
Fix possible NPE
This commit is contained in:
parent
b2138ca99b
commit
5448763b9d
|
@ -6,6 +6,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -22,9 +23,16 @@ public class FfmpegMuxer {
|
|||
|
||||
public FfmpegMuxer(File segmentDir, File targetFile) throws IOException {
|
||||
this.segmentDir = segmentDir;
|
||||
String[] videoSegments = segmentDir.list((dir, name) -> name.startsWith("video_"));
|
||||
if (!segmentDir.exists()) {
|
||||
throw new IOException("Directory does not exist " + segmentDir);
|
||||
}
|
||||
if (!segmentDir.isDirectory()) {
|
||||
throw new IOException(segmentDir + " is not a directory");
|
||||
}
|
||||
|
||||
String[] videoSegments = Optional.ofNullable(segmentDir.list((dir, name) -> name.startsWith("video_"))).orElse(new String[0]);
|
||||
Arrays.sort(videoSegments);
|
||||
String[] audioSegments = segmentDir.list((dir, name) -> name.startsWith("audio_"));
|
||||
String[] audioSegments = Optional.ofNullable(segmentDir.list((dir, name) -> name.startsWith("audio_"))).orElse(new String[0]);
|
||||
Arrays.sort(audioSegments);
|
||||
|
||||
File mp4VideoTrack = new File(segmentDir, "video.mp4");
|
||||
|
|
Loading…
Reference in New Issue