Example #1
0
        /// <summary>
        ///     Download latest FFmpeg version for current operating system to "." directory. Works best with FFmpeg.ExecutablesPath as path
        /// <param name="version">Determine which version of FFmpeg should be downloaded</param>
        /// <param name="path">FFmpeg executables destination directory</param>
        /// <param name="progress">Progress of download</param>
        /// </summary>
        public static async Task GetLatestVersion(FFmpegVersion version, string path, IProgress <ProgressInfo> progress = null)
        {
            IFFmpegDownloader downloader;

            switch (version)
            {
            case FFmpegVersion.Official:
                downloader = new OfficialFFmpegDownloader();
                break;

            case FFmpegVersion.Full:
                downloader = new FullFFmpegDownloader();
                break;

            case FFmpegVersion.Shared:
                downloader = new SharedFFmpegDownloader();
                break;

            case FFmpegVersion.Android:
                downloader = new AndroidFFmpegDownloader();
                break;

            default:
                throw new NotImplementedException();
            }
            await downloader.GetLatestVersion(path, progress);
        }
Example #2
0
        internal async Task DownloadLatestAndroidVersionWithProgressAndRetriesTest(OperatingSystemArchitecture arch)
        {
            var operatingSystemArchProvider = Substitute.For <IOperatingSystemArchitectureProvider>();

            operatingSystemArchProvider.GetArchitecture().Returns(x => arch);

            var ffmpegExecutablesPath = FFmpeg.ExecutablesPath;

            try
            {
                FFbinariesVersionInfo currentVersion = JsonConvert.DeserializeObject <FFbinariesVersionInfo>(File.ReadAllText(Resources.FFbinariesInfo));
                FFmpeg.SetExecutablesPath("assemblies");
                if (Directory.Exists("assemblies"))
                {
                    Directory.Delete("assemblies", true);
                }
                AndroidFFmpegDownloader  downloader = new AndroidFFmpegDownloader(operatingSystemArchProvider);
                IProgress <ProgressInfo> progress   = new Progress <ProgressInfo>();
                await downloader.GetLatestVersion(FFmpeg.ExecutablesPath, progress, 3);

                Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffmpeg", arch, FFmpeg.ExecutablesPath)));
                Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffprobe", arch, FFmpeg.ExecutablesPath)));
            }
            finally
            {
                FFmpeg.SetExecutablesPath(ffmpegExecutablesPath);
            }
        }
        internal async Task DownloadLatestAndroidVersionTest(OperatingSystemArchitecture arch)
        {
            var operatingSystemArchProvider = Substitute.For <IOperatingSystemArchitectureProvider>();

            operatingSystemArchProvider.GetArchitecture().Returns(x => arch);

            var ffmpegExecutablesPath = FFmpeg.ExecutablesPath;

            try
            {
                FFbinariesVersionInfo currentVersion = JsonConvert.DeserializeObject <FFbinariesVersionInfo>(File.ReadAllText(Resources.FFbinariesInfo));
                FFmpeg.SetExecutablesPath(_storageFixture.GetTempDirectory());
                AndroidFFmpegDownloader downloader = new AndroidFFmpegDownloader(operatingSystemArchProvider);
                await downloader.GetLatestVersion(FFmpeg.ExecutablesPath);

                Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffmpeg", arch, FFmpeg.ExecutablesPath)));
                Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffprobe", arch, FFmpeg.ExecutablesPath)));
            }
            finally
            {
                FFmpeg.SetExecutablesPath(ffmpegExecutablesPath);
            }
        }