Example #1
0
            public int Compare(object x, object y)
            {
                FFmpegHelper.EncodeObject eox = (x as ListViewItem).Tag as FFmpegHelper.EncodeObject;
                FFmpegHelper.EncodeObject eoy = (y as ListViewItem).Tag as FFmpegHelper.EncodeObject;

                int result = -1;

                switch (col)
                {
                case 2:     // bitrate
                    result = eox.MO.Bitrate.CompareTo(eoy.MO.Bitrate);
                    break;

                case 3:     // duration
                    if (eox.MO.Duration < eoy.MO.Duration)
                    {
                        result = -1;
                    }
                    else if (eox.MO.Duration == eoy.MO.Duration)
                    {
                        result = 0;
                    }
                    else
                    {
                        result = 1;
                    }
                    break;

                case 6:
                    result = eox.MO.FileInfo.Length.CompareTo(eoy.MO.FileInfo.Length);
                    break;

                case 7:
                    result = eox.NewSize.CompareTo(eoy.NewSize);
                    break;

                case 8:     // resolution
                    for (int i = 0; i < 2; i++)
                    {
                        int vx = int.Parse(eox.MO.Resolution.Split('x')[i]);
                        int vy = int.Parse(eoy.MO.Resolution.Split('x')[i]);
                        result = vx.CompareTo(vy);
                        if (result != 0)
                        {
                            break;
                        }
                    }
                    break;

                default:
                    result = String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
                    break;
                }

                if (reverse)
                {
                    result = result * -1;
                }
                return(result);
            }
Example #2
0
        void applyParameters(FFmpegHelper.EncodeObject eo, ListViewItem lvi)
        {
            int Scale;

            if (comboBoxScale.Text != "(none)" && int.TryParse(comboBoxScale.Text, out Scale))
            {
                eo.scale = Scale;
            }
            else
            {
                eo.scale = -1;
            }

            eo.suffix = textBoxSuffix.Text;
            eo.codec  = comboBoxCodec.Text;
            if (radioButtonCRF.Checked)
            {
                eo.CRF = (int)numericUpDownCRF.Value;
            }
            else if (radioButtonBitrate.Checked)
            {
                eo.AvgBitrate = (int)numericUpDownBitrate.Value;
            }
            eo.outdir  = textBoxOutdir.Text;
            eo.NewSize = 0;
            eo.Status  = FFmpegHelper.Status.New;

            lvi.SubItems[columnHeaderParameters.Index]  = new ListViewItem.ListViewSubItem(lvi, eo.Q.ToString());
            lvi.SubItems[columnHeaderStatus.Index].Text = Enum.GetName(typeof(FFmpegHelper.Status), eo.Status);
        }
Example #3
0
        private void EncodeNextVideo()
        {
            foreach (ListViewItem lvi in listViewFiles.Items)
            {
                FFmpegHelper.EncodeObject eo = null;
                eo = lvi.Tag as FFmpegHelper.EncodeObject;
                if (eo.Status != FFmpegHelper.Status.New)
                {
                    continue;
                }

                toolStripProgressBar1.Value = 0;
                Task.Factory.StartNew(() => ffmpegHelper.EncodeVideo(eo));
                return;
            }

            UpdateButtons(false);
        }
Example #4
0
        private async Task LoadFiles(string[] FileList)
        {
            // toolStripProgressBar1.Maximum += FileList.Length;
            foreach (string f in FileList)
            {
                // toolStripProgressBar1.Value++;
                toolStripStatusLabelConsole.Text = Path.GetFileName(f);
                var mo = await Task.Run(new Func <FFmpegHelper.MediaObject>(() => ffmpegHelper.GetMediaObject(f)));

                if (mo == null)
                {
                    continue;
                }
                if (mo.Video.StartsWith("hevc")) // FIXME
                {
                    continue;
                }

                FFmpegHelper.EncodeObject eo = new FFmpegHelper.EncodeObject();
                eo.MO = mo;
                ListViewItem lvi = new ListViewItem(Path.GetFileName(f));
                lvi.Tag = eo;
                for (int i = 0; i < listViewFiles.Columns.Count; i++)
                {
                    lvi.SubItems.Add("");
                }

                applyParameters(eo, lvi);

                lvi.SubItems[columnHeaderFolder.Index]     = new ListViewItem.ListViewSubItem(lvi, Path.GetDirectoryName(f));
                lvi.SubItems[columnHeaderBitrate.Index]    = new ListViewItem.ListViewSubItem(lvi, mo.Bitrate.ToString());
                lvi.SubItems[columnHeaderDuration.Index]   = new ListViewItem.ListViewSubItem(lvi, mo.Duration.ToString());
                lvi.SubItems[columnHeaderVideo.Index]      = new ListViewItem.ListViewSubItem(lvi, mo.Video);
                lvi.SubItems[columnHeaderAudio.Index]      = new ListViewItem.ListViewSubItem(lvi, mo.Audio);
                lvi.SubItems[columnHeaderSize.Index]       = new ListViewItem.ListViewSubItem(lvi, mo.FileInfo.Length.ToString("N0"));
                lvi.SubItems[columnHeaderResolution.Index] = new ListViewItem.ListViewSubItem(lvi, mo.Resolution);
                listViewFiles.Items.Add(lvi);
            }
        }