예제 #1
0
    public MainWindow(string configurationPath) : base(Gtk.WindowType.Toplevel)
    {
        // Loading configuration
        MediaConvertGUIConfiguration.Load(configurationPath);

        Build();

        // iapp icon
        var sep    = System.IO.Path.DirectorySeparatorChar;
        var buffer = System.IO.File.ReadAllBytes(System.IO.Path.Combine(SupportMethods.AppPath + sep + "Icons" + sep + "ico.ico"));

        var pixbuf = new Gdk.Pixbuf(buffer);

        Icon = pixbuf;


        TestPrerequisites();

        _fileTreeViewData = new TreeViewData(tree);
        CreateGridColumns();
        widgetTargetMovieTrack.Editable = true;
        widgetTargetContainer.Editable  = true;
        widgetSourceContainer.Editable  = false;

        _proressWindow = new ProgressWin();
        _proressWindow.Hide();

        tree.Selection.Mode = SelectionMode.Multiple;

        tree.CursorChanged += OnTreeCursorChanged;

        tree.ButtonPressEvent += OnTreeButtonPressEvent;

        FillTree();
    }
예제 #2
0
    public void AddMediaInfo(string fName)
    {
        var sourceMovie = new MediaInfo();

        if (sourceMovie.OpenFromFile(fName))
        {
            var firstVideoTrack = sourceMovie.FirstVideoTrack;

            if (sourceMovie.AudioTracks.Count > 0 || firstVideoTrack != null)
            {
                var targetMovie = new MediaInfo();
                sourceMovie.Copyto(targetMovie, false);

                if (firstVideoTrack != null)
                {
                    targetMovie.TargetContainer  = MediaConvertGUIConfiguration.DefaultContainer;
                    targetMovie.TargetVideoCodec = MediaConvertGUIConfiguration.GetVideoCodecByName("copy");
                }

                // leaving only first audio track
                while (targetMovie.AudioTracks.Count > 1)
                {
                    TrackInfo lastAudioTrack = null;
                    foreach (var track in targetMovie.Tracks)
                    {
                        if (track.TrackType == "Audio")
                        {
                            lastAudioTrack = track;
                        }
                    }
                    if (targetMovie.Tracks.Contains(lastAudioTrack))
                    {
                        targetMovie.Tracks.Remove(lastAudioTrack);
                    }
                    else
                    {
                        break;
                    }
                }

                if (targetMovie.AudioTracks.Count > 0)
                {
                    if (firstVideoTrack != null)
                    {
                        targetMovie.FirstAudioTrack.TargetAudioCodec = MediaConvertGUIConfiguration.GetAudioCodecByName("copy");
                    }
                    else
                    {
                        targetMovie.FirstAudioTrack.TargetAudioCodec = MediaConvertGUIConfiguration.GetAudioCodecByName("mp3");
                    }
                }

                MoviesInfo.Add(sourceMovie, targetMovie);

                FillTree();
            }
        }
    }
예제 #3
0
    private void ThreadMethod()
    {
        _currentFileListCount  = MoviesInfo.Count;
        _currentFileListNumber = -1;

        foreach (var kvp in MoviesInfo)
        {
            if (kvp.Value == null)
            {
                break;
            }

            _currentConvertingMovie = kvp.Value;
            var info = _currentConvertingMovie.FirstVideoTrack;

            _currentFileListNumber++;

            _currentPass = 1;

            if (_processAbortRequest)
            {
                break;
            }

            var cmd1 = MediaInfoBase.MakeFFMpegCommand(kvp.Key, kvp.Value, 1);
            ExecutFFMpegCommand(cmd1, kvp.Value.FFMPEGOutputFileName);

            if (info != null &&
                _currentConvertingMovie.TargetVideoCodec != MediaConvertGUIConfiguration.GetVideoCodecByName("none"))
            {
                // converting 2 pass video
                var cmd2 = MediaInfoBase.MakeFFMpegCommand(kvp.Key, kvp.Value, 2);

                if (_processAbortRequest)
                {
                    break;
                }

                _currentPass = 2;

                if (!String.IsNullOrEmpty(cmd2))
                {
                    ExecutFFMpegCommand(cmd2, kvp.Value.FFMPEGOutputFileName);
                }
            }
        }

        Application.Invoke((_, __) =>
        {
            applyAction.Sensitive           = true;
            widgetTargetMovieTrack.Editable = true;
            widgetTargetContainer.Editable  = true;
            widgetSourceContainer.Editable  = true;
            _processthread.Join();
            _processthread = null;
        });
    }