Add config setting to log missed segments

This commit is contained in:
0xb00bface 2021-02-13 22:39:21 +01:00
parent 500be5eee4
commit 0f125f6e63
4 changed files with 13 additions and 4 deletions

View File

@ -1,3 +1,10 @@
4.0.0
========================
* Rewrite of the recorder internals
* Creation of contact sheets is much faster
* You can now add timestamps to the contact sheet
* Fix online state detection for Bongacams
3.13.1
========================
* Fixed Streamate tabs

View File

@ -119,6 +119,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private SimpleStringProperty ffmpegParameters;
private SimpleBooleanProperty logFFmpegOutput;
private SimpleBooleanProperty loghlsdlOutput;
private SimpleBooleanProperty logMissedSegments;
private SimpleStringProperty fileExtension;
private SimpleStringProperty server;
private SimpleIntegerProperty port;
@ -177,6 +178,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
ffmpegParameters = new SimpleStringProperty(null, "ffmpegMergedDownloadArgs", settings.ffmpegMergedDownloadArgs);
logFFmpegOutput = new SimpleBooleanProperty(null, "logFFmpegOutput", settings.logFFmpegOutput);
loghlsdlOutput = new SimpleBooleanProperty(null, "loghlsdlOutput", settings.loghlsdlOutput);
logMissedSegments = new SimpleBooleanProperty(null, "logMissedSegments", settings.logMissedSegments);
fileExtension = new SimpleStringProperty(null, "ffmpegFileSuffix", settings.ffmpegFileSuffix);
server = new SimpleStringProperty(null, "httpServer", settings.httpServer);
port = new SimpleIntegerProperty(null, "httpPort", settings.httpPort);
@ -283,7 +285,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
Setting.of("Playlist request timeout (ms)", playlistRequestTimeout, "Timeout in ms for playlist requests")
),
Group.of("Logging",
Setting.of("Log FFmpeg output", logFFmpegOutput, "Log FFmpeg output to files in the system's temp directory")
Setting.of("Log FFmpeg output", logFFmpegOutput, "Log FFmpeg output to files in the system's temp directory"),
Setting.of("Log missed segments", logMissedSegments, "Write a log files in the system's temp directory to analyze missed segments")
),
Group.of("hlsdl (experimental)",
Setting.of("Use hlsdl (if possible)", useHlsdl, "Use hlsdl to record the live streams. Some features might not work correctly."),

View File

@ -87,6 +87,7 @@ public class Settings {
public boolean localRecording = true;
public boolean logFFmpegOutput = false;
public boolean loghlsdlOutput = false;
public boolean logMissedSegments = false;
public int minimumResolution = 0;
public int maximumResolution = 8640;
public int maximumResolutionPlayer = 0;

View File

@ -30,7 +30,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@ -73,7 +72,6 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
private static final transient Logger LOG = LoggerFactory.getLogger(AbstractHlsDownload.class);
private static final int TEN_SECONDS = 10_000;
private static final boolean DEBUG_HLS = Objects.equals(System.getenv("CTBREC_DEBUG_HLS"), "true");
private transient NumberFormat nf = new DecimalFormat("000000");
private transient int playlistEmptyCount = 0;
@ -321,7 +319,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
private void handleMissedSegments(SegmentPlaylist playlist, int nextSegmentNumber) throws IOException {
if (nextSegmentNumber > 0 && playlist.seq > nextSegmentNumber) {
recordingEvents.add(RecordingEvent.of("Missed segments: "+nextSegmentNumber+" < " + playlist.seq));
if (DEBUG_HLS) {
if (config.getSettings().logMissedSegments) {
File hlsEventsFile = File.createTempFile("/tmp/rec_evt_" + Instant.now() + "_" + model.getSanitizedNamed(), ".log");
try (OutputStream outputStream = Files.newOutputStream(hlsEventsFile.toPath(), CREATE, WRITE, TRUNCATE_EXISTING)) {
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(outputStream));