mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-16 19:15:44 +00:00
Compare commits
3 commits
9f6249cb5f
...
483c526772
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
483c526772 | ||
|
|
1c03587cd8 | ||
|
|
644c41df90 |
3 changed files with 7 additions and 11 deletions
|
|
@ -30,21 +30,21 @@ public class FFMpegDownloader
|
||||||
// download ffmpeg if selected
|
// download ffmpeg if selected
|
||||||
if (binaries.HasFlag(FFMpegBinaries.FFMpeg) && downloadInfo.FFMpeg is not null)
|
if (binaries.HasFlag(FFMpegBinaries.FFMpeg) && downloadInfo.FFMpeg is not null)
|
||||||
{
|
{
|
||||||
var zipStream = FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFMpeg));
|
await using var zipStream = await FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFMpeg));
|
||||||
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
|
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
// download ffprobe if selected
|
// download ffprobe if selected
|
||||||
if (binaries.HasFlag(FFMpegBinaries.FFProbe) && downloadInfo.FFProbe is not null)
|
if (binaries.HasFlag(FFMpegBinaries.FFProbe) && downloadInfo.FFProbe is not null)
|
||||||
{
|
{
|
||||||
var zipStream = FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFProbe));
|
await using var zipStream = await FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFProbe));
|
||||||
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
|
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
// download ffplay if selected
|
// download ffplay if selected
|
||||||
if (binaries.HasFlag(FFMpegBinaries.FFPlay) && downloadInfo.FFPlay is not null)
|
if (binaries.HasFlag(FFMpegBinaries.FFPlay) && downloadInfo.FFPlay is not null)
|
||||||
{
|
{
|
||||||
var zipStream = FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFPlay));
|
await using var zipStream = await FFbinariesService.DownloadFileAsSteam(new Uri(downloadInfo.FFPlay));
|
||||||
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
|
successList.AddRange(FFbinariesService.ExtractZipAndSave(zipStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Net;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using FFMpegCore.Extensions.Downloader.Enums;
|
using FFMpegCore.Extensions.Downloader.Enums;
|
||||||
using FFMpegCore.Extensions.Downloader.Exceptions;
|
using FFMpegCore.Extensions.Downloader.Exceptions;
|
||||||
|
|
@ -43,13 +42,10 @@ internal class FFbinariesService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="address">uri of the file</param>
|
/// <param name="address">uri of the file</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal static MemoryStream DownloadFileAsSteam(Uri address)
|
internal static async Task<Stream> DownloadFileAsSteam(Uri address)
|
||||||
{
|
{
|
||||||
var client = new WebClient();
|
var client = new HttpClient();
|
||||||
var fileStream = new MemoryStream(client.DownloadData(address));
|
return await client.GetStreamAsync(address);
|
||||||
fileStream.Position = 0;
|
|
||||||
|
|
||||||
return fileStream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ public class DownloaderTests
|
||||||
public void GetSpecificVersionTest()
|
public void GetSpecificVersionTest()
|
||||||
{
|
{
|
||||||
var binaries = FFMpegDownloader.DownloadFFMpegSuite(FFMpegVersions.V6_1).Result;
|
var binaries = FFMpegDownloader.DownloadFFMpegSuite(FFMpegVersions.V6_1).Result;
|
||||||
Assert.IsTrue(binaries.Count == 1);
|
Assert.IsTrue(binaries.Count == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue