Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        private async void GetAudioFormatsAsync()
        {
            var localAudioFormats = new ObservableCollection <AudioFormat>();

            await Task.Run(() =>
            {
                foreach (AudioFormat format in FileFormats.SupportedAudioFormats.OrderBy(f => f.Name))
                {
                    localAudioFormats.Add(format);
                }
            });

            this.AudioFormats = localAudioFormats;

            AudioFormat localSelectedAudioFormat = null;

            await Task.Run(() => localSelectedAudioFormat = FileFormats.GetValidAudioFormat(SettingsClient.Get <string>("Output", "Format")));

            this.SelectedAudioFormat = localSelectedAudioFormat;
        }