public void ProcessVideo(string uri) { try { // Get the audio format and bit rate from the settings AudioFormat format = FileFormats.GetValidAudioFormat(SettingsClient.Get <string>("Output", "Format")); int bitRate = FileFormats.GetValidBitRate(SettingsClient.Get <int>("Output", "BitRate")); // Create a temporary directory string tempFolder = Path.Combine(this.workingFolder, Guid.NewGuid().ToString()); if (!Directory.Exists(tempFolder)) { Directory.CreateDirectory(tempFolder); } if (this.IsVideoUrl(uri)) { // Process the video URL this.ConvertOnlineVideo(tempFolder, uri, format, bitRate); } else if (this.IsVideoFile(uri)) { // Process the video file this.ConvertLocalVideo(tempFolder, uri, format, bitRate); } } catch (Exception ex) { LogClient.Error("An error occurred while processing the video. Exception: {0}", ex.Message); this.SetConvertState(ConvertState.Failed); } }
private async void GetBitRatesAsync() { var localBitRates = new ObservableCollection <NameValue>(); string bitRateUnit = "kbps"; await Task.Run(() => { localBitRates.Add(new NameValue() { Name = $"32 {bitRateUnit}", Value = 32 }); localBitRates.Add(new NameValue() { Name = $"48 {bitRateUnit}", Value = 48 }); localBitRates.Add(new NameValue() { Name = $"56 {bitRateUnit}", Value = 56 }); localBitRates.Add(new NameValue() { Name = $"64 {bitRateUnit}", Value = 64 }); localBitRates.Add(new NameValue() { Name = $"96 {bitRateUnit}", Value = 96 }); localBitRates.Add(new NameValue() { Name = $"128 {bitRateUnit}", Value = 128 }); localBitRates.Add(new NameValue() { Name = $"160 {bitRateUnit}", Value = 160 }); localBitRates.Add(new NameValue() { Name = $"192 {bitRateUnit}", Value = 192 }); localBitRates.Add(new NameValue() { Name = $"224 {bitRateUnit}", Value = 224 }); localBitRates.Add(new NameValue() { Name = $"256 {bitRateUnit}", Value = 256 }); localBitRates.Add(new NameValue() { Name = $"320 {bitRateUnit}", Value = 320 }); }); this.BitRates = localBitRates; NameValue localSelectedBitRate = null; int bitRate = FileFormats.GetValidBitRate(SettingsClient.Get <int>("Output", "BitRate")); await Task.Run(() => localSelectedBitRate = new NameValue() { Name = $"{bitRate} {bitRateUnit}", Value = bitRate }); this.SelectedBitRate = localSelectedBitRate; }