Merge pull request #7443 from whiteowl3/strm-probe

pull/7495/head
Cody Robibero 3 years ago committed by GitHub
commit 8056b0e961
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -461,14 +461,16 @@ namespace MediaBrowser.MediaEncoding.Encoder
using (var processWrapper = new ProcessWrapper(process, this)) using (var processWrapper = new ProcessWrapper(process, this))
{ {
await using var memoryStream = new MemoryStream();
_logger.LogDebug("Starting ffprobe with args {Args}", args); _logger.LogDebug("Starting ffprobe with args {Args}", args);
StartProcess(processWrapper); StartProcess(processWrapper);
await process.StandardOutput.BaseStream.CopyToAsync(memoryStream, cancellationToken: cancellationToken);
memoryStream.Seek(0, SeekOrigin.Begin);
InternalMediaInfoResult result; InternalMediaInfoResult result;
try try
{ {
result = await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>( result = await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>(
process.StandardOutput.BaseStream, memoryStream,
_jsonSerializerOptions, _jsonSerializerOptions,
cancellationToken: cancellationToken).ConfigureAwait(false); cancellationToken: cancellationToken).ConfigureAwait(false);
} }

@ -100,25 +100,28 @@ namespace MediaBrowser.Providers.MediaInfo
foreach (var pathInfo in pathInfos) foreach (var pathInfo in pathInfos)
{ {
var mediaInfo = await GetMediaInfo(pathInfo.Path, _type, cancellationToken).ConfigureAwait(false); if (!pathInfo.Path.AsSpan().EndsWith(".strm", StringComparison.OrdinalIgnoreCase))
if (mediaInfo.MediaStreams.Count == 1)
{ {
MediaStream mediaStream = mediaInfo.MediaStreams[0]; var mediaInfo = await GetMediaInfo(pathInfo.Path, _type, cancellationToken).ConfigureAwait(false);
mediaStream.Index = startIndex++;
mediaStream.IsDefault = pathInfo.IsDefault || mediaStream.IsDefault;
mediaStream.IsForced = pathInfo.IsForced || mediaStream.IsForced;
mediaStreams.Add(MergeMetadata(mediaStream, pathInfo)); if (mediaInfo.MediaStreams.Count == 1)
}
else
{
foreach (MediaStream mediaStream in mediaInfo.MediaStreams)
{ {
MediaStream mediaStream = mediaInfo.MediaStreams[0];
mediaStream.Index = startIndex++; mediaStream.Index = startIndex++;
mediaStream.IsDefault = pathInfo.IsDefault || mediaStream.IsDefault;
mediaStream.IsForced = pathInfo.IsForced || mediaStream.IsForced;
mediaStreams.Add(MergeMetadata(mediaStream, pathInfo)); mediaStreams.Add(MergeMetadata(mediaStream, pathInfo));
} }
else
{
foreach (MediaStream mediaStream in mediaInfo.MediaStreams)
{
mediaStream.Index = startIndex++;
mediaStreams.Add(MergeMetadata(mediaStream, pathInfo));
}
}
} }
} }

Loading…
Cancel
Save