mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update recorder
This commit is contained in:
parent
f283a21653
commit
83c1503333
@ -6,6 +6,7 @@ using MediaBrowser.Model.IO;
|
|||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
@ -29,7 +30,35 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
return targetFile;
|
return targetFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Record(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
|
public Task Record(IDirectStreamProvider directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (directStreamProvider != null)
|
||||||
|
{
|
||||||
|
return RecordFromDirectStreamProvider(directStreamProvider, targetFile, duration, onStarted, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RecordFromMediaSource(mediaSource, targetFile, duration, onStarted, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RecordFromDirectStreamProvider(IDirectStreamProvider directStreamProvider, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
||||||
|
{
|
||||||
|
onStarted();
|
||||||
|
|
||||||
|
_logger.Info("Copying recording stream to file {0}", targetFile);
|
||||||
|
|
||||||
|
// The media source if infinite so we need to handle stopping ourselves
|
||||||
|
var durationToken = new CancellationTokenSource(duration);
|
||||||
|
cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
|
||||||
|
|
||||||
|
await directStreamProvider.CopyToAsync(output, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Info("Recording completed to file {0}", targetFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RecordFromMediaSource(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var httpRequestOptions = new HttpRequestOptions
|
var httpRequestOptions = new HttpRequestOptions
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ using MediaBrowser.Model.LiveTv;
|
|||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
{
|
{
|
||||||
@ -64,6 +65,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
{
|
{
|
||||||
return "mkv";
|
return "mkv";
|
||||||
}
|
}
|
||||||
|
if (string.Equals(format, "ts", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return "ts";
|
||||||
|
}
|
||||||
|
|
||||||
return "mp4";
|
return "mp4";
|
||||||
}
|
}
|
||||||
@ -90,7 +95,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
return Path.ChangeExtension(targetFile, "." + extension);
|
return Path.ChangeExtension(targetFile, "." + extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Record(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
|
public async Task Record(IDirectStreamProvider directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
//var durationToken = new CancellationTokenSource(duration);
|
//var durationToken = new CancellationTokenSource(duration);
|
||||||
//cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
|
//cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
|
||||||
@ -177,6 +182,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
videoArgs = "-codec:v:0 copy";
|
videoArgs = "-codec:v:0 copy";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
videoArgs += " -fflags +genpts";
|
||||||
|
|
||||||
var durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks);
|
var durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks);
|
||||||
|
|
||||||
var flags = new List<string>();
|
var flags = new List<string>();
|
||||||
@ -188,6 +195,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
{
|
{
|
||||||
flags.Add("+ignidx");
|
flags.Add("+ignidx");
|
||||||
}
|
}
|
||||||
|
if (mediaSource.GenPtsInput)
|
||||||
|
{
|
||||||
|
flags.Add("+genpts");
|
||||||
|
}
|
||||||
|
|
||||||
var inputModifiers = "-async 1 -vsync -1";
|
var inputModifiers = "-async 1 -vsync -1";
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
@ -10,13 +11,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Records the specified media source.
|
/// Records the specified media source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mediaSource">The media source.</param>
|
Task Record(IDirectStreamProvider directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken);
|
||||||
/// <param name="targetFile">The target file.</param>
|
|
||||||
/// <param name="duration">The duration.</param>
|
|
||||||
/// <param name="onStarted">The on started.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task.</returns>
|
|
||||||
Task Record(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken);
|
|
||||||
|
|
||||||
string GetOutputPath(MediaSourceInfo mediaSource, string targetFile);
|
string GetOutputPath(MediaSourceInfo mediaSource, string targetFile);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user