diff --git a/Qwilight/Assets/x64/avcodec-60.dll b/Qwilight/Assets/x64/avcodec-60.dll new file mode 100644 index 0000000..4fb5d33 --- /dev/null +++ b/Qwilight/Assets/x64/avcodec-60.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6f9c2e6120057246b6dec4ad456dc2fa54fb48109d0ed5373c9049ef65fe40a +size 78533120 diff --git a/Qwilight/Assets/x64/avdevice-60.dll b/Qwilight/Assets/x64/avdevice-60.dll new file mode 100644 index 0000000..1eea7ee --- /dev/null +++ b/Qwilight/Assets/x64/avdevice-60.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c80c376bab5dd2d15cc0f69f1b0c112cc5da33c578db09cd1718a4d406bac00a +size 4382720 diff --git a/Qwilight/Assets/x64/avfilter-9.dll b/Qwilight/Assets/x64/avfilter-9.dll new file mode 100644 index 0000000..b2d27b7 --- /dev/null +++ b/Qwilight/Assets/x64/avfilter-9.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ca260b1682ad0dfecad6b74183697c5af7cd6041e38fc8442344fd5e0a8b5b4 +size 39698944 diff --git a/Qwilight/Assets/x64/avformat-60.dll b/Qwilight/Assets/x64/avformat-60.dll new file mode 100644 index 0000000..366928d --- /dev/null +++ b/Qwilight/Assets/x64/avformat-60.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1c005328f42a6ddcdee81bd0a4e7207da929f910030c05a0e44793baea3d9ff +size 17244672 diff --git a/Qwilight/Assets/x64/avutil-58.dll b/Qwilight/Assets/x64/avutil-58.dll new file mode 100644 index 0000000..f26afa5 --- /dev/null +++ b/Qwilight/Assets/x64/avutil-58.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e932b5cf15897e6fec4f789cb11e4f6d07da5db0b1b802f1789d64bb0e12f2c +size 2302976 diff --git a/Qwilight/Assets/x64/ffmpeg.exe b/Qwilight/Assets/x64/ffmpeg.exe index e323423..3b6867e 100644 --- a/Qwilight/Assets/x64/ffmpeg.exe +++ b/Qwilight/Assets/x64/ffmpeg.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b9fb1e0934e04b91b6924de97edd2e1b80fc5dfa0a7f08c32b9c5cca3a12717b -size 131666944 +oid sha256:655b6620d6be16bc407c2a124430be46fbcca87909e685f42f80af5089e4c93f +size 388608 diff --git a/Qwilight/Assets/x64/ffprobe.exe b/Qwilight/Assets/x64/ffprobe.exe new file mode 100644 index 0000000..ddc62ee --- /dev/null +++ b/Qwilight/Assets/x64/ffprobe.exe @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eff5050810b6c12708ccf1a8bec8bc7ec537f43b7ec2f349908d795f3a379a50 +size 192000 diff --git a/Qwilight/Assets/x64/postproc-57.dll b/Qwilight/Assets/x64/postproc-57.dll new file mode 100644 index 0000000..944e5be --- /dev/null +++ b/Qwilight/Assets/x64/postproc-57.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a0579c154099b90abc2620b1503e9035304c99863da266ef2a51f24bf38cd1a +size 76288 diff --git a/Qwilight/Assets/x64/swresample-4.dll b/Qwilight/Assets/x64/swresample-4.dll new file mode 100644 index 0000000..b458395 --- /dev/null +++ b/Qwilight/Assets/x64/swresample-4.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51a941274807c0f12464cc918c4e7232914924c2d4128ea8554bffa4f7f23665 +size 436224 diff --git a/Qwilight/Assets/x64/swscale-7.dll b/Qwilight/Assets/x64/swscale-7.dll new file mode 100644 index 0000000..312c9f6 --- /dev/null +++ b/Qwilight/Assets/x64/swscale-7.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:201c421d59b075b651dc1ff7fbc141633558435034afba974aad739423ef4d5c +size 643072 diff --git a/Qwilight/Qwilight.csproj b/Qwilight/Qwilight.csproj index 288e866..aebe3dc 100644 --- a/Qwilight/Qwilight.csproj +++ b/Qwilight/Qwilight.csproj @@ -42,7 +42,6 @@ - @@ -239,12 +238,30 @@ + + Always + + + Always + + + Always + + + Always + + + Always + Always Always + + Always + Always @@ -263,6 +280,9 @@ Always + + Always + Always @@ -275,6 +295,12 @@ Always + + Always + + + Always + Always diff --git a/Qwilight/QwilightComponent.cs b/Qwilight/QwilightComponent.cs index acbb7bf..7107636 100644 --- a/Qwilight/QwilightComponent.cs +++ b/Qwilight/QwilightComponent.cs @@ -50,6 +50,7 @@ public static readonly string[] AudioFileFormats = new[] { ".aif", ".aiff", ".asf", ".flac", ".m4a", ".mid", ".midi", ".mp2", ".mp3", ".ogg", ".opus", ".raw", ".wav", ".wma" }; public static readonly string[] DrawingFileFormats = new[] { ".bmp", ".gif", ".jpeg", ".jpg", ".png" }; public static readonly string[] MediaFileFormats = new[] { ".avi", ".flv", ".m1v", ".mkv", ".mov", ".mp4", ".mpeg", ".mpg", ".wmv" }; + public static readonly string[] ModifiedMediaFileFormats = new[] { ".avi", ".flv", ".m1v", ".mpeg", ".mpg" }; public static readonly string HashText = Utility.GetID512(File.ReadAllBytes(Path.Combine(AppContext.BaseDirectory, "Qwilight.dll"))); public static readonly Version Date = Assembly.GetEntryAssembly().GetName().Version; public static readonly string DateText = $"{Date.Major}.{Date.Minor}.{Date.Build}"; diff --git a/Qwilight/System/MediaSystem/HandledMediaItem.cs b/Qwilight/System/MediaSystem/HandledMediaItem.cs index d3f2d6b..efa29ad 100644 --- a/Qwilight/System/MediaSystem/HandledMediaItem.cs +++ b/Qwilight/System/MediaSystem/HandledMediaItem.cs @@ -1,12 +1,9 @@ -using FFmpegInteropX; -using Windows.Media.Playback; +using Windows.Media.Playback; namespace Qwilight { public sealed class HandledMediaItem : IHandledItem, IDisposable { - public FFmpegMediaSource MediaSrc { get; init; } - public MediaPlayer Media { get; init; } public System.Windows.Media.MediaPlayer DefaultMedia { get; set; } diff --git a/Qwilight/System/MediaSystem/MediaSystem.cs b/Qwilight/System/MediaSystem/MediaSystem.cs index 1792706..5849577 100644 --- a/Qwilight/System/MediaSystem/MediaSystem.cs +++ b/Qwilight/System/MediaSystem/MediaSystem.cs @@ -1,8 +1,10 @@ -using FFmpegInteropX; -using Qwilight.Utilities; +using Qwilight.Utilities; using Qwilight.ViewModel; using System.Collections.Concurrent; +using System.Diagnostics; using System.IO; +using Windows.Media.Core; +using Windows.Media.Playback; namespace Qwilight { @@ -11,6 +13,10 @@ public static readonly MediaSystem Instance = new(); static readonly object _exeCSX = new(); + static readonly string[] _validMedia = new string[] + { + "e82d6a96a58c9a01098fa4a53f95c5ad" + }; static readonly string[] _wrongMedia = new string[] { "ed7f217838d78942898e53d5dbee64ec" // Celestial Axes @@ -95,8 +101,8 @@ return handledMediaItem; } - var mediaSrc = FFmpegMediaSource.CreateFromFileAsync(mediaFilePath).Await(); - var mediaLength = mediaSrc.Duration; + var mediaSrc = MediaSource.CreateFromUri(new Uri(mediaFilePath)); + var mediaLength = GetMediaLength(mediaFilePath); var mediaModifierValue = mediaContainer.MediaModifierValue; if (mediaModifierValue != null) { @@ -109,8 +115,8 @@ } else { - var isWrongMedia = Array.IndexOf(_wrongMedia, hash) != -1 || mediaLength < TimeSpan.FromMinutes(1.0); - var hasAudio = mediaSrc.AudioStreams.Count > 0; + var isWrongMedia = Array.IndexOf(_wrongMedia, hash) != -1 || (Array.IndexOf(_validMedia, hash) == -1 && QwilightComponent.ModifiedMediaFileFormats.Any(format => mediaFilePath.IsTailCaselsss(format))); + var hasAudio = HasAudio(mediaFilePath); if (isWrongMedia || hasAudio || isCounterWave) { mediaSrc.Dispose(); @@ -122,20 +128,19 @@ } } } - mediaSrc ??= FFmpegMediaSource.CreateFromFileAsync(mediaFilePath).Await(); - mediaLength = mediaSrc.Duration; + mediaSrc = MediaSource.CreateFromUri(new Uri(mediaFilePath)); + mediaLength = GetMediaLength(mediaFilePath); handledMediaItem = new() { - MediaSrc = mediaSrc, Media = new() { - Source = mediaSrc.CreateMediaPlaybackItem(), + Source = new MediaPlaybackItem(MediaSource.CreateFromUri(new(mediaFilePath))), IsMuted = true, IsVideoFrameServerEnabled = true, IsLoopingEnabled = isLooping }, MediaFilePath = mediaFilePath, - Length = mediaLength.TotalMilliseconds, + Length = mediaLength, IsLooping = isLooping }; handledMediaItem.Media.CommandManager.IsEnabled = false; @@ -332,5 +337,63 @@ _mediaMap[target] = audioItems; } } + + static double GetMediaLength(string fileName) + { + var mediaLength = 0.0; + using (var exe = new Process + { + StartInfo = new(Path.Combine(QwilightComponent.CPUAssetsEntryPath, "ffprobe.exe"), $""" + -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "{fileName}" + """) + { + CreateNoWindow = true, + RedirectStandardOutput = true + } + }) + { + exe.OutputDataReceived += (sender, e) => + { + if (!string.IsNullOrEmpty(e.Data)) + { + Utility.ToFloat64(e.Data, out mediaLength); + } + }; + exe.Start(); + exe.PriorityClass = ProcessPriorityClass.Idle; + exe.BeginOutputReadLine(); + exe.WaitForExit(); + } + return 1000.0 * mediaLength; + } + + static bool HasAudio(string fileName) + { + var hasAudio = false; + using (var exe = new Process + { + StartInfo = new(Path.Combine(QwilightComponent.CPUAssetsEntryPath, "ffprobe.exe"), $""" + -v error -show_entries stream=codec_type -of default=noprint_wrappers=1:nokey=1 "{fileName}" + """) + { + CreateNoWindow = true, + RedirectStandardOutput = true + } + }) + { + exe.OutputDataReceived += (sender, e) => + { + if (!string.IsNullOrEmpty(e.Data)) + { + hasAudio |= e.Data.Contains("audio"); + } + }; + exe.Start(); + exe.PriorityClass = ProcessPriorityClass.Idle; + exe.BeginOutputReadLine(); + exe.WaitForExit(); + } + return hasAudio; + } } } \ No newline at end of file diff --git a/Qwilight/View/AssistWindow.xaml b/Qwilight/View/AssistWindow.xaml index 447b5fc..6de7dce 100644 --- a/Qwilight/View/AssistWindow.xaml +++ b/Qwilight/View/AssistWindow.xaml @@ -324,14 +324,6 @@ - - - - - - - -