Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
Tweaks ffprobe arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Cordeiro committed May 3, 2023
1 parent 38dc395 commit d97300a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Wasari.Crunchyroll/CrunchyrollDownloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using FFMpegCore;
using FFMpegCore.Enums;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -103,14 +104,18 @@ private async IAsyncEnumerable<IWasariEpisodeInput> ProcessEpisode(ApiEpisode ep
{
await episode.LoadStreams(crunchyrollApiService);

if (episode.ApiEpisodeStreams?.Streams == null || episode.ApiEpisodeStreams.Streams.Length <= 0)
if (episode.ApiEpisodeStreams?.Streams is not { Length: > 0 })
{
Logger.LogWarning("Episode found with no stream options: {@Episode}", episode);
yield break;
}

var stream = episode.ApiEpisodeStreams.Streams.Single(o => o.Type == "adaptive_hls" && string.IsNullOrEmpty(o.Locale));
var mediaInfo = await FFProbe.AnalyseAsync(new Uri(stream.Url));
var mediaInfo = await FFProbe.AnalyseAsync(new Uri(stream.Url), new FFOptions
{
LogLevel = FFMpegLogLevel.Error,
UseCache = false
});
var bestVideo = mediaInfo.VideoStreams.OrderBy(vStream => vStream.Height + vStream.Width).Last();

yield return new WasariEpisodeInputWithStream(stream.Url, episode.Locale, !episode.IsDubbed ? InputType.VideoWithAudio : InputType.Audio, mediaInfo.PrimaryAudioStream?.Index, !episode.IsDubbed ? bestVideo.Index : null);
Expand Down

0 comments on commit d97300a

Please sign in to comment.