Merge pull request #1904 from JustAMan/hls-move-2

Switch ffmpeg to hls muxer (from segment) to fix premature stop on non-patched ffmpeg

(cherry picked from commit a460814182)
Signed-off-by: Joshua Boniface <joshua@boniface.me>
This commit is contained in:
Joshua M. Boniface
2019-11-03 14:36:34 -05:00
committed by Joshua Boniface
parent 1fad64cd59
commit 7a592a0f15
4 changed files with 86 additions and 44 deletions

View File

@@ -289,17 +289,22 @@ namespace MediaBrowser.Api.Playback
throw;
}
Logger.LogDebug("Launched ffmpeg process");
state.TranscodingJob = transcodingJob;
// Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback
_ = new JobLogger(Logger).StartStreamingLog(state, process.StandardError.BaseStream, logStream);
// Wait for the file to exist before proceeeding
while (!File.Exists(state.WaitForPath ?? outputPath) && !transcodingJob.HasExited)
var ffmpegTargetFile = state.WaitForPath ?? outputPath;
Logger.LogDebug("Waiting for the creation of {0}", ffmpegTargetFile);
while (!File.Exists(ffmpegTargetFile) && !transcodingJob.HasExited)
{
await Task.Delay(100, cancellationTokenSource.Token).ConfigureAwait(false);
}
Logger.LogDebug("File {0} created or transcoding has finished", ffmpegTargetFile);
if (state.IsInputVideo && transcodingJob.Type == TranscodingJobType.Progressive && !transcodingJob.HasExited)
{
await Task.Delay(1000, cancellationTokenSource.Token).ConfigureAwait(false);
@@ -314,6 +319,7 @@ namespace MediaBrowser.Api.Playback
{
StartThrottler(state, transcodingJob);
}
Logger.LogDebug("StartFfMpeg() finished successfully");
return transcodingJob;
}