コード例 #1
0
ファイル: FFMpegLoader.cs プロジェクト: egandt/Emby
        private void ExtractFFMpeg(FFMpegInstallInfo downloadinfo, string tempFile, string targetFolder)
        {
            _logger.Info("Extracting ffmpeg from {0}", tempFile);

            var tempFolder = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString());

            _fileSystem.CreateDirectory(tempFolder);

            try
            {
                ExtractArchive(downloadinfo, tempFile, tempFolder);

                var files = Directory.EnumerateFiles(tempFolder, "*", SearchOption.AllDirectories)
                            .ToList();

                foreach (var file in files.Where(i =>
                {
                    var filename = Path.GetFileName(i);

                    return
                    (string.Equals(filename, downloadinfo.FFProbeFilename, StringComparison.OrdinalIgnoreCase) ||
                     string.Equals(filename, downloadinfo.FFMpegFilename, StringComparison.OrdinalIgnoreCase));
                }))
                {
                    var targetFile = Path.Combine(targetFolder, Path.GetFileName(file));
                    _fileSystem.CopyFile(file, targetFile, true);
                    SetFilePermissions(targetFile);
                }
            }
            finally
            {
                DeleteFile(tempFile);
            }
        }
コード例 #2
0
ファイル: FFMpegLoader.cs プロジェクト: egandt/Emby
        private async Task <bool> DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress <double> progress)
        {
            foreach (var url in downloadinfo.DownloadUrls)
            {
                progress.Report(0);

                try
                {
                    var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
                    {
                        Url = url,
                        CancellationToken = CancellationToken.None,
                        Progress          = progress
                    }).ConfigureAwait(false);

                    ExtractFFMpeg(downloadinfo, tempFile, directory);
                    return(true);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error downloading {0}", ex, url);
                }
            }
            return(false);
        }
コード例 #3
0
ファイル: FFMpegLoader.cs プロジェクト: egandt/Emby
 public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, FFMpegInstallInfo ffmpegInstallInfo)
 {
     _logger            = logger;
     _appPaths          = appPaths;
     _httpClient        = httpClient;
     _zipClient         = zipClient;
     _fileSystem        = fileSystem;
     _environment       = environment;
     _ffmpegInstallInfo = ffmpegInstallInfo;
 }
コード例 #4
0
ファイル: FFMpegLoader.cs プロジェクト: softworkz/Emby
 public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, FFMpegInstallInfo ffmpegInstallInfo)
 {
     _logger = logger;
     _appPaths = appPaths;
     _httpClient = httpClient;
     _zipClient = zipClient;
     _fileSystem = fileSystem;
     _environment = environment;
     _ffmpegInstallInfo = ffmpegInstallInfo;
 }
コード例 #5
0
ファイル: FFMpegLoader.cs プロジェクト: waynus/Emby
 private async void DownloadFFMpegInBackground(FFMpegInstallInfo downloadinfo, string directory)
 {
     try
     {
         await DownloadFFMpeg(downloadinfo, directory, new Progress <double>()).ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         _logger.ErrorException("Error downloading ffmpeg", ex);
     }
 }
コード例 #6
0
ファイル: FFMpegLoader.cs プロジェクト: egandt/Emby
        private void ExtractArchive(FFMpegInstallInfo downloadinfo, string archivePath, string targetPath)
        {
            _logger.Info("Extracting {0} to {1}", archivePath, targetPath);

            if (string.Equals(downloadinfo.ArchiveType, "7z", StringComparison.OrdinalIgnoreCase))
            {
                _zipClient.ExtractAllFrom7z(archivePath, targetPath, true);
            }
            else if (string.Equals(downloadinfo.ArchiveType, "gz", StringComparison.OrdinalIgnoreCase))
            {
                _zipClient.ExtractAllFromTar(archivePath, targetPath, true);
            }
        }
コード例 #7
0
ファイル: FFMpegLoader.cs プロジェクト: waynus/Emby
        private async Task DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress <double> progress)
        {
            if (downloadinfo.IsEmbedded)
            {
                var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString());
                _fileSystem.CreateDirectory(Path.GetDirectoryName(tempFile));

                using (var stream = _ownerAssembly.GetManifestResourceStream(downloadinfo.DownloadUrls[0]))
                {
                    using (var fs = _fileSystem.GetFileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, true))
                    {
                        await stream.CopyToAsync(fs).ConfigureAwait(false);
                    }
                }
                ExtractFFMpeg(downloadinfo, tempFile, directory);
                return;
            }

            foreach (var url in downloadinfo.DownloadUrls)
            {
                progress.Report(0);

                try
                {
                    var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
                    {
                        Url = url,
                        CancellationToken = CancellationToken.None,
                        Progress          = progress
                    }).ConfigureAwait(false);

                    ExtractFFMpeg(downloadinfo, tempFile, directory);
                    return;
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error downloading {0}", ex, url);
                }
            }

            if (downloadinfo.DownloadUrls.Length == 0)
            {
                throw new ApplicationException("ffmpeg unvailable. Please install it and start the server with two command line arguments: -ffmpeg \"{PATH}\" and -ffprobe \"{PATH}\"");
            }

            throw new ApplicationException("Unable to download required components. Please try again later.");
        }
コード例 #8
0
ファイル: BaseMonoApp.cs プロジェクト: softworkz/Emby
        public static FFMpegInstallInfo GetInfo(NativeEnvironment environment)
        {
            var info = new FFMpegInstallInfo();

            // Windows builds: http://ffmpeg.zeranoe.com/builds/
            // Linux builds: http://johnvansickle.com/ffmpeg/
            // OS X builds: http://ffmpegmac.net/
            // OS X x64: http://www.evermeet.cx/ffmpeg/

            switch (environment.OperatingSystem)
            {
                case OperatingSystem.Osx:
                case OperatingSystem.Bsd:
                    break;
                case OperatingSystem.Linux:

                    info.ArchiveType = "7z";
                    info.Version = "20160215";
                    break;
            }

            info.DownloadUrls = GetDownloadUrls(environment);

            return info;
        }
コード例 #9
0
ファイル: BaseMonoApp.cs プロジェクト: paul-777/Emby
        public static FFMpegInstallInfo GetInfo(NativeEnvironment environment)
        {
            var info = new FFMpegInstallInfo();

            info.ArchiveType = "7z";

            switch (environment.SystemArchitecture)
            {
                case Architecture.X86_X64:
                    info.Version = "20160124";
                    break;
                case Architecture.X86:
                    info.Version = "20150110";
                    break;
            }

            info.DownloadUrls = GetDownloadUrls(environment);

            return info;
        }
コード例 #10
0
ファイル: FFMpegLoader.cs プロジェクト: paul-777/Emby
        private void ExtractArchive(FFMpegInstallInfo downloadinfo, string archivePath, string targetPath)
        {
            _logger.Info("Extracting {0} to {1}", archivePath, targetPath);

            if (string.Equals(downloadinfo.ArchiveType, "7z", StringComparison.OrdinalIgnoreCase))
            {
                _zipClient.ExtractAllFrom7z(archivePath, targetPath, true);
            }
            else if (string.Equals(downloadinfo.ArchiveType, "gz", StringComparison.OrdinalIgnoreCase))
            {
                _zipClient.ExtractAllFromTar(archivePath, targetPath, true);
            }
        }
コード例 #11
0
ファイル: FFMpegLoader.cs プロジェクト: paul-777/Emby
        private void ExtractFFMpeg(FFMpegInstallInfo downloadinfo, string tempFile, string targetFolder)
        {
            _logger.Info("Extracting ffmpeg from {0}", tempFile);

            var tempFolder = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString());

            _fileSystem.CreateDirectory(tempFolder);

            try
            {
                ExtractArchive(downloadinfo, tempFile, tempFolder);

                var files = Directory.EnumerateFiles(tempFolder, "*", SearchOption.AllDirectories)
                    .ToList();

                foreach (var file in files.Where(i =>
                    {
                        var filename = Path.GetFileName(i);

                        return
                            string.Equals(filename, downloadinfo.FFProbeFilename, StringComparison.OrdinalIgnoreCase) ||
                            string.Equals(filename, downloadinfo.FFMpegFilename, StringComparison.OrdinalIgnoreCase);
                    }))
                {
                    var targetFile = Path.Combine(targetFolder, Path.GetFileName(file));
                    _fileSystem.CopyFile(file, targetFile, true);
                    SetFilePermissions(targetFile);
                }
            }
            finally
            {
                DeleteFile(tempFile);
            }
        }
コード例 #12
0
ファイル: FFMpegLoader.cs プロジェクト: paul-777/Emby
        private async Task DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress<double> progress)
        {
            if (downloadinfo.IsEmbedded)
            {
                var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString());
                _fileSystem.CreateDirectory(Path.GetDirectoryName(tempFile));

                using (var stream = _ownerAssembly.GetManifestResourceStream(downloadinfo.DownloadUrls[0]))
                {
                    using (var fs = _fileSystem.GetFileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, true))
                    {
                        await stream.CopyToAsync(fs).ConfigureAwait(false);
                    }
                }
                ExtractFFMpeg(downloadinfo, tempFile, directory);
                return;
            }

            foreach (var url in downloadinfo.DownloadUrls)
            {
                progress.Report(0);

                try
                {
                    var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
                    {
                        Url = url,
                        CancellationToken = CancellationToken.None,
                        Progress = progress

                    }).ConfigureAwait(false);

                    ExtractFFMpeg(downloadinfo, tempFile, directory);
                    return;
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error downloading {0}", ex, url);
                }
            }

            if (downloadinfo.DownloadUrls.Length == 0)
            {
                throw new ApplicationException("ffmpeg unvailable. Please install it and start the server with two command line arguments: -ffmpeg \"{PATH}\" and -ffprobe \"{PATH}\"");
            }

            throw new ApplicationException("Unable to download required components. Please try again later.");
        }
コード例 #13
0
ファイル: FFMpegLoader.cs プロジェクト: paul-777/Emby
 private async void DownloadFFMpegInBackground(FFMpegInstallInfo downloadinfo, string directory)
 {
     try
     {
         await DownloadFFMpeg(downloadinfo, directory, new Progress<double>()).ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         _logger.ErrorException("Error downloading ffmpeg", ex);
     }
 }
コード例 #14
0
ファイル: WindowsApp.cs プロジェクト: softworkz/Emby
        public FFMpegInstallInfo GetFfmpegInstallInfo()
        {
            var info = new FFMpegInstallInfo();

            info.FFMpegFilename = "ffmpeg.exe";
            info.FFProbeFilename = "ffprobe.exe";
            info.Version = "0";

            return info;
        }
コード例 #15
0
ファイル: FFMpegLoader.cs プロジェクト: softworkz/Emby
        private async Task<bool> DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress<double> progress)
        {
            foreach (var url in downloadinfo.DownloadUrls)
            {
                progress.Report(0);

                try
                {
                    var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
                    {
                        Url = url,
                        CancellationToken = CancellationToken.None,
                        Progress = progress

                    }).ConfigureAwait(false);

                    ExtractFFMpeg(downloadinfo, tempFile, directory);
                    return true;
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error downloading {0}", ex, url);
                }
            }
            return false;
        }
コード例 #16
0
ファイル: WindowsApp.cs プロジェクト: paul-777/Emby
        public FFMpegInstallInfo GetFfmpegInstallInfo()
        {
            var info = new FFMpegInstallInfo();

            info.FFMpegFilename = "ffmpeg.exe";
            info.FFProbeFilename = "ffprobe.exe";
            info.Version = "20160410";
            info.ArchiveType = "7z";
            info.IsEmbedded = false;
            info.DownloadUrls = GetDownloadUrls();

            return info;
        }