Add extensive logging to stream worker startPlayback function
This commit is contained in:
parent
74f701fb04
commit
384a6f9b94
1 changed files with 24 additions and 0 deletions
|
|
@ -363,6 +363,7 @@ async function startPlayback(session, playback, startSeconds = 0) {
|
||||||
);
|
);
|
||||||
|
|
||||||
const options = streamOptions();
|
const options = streamOptions();
|
||||||
|
console.log(`[worker] Calling prepareStream with options:`, JSON.stringify(options, null, 2));
|
||||||
const prepared = streamingStack.prepareStream(
|
const prepared = streamingStack.prepareStream(
|
||||||
session.positionSeconds > 0 ? streamUrlAtOffset(input, session.positionSeconds) : input,
|
session.positionSeconds > 0 ? streamUrlAtOffset(input, session.positionSeconds) : input,
|
||||||
options,
|
options,
|
||||||
|
|
@ -375,20 +376,41 @@ async function startPlayback(session, playback, startSeconds = 0) {
|
||||||
}
|
}
|
||||||
session.ffmpegCommand = command;
|
session.ffmpegCommand = command;
|
||||||
|
|
||||||
|
command.on("start", (commandLine) => {
|
||||||
|
console.log(`[worker] FFmpeg command line: ${commandLine}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
command.on("codecData", (data) => {
|
||||||
|
console.log(`[worker] FFmpeg codec data:`, JSON.stringify(data, null, 2));
|
||||||
|
});
|
||||||
|
|
||||||
|
command.on("progress", (progress) => {
|
||||||
|
console.log(`[worker] FFmpeg progress: frame=${progress.frames} fps=${progress.currentFps} kbps=${progress.currentKbps} time=${progress.timemark}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
command.on("stderr", (line) => {
|
||||||
|
console.log(`[worker] FFmpeg stderr: ${line}`);
|
||||||
|
});
|
||||||
|
|
||||||
command.on("error", (error) => {
|
command.on("error", (error) => {
|
||||||
if (session.manualStop || abortController.signal.aborted) {
|
if (session.manualStop || abortController.signal.aborted) {
|
||||||
|
console.log("[worker] FFmpeg command ended/stopped manually.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.error("[worker] FFmpeg command error:", error);
|
||||||
session.lastError = error && error.message ? String(error.message) : "FFmpeg stream failed";
|
session.lastError = error && error.message ? String(error.message) : "FFmpeg stream failed";
|
||||||
session.playbackState = "error";
|
session.playbackState = "error";
|
||||||
session.workerStatus = "error";
|
session.workerStatus = "error";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("[worker] Initializing playStream...");
|
||||||
streamingStack.playStream(output, runtime.streamer, playMode, abortController.signal)
|
streamingStack.playStream(output, runtime.streamer, playMode, abortController.signal)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (session.manualStop || abortController.signal.aborted) {
|
if (session.manualStop || abortController.signal.aborted) {
|
||||||
|
console.log("[worker] playStream finished (manually stopped/aborted).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log("[worker] playStream completed successfully.");
|
||||||
session.positionSeconds = session.durationSeconds > 0 ? session.durationSeconds : sessionPlaybackPosition(session);
|
session.positionSeconds = session.durationSeconds > 0 ? session.durationSeconds : sessionPlaybackPosition(session);
|
||||||
session.startedAtSeconds = 0;
|
session.startedAtSeconds = 0;
|
||||||
session.playbackState = "idle";
|
session.playbackState = "idle";
|
||||||
|
|
@ -398,8 +420,10 @@ async function startPlayback(session, playback, startSeconds = 0) {
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (session.manualStop || abortController.signal.aborted) {
|
if (session.manualStop || abortController.signal.aborted) {
|
||||||
|
console.log("[worker] playStream rejected (manually stopped/aborted).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.error("[worker] playStream failed with error:", error);
|
||||||
session.lastError = error && error.message ? String(error.message) : "Streaming failed";
|
session.lastError = error && error.message ? String(error.message) : "Streaming failed";
|
||||||
session.startedAtSeconds = 0;
|
session.startedAtSeconds = 0;
|
||||||
session.playbackState = "error";
|
session.playbackState = "error";
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue