/// <summary> /// Converts the original '.ts' file into an mp4 file using ffmpeg. /// </summary> /// <param name="streamingCombineUiModel">The conversion meta data.</param> /// <param name="progressIndicator">The progress indicator.</param> public void ConvertFile(IStreamingCombineUiModel streamingCombineUiModel, IProgress <IProgressData> progressIndicator) { FrapperWrapper frapperWrapper = new FrapperWrapper(new FFMPEG()); IFfmpegCommand command = new FfmpegConversionCommandBuilder() .AddInputFilePath(streamingCombineUiModel.UnconvertedFilePath) .AddOutputFilePath(streamingCombineUiModel.ConvertedFilePath) .AddBitStreamFilter(BitStreamFilter.AacAdtstoasc) .GetCommand(); frapperWrapper.ExecuteCommand(command); IProgressData progressData = new ProgressData { PercentDone = 95 }; progressIndicator.Report(progressData); if (streamingCombineUiModel.CanDeleteUnconvertedFile) { DeleteFile(streamingCombineUiModel.UnconvertedFilePath); } progressData.PercentDone = 100; progressIndicator.Report(progressData); }
/// <summary> /// Gets the chunk file list. /// </summary> /// <param name="streamingCombineUiModel">The view model.</param> /// <param name="progressIndicator">The progress indicator.</param> /// <returns>The view model.</returns> public async Task <IStreamingCombineUiModel> GetChunkFileList(IStreamingCombineUiModel streamingCombineUiModel, IProgress <IProgressData> progressIndicator) { Queue <Uri> chunkFiles = await Task.Factory.StartNew(() => _chunkFileListParser.GetChunkFileList(streamingCombineUiModel.ChunkListFileUrl, progressIndicator) ); streamingCombineUiModel.ParsedChunks = chunkFiles; streamingCombineUiModel.NumberOfChunkFiles = streamingCombineUiModel.ParsedChunks.Count; return(streamingCombineUiModel); }
/// <summary> /// Downloads the chunk files. /// </summary> /// <param name="streamingCombineUiModel">The streaming combine UI model.</param> /// <param name="progressIndicator">The progress indicator.</param> public async Task DownloadChunkFiles(IStreamingCombineUiModel streamingCombineUiModel, IProgress <IProgressData> progressIndicator) { _downloadChunksCancellationTokenSource = new CancellationTokenSource(); _downloadChunksCancellationToken = _downloadChunksCancellationTokenSource.Token; await Task.Factory.StartNew(() => _chunkDownloader.DownloadFileChunks( streamingCombineUiModel.ParsedChunks, streamingCombineUiModel.TempDirectory, progressIndicator, _downloadChunksCancellationToken), _downloadChunksCancellationToken ); }
/// <summary> /// Combines the chunk files. /// </summary> /// <param name="streamingCombineUiModel">The conversion meta data.</param> /// <param name="progressIndicator">The progress indicator.</param> public async void CombineChunkFiles(IStreamingCombineUiModel streamingCombineUiModel, IProgress <IProgressData> progressIndicator) { _combineChunksCancellationTokenSource = new CancellationTokenSource(); _combineChunksCancellationToken = _combineChunksCancellationTokenSource.Token; IEnumerable <FileInfo> chunkFiles = _chunkFileCombiner.GetChunkFileInfos(streamingCombineUiModel.TempDirectory); await Task.Factory.StartNew(() => _chunkFileCombiner.CombineChunkFiles( chunkFiles, streamingCombineUiModel.UnconvertedFilePath, progressIndicator, _combineChunksCancellationToken), _combineChunksCancellationToken ); if (streamingCombineUiModel.CanDeleteOldChunkFiles) { foreach (var chunkFile in chunkFiles) { chunkFile.Delete(); } } }