Beispiel #1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (Environment.GetCommandLineArgs().Length > 1)
            {
                string sourcePath = Environment.GetCommandLineArgs()[1];
                string extension  = Path.GetExtension(sourcePath);
                if (Array.IndexOf(SUPPORTED_EXTENSIONS, extension) > -1)
                {
                    mediaInfo = await MediaInfo.Open(sourcePath);

                    OpenSource();
                }
            }
        }
Beispiel #2
0
        private async void ButtonOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title       = "Select the source file";
            ofd.Multiselect = false;
            ofd.Filter      = "Video files|";
            foreach (var item in SUPPORTED_EXTENSIONS)
            {
                ofd.Filter += $"*{item};";
            }
            bool?result = ofd.ShowDialog();

            if (result == true)
            {
                mediaInfo = await MediaInfo.Open(ofd.FileName);

                OpenSource();
            }
        }
Beispiel #3
0
        private async void Rectangle_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] paths     = (string[])e.Data.GetData(DataFormats.FileDrop);
                string   extension = Path.GetExtension(paths[0]);
                if (Array.IndexOf(SUPPORTED_EXTENSIONS, extension) > -1)
                {
                    mediaInfo = await MediaInfo.Open(paths[0]);

                    OpenSource();
                }
                else
                {
                    MessageBox.Show("File not supported!");
                }
            }
            Storyboard storyboard = FindResource("DragOverAnimation") as Storyboard;

            storyboard.Stop();
        }
Beispiel #4
0
        private async void ConversionCompleted(ProgressData progressData)
        {
            DoubleAnimation progressAnimation = new DoubleAnimation(100, TimeSpan.FromSeconds(0));

            progressBarConvertProgress.BeginAnimation(ProgressBar.ValueProperty, progressAnimation);
            textBlockProgress.Text = progressData.IsFastCut ? "Video cut!" : "Video converted!";
            string outputSize = GetBytesReadable(new FileInfo(currentOutputPath).Length);

            textBlockSize.Text            = "Output size: " + outputSize;
            TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
            Storyboard storyboard = FindResource("ProgressAnimationOut") as Storyboard;

            storyboard.Begin();
            buttonConvert.IsEnabled     = true;
            buttonPreview.IsEnabled     = true;
            buttonOpenFile.IsEnabled    = true;
            buttonOpenStream.IsEnabled  = true;
            buttonPauseResume.IsEnabled = false;
            buttonCancel.IsEnabled      = false;
            checkBoxCrop.IsEnabled      = true;
            checkBoxCut.IsEnabled       = true;
            gridSourceMedia.IsEnabled   = true;
            buttonOpenOutput.Visibility = Visibility.Visible;
            Title = "AVC to HEVC Converter";

            MediaInfo outputFile = await MediaInfo.Open(currentOutputPath);

            textBlockDuration.Text   += $"   ⟶   {outputFile.Duration.ToString(@"hh\:mm\:ss\.ff")}";
            textBlockCodec.Text      += $"   ⟶   {outputFile.Codec} / {outputFile.AudioCodec}";
            textBlockFramerate.Text  += $"   ⟶   {outputFile.Framerate} fps";
            textBlockBitrate.Text    += $"   ⟶   {outputFile.Bitrate} Kbps";
            textBlockResolution.Text += $"   ⟶   {outputFile.Width + "x" + outputFile.Height}";
            textBlockInputSize.Text  += $"   ⟶   {outputSize}";
            if (!String.IsNullOrEmpty(outputFile.AspectRatio) && outputFile.AspectRatio != "N/A")
            {
                textBlockResolution.Text += $" ({outputFile.AspectRatio})";
            }
        }
Beispiel #5
0
        private async void ButtonOpen_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(textBoxURL.Text))
            {
                return;
            }

            buttonOpen.IsEnabled = false;
            if (buttonOpen.Content.ToString() == "Open URL")
            {
                string url = textBoxURL.Text;
                if (url.StartsWith("http"))
                {
                    if (!url.Contains("reddit") && !url.Contains("youtu") && !url.Contains("twitter"))
                    {
                        labelTitle.Content = "Opening network stream...";
                        MediaStream        = await MediaInfo.Open(url);

                        Close();
                    }
                    else
                    {
                        VideoUrlParser videoUrlParser = null;

                        if (url.Contains("reddit"))
                        {
                            host = "Reddit";
                            labelTitle.Content = "Fetching Reddit post info...";
                            videoUrlParser     = new RedditParser();
                        }
                        else if (url.Contains("youtu"))
                        {
                            host = "Youtube";
                            labelTitle.Content = "Fetching Youtube video info...";
                            videoUrlParser     = new YouTubeParser();
                        }
                        else if (url.Contains("twitter"))
                        {
                            host = "Twitter";
                            labelTitle.Content = "Fetching Twitter status info...";
                            videoUrlParser     = new TwitterParser();
                            comboBoxAudioQuality.Visibility  = Visibility.Hidden;
                            textBlockAudioQuality.Visibility = Visibility.Hidden;
                        }

                        foreach (var item in await videoUrlParser.GetVideoList(url))
                        {
                            if (!item.IsAudio)
                            {
                                comboBoxQuality.Items.Add(item);
                            }
                            else
                            {
                                comboBoxAudioQuality.Items.Add(item);
                            }
                            labelTitle.Content = item.Title;
                        }
                        comboBoxAudioQuality.Items.Add("[No Audio]");
                        comboBoxQuality.SelectedIndex      = 0;
                        comboBoxAudioQuality.SelectedIndex = 0;
                        buttonOpen.Content   = "Open selected quality";
                        buttonOpen.IsEnabled = true;
                        Storyboard storyboard = FindResource("ChoseQualityAnimation") as Storyboard;
                        storyboard.Begin();
                    }
                }
            }
            else
            {
                buttonOpen.IsEnabled = false;
                labelTitle.Content   = $"Loading {host} video...";
                StreamInfo selectedVideo = (StreamInfo)comboBoxQuality.SelectedItem;
                MediaStream = await MediaInfo.Open(selectedVideo.Url);

                if (comboBoxAudioQuality.SelectedItem.ToString() != "[No Audio]")
                {
                    StreamInfo selectedAudio = (StreamInfo)comboBoxAudioQuality.SelectedItem;
                    MediaStream.AudioSource = selectedAudio.Url;
                    MediaStream.AudioCodec  = selectedAudio.Codec;
                }
                MediaStream.Title = selectedVideo.Title;
                Close();
            }
        }
        private async void ButtonOpen_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(textBoxURL.Text))
            {
                return;
            }

            buttonOpen.IsEnabled = false;
            if (buttonOpen.Content.ToString() == "Open URL")
            {
                string url = textBoxURL.Text;
                if (url.StartsWith("http"))
                {
                    if (!url.Contains("reddit") && !url.Contains("youtu") && !url.Contains("twitter") && !url.Contains("facebook") && !url.Contains("instagram"))
                    {
                        labelTitle.Content = "Opening network stream...";
                        try
                        {
                            MediaStream = await MediaInfo.Open(url);
                        }
                        catch (Exception)
                        {
                            new MessageBoxWindow("Failed to open media from the url\n" + url, "Error opening url").ShowDialog();
                            MediaStream = null;
                        }
                        Close();
                    }
                    else
                    {
                        VideoUrlParser videoUrlParser = null;

                        if (url.Contains("reddit"))
                        {
                            host = "Reddit";
                            labelTitle.Content = "Fetching Reddit post info...";
                            videoUrlParser     = new RedditParser();
                        }
                        else if (url.Contains("youtu"))
                        {
                            host = "Youtube";
                            labelTitle.Content = "Fetching Youtube video info...";
                            videoUrlParser     = new YouTubeParser();
                        }
                        else if (url.Contains("twitter"))
                        {
                            host = "Twitter";
                            labelTitle.Content = "Fetching Twitter status info...";
                            videoUrlParser     = new TwitterParser();
                            comboBoxAudioQuality.Visibility  = Visibility.Hidden;
                            textBlockAudioQuality.Visibility = Visibility.Hidden;
                        }
                        else if (url.Contains("facebook"))
                        {
                            host = "Facebook";
                            labelTitle.Content = "Fetching Facebook post info...";
                            videoUrlParser     = new FacebookParser();
                            comboBoxAudioQuality.Visibility  = Visibility.Hidden;
                            textBlockAudioQuality.Visibility = Visibility.Hidden;
                        }
                        else if (url.Contains("instagram"))
                        {
                            host = "Instagram";
                            labelTitle.Content = "Fetching Instagram post info...";
                            videoUrlParser     = new InstagramParser();
                        }

                        try
                        {
                            foreach (var item in await videoUrlParser.GetVideoList(url))
                            {
                                if (!item.IsAudio)
                                {
                                    comboBoxQuality.Items.Add(item);
                                }
                                else
                                {
                                    comboBoxAudioQuality.Items.Add(item);
                                }
                                labelTitle.Content = item.Title;
                            }
                        }
                        catch (Exception)
                        {
                            new MessageBoxWindow("Failed to retreive media info from the url\n" + url, "Error parsing url").ShowDialog();
                            buttonOpen.IsEnabled = true;
                            return;
                        }

                        comboBoxQuality.SelectedIndex = 0;
                        if (comboBoxAudioQuality.Items.Count > 0)
                        {
                            comboBoxAudioQuality.SelectedIndex = 0;
                            comboBoxAudioQuality.Visibility    = Visibility.Visible;
                        }
                        else
                        {
                            comboBoxAudioQuality.Visibility = Visibility.Hidden;
                        }
                        buttonOpen.Content = "Open selected quality";
                        if (comboBoxQuality.Items.Count == 1 && comboBoxAudioQuality.Items.Count == 1) //Only one option -> automatically select that option
                        {
                            ButtonOpen_Click(null, null);
                        }
                        else
                        {
                            buttonOpen.IsEnabled = true;
                            Storyboard storyboard = FindResource("ChoseQualityAnimation") as Storyboard;
                            storyboard.Begin();
                        }
                    }
                }
                else
                {
                    new MessageBoxWindow("Enter a valid url", "FF Video Converter").ShowDialog();
                }
            }
            else
            {
                buttonOpen.IsEnabled = false;
                labelTitle.Content   = $"Loading {host} video...";
                StreamInfo selectedVideo = (StreamInfo)comboBoxQuality.SelectedItem;
                try
                {
                    if (comboBoxAudioQuality.Items.Count > 0)
                    {
                        StreamInfo selectedAudio = (StreamInfo)comboBoxAudioQuality.SelectedItem;
                        MediaStream = await MediaInfo.Open(selectedVideo.Url, selectedAudio.Url);

                        new MessageBoxWindow("The audio stream relative to this video is separate, therefore the integrated player will play the video without audio.\nWhen converting or downloading this video however, audio and video will be muxed toghether", "Info").ShowDialog();
                    }
                    else
                    {
                        MediaStream = await MediaInfo.Open(selectedVideo.Url);
                    }
                }
                catch (Exception ex)
                {
                    new MessageBoxWindow(ex.Message, "Error opening selected url").ShowDialog();
                    Close();
                    return;
                }
                MediaStream.Title = selectedVideo.Title;
                Close();
            }
        }
Beispiel #7
0
        private async void ButtonOpen_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(textBoxURL.Text))
            {
                return;
            }

            buttonOpen.IsEnabled = false;
            if (buttonOpen.Content.ToString() == "Open URL")
            {
                string url = textBoxURL.Text;
                if (url.StartsWith("http"))
                {
                    if (!url.Contains("reddit") && !url.Contains("youtu") && !url.Contains("twitter") && !url.Contains("facebook") && !url.Contains("instagram"))
                    {
                        titleBar.Text = "Opening network stream...";
                        try
                        {
                            MediaStream = await MediaInfo.Open(url);
                        }
                        catch (Exception)
                        {
                            new MessageBoxWindow("Failed to open media from the url\n" + url, "Error opening url").ShowDialog();
                            MediaStream = null;
                        }
                        Close();
                    }
                    else
                    {
                        VideoUrlParser videoUrlParser = null;

                        if (url.Contains("reddit"))
                        {
                            host           = "Reddit";
                            titleBar.Text  = "Fetching Reddit post info...";
                            videoUrlParser = new RedditParser();
                        }
                        else if (url.Contains("youtu"))
                        {
                            host           = "Youtube";
                            titleBar.Text  = "Fetching Youtube video info...";
                            videoUrlParser = new YouTubeParser();
                        }
                        else if (url.Contains("twitter"))
                        {
                            host           = "Twitter";
                            titleBar.Text  = "Fetching Twitter status info...";
                            videoUrlParser = new TwitterParser();
                            comboBoxAudioQuality.Visibility  = Visibility.Hidden;
                            textBlockAudioQuality.Visibility = Visibility.Hidden;
                        }
                        else if (url.Contains("facebook"))
                        {
                            host           = "Facebook";
                            titleBar.Text  = "Fetching Facebook post info...";
                            videoUrlParser = new FacebookParser();
                            comboBoxAudioQuality.Visibility  = Visibility.Hidden;
                            textBlockAudioQuality.Visibility = Visibility.Hidden;
                        }
                        else if (url.Contains("instagram"))
                        {
                            host           = "Instagram";
                            titleBar.Text  = "Fetching Instagram post info...";
                            videoUrlParser = new InstagramParser();
                        }

                        GetVideoList(videoUrlParser, url);
                    }
                }
                else
                {
                    new MessageBoxWindow("Enter a valid url", "FF Video Converter").ShowDialog();
                }
            }
            else
            {
                OpenVideo((StreamInfo)comboBoxQuality.SelectedItem);
            }
        }