Exemplo n.º 1
0
        private void SetPreviewField(MediaFile.FrameField field)
        {
            if (field != null)
            {
                if (edgeMapToolStripMenuItem.Checked)
                {
                    var yFloatData = field.YData.GetFloatData();
                    var edgeData   = ImageProcessing.ImageProcessor.GenerateEdgeDetectedImage(yFloatData);
                    var edgeImage  = edgeData.ToBitmap();

                    pictureBoxPreview.Image = edgeImage;
                }
                else if (edgeMapStdDev5SecsToolStripMenuItem.Checked)
                {
                }
                else
                {
                    pictureBoxPreview.Image = field.Image;
                }
                //if (field.Image != null)
                //    field.Image.Save(@"D:\temp\image-" + field.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png);

                var    seconds   = TimeSpan.FromSeconds(field.Seconds);
                string frameType = "";

                if (field.AVFrame.pict_type != SharpFFmpeg.FFmpeg.AVPictureType.AV_PICTURE_TYPE_NONE)
                {
                    var pictType = field.AVFrame.pict_type.ToString();
                    frameType = "[" + pictType.Substring(pictType.LastIndexOf('_') + 1) + "] ";
                }

                labelCurrentPosition.Text        = "Current position: " + seconds.ToString(@"h\:mm\:ss\.fff") + "  " + frameType + field.FieldNumber.ToString();
                timelineUserControl1.FieldNumber = field.FieldNumber;
                graphsUserControl1.FieldNumber   = field.FieldNumber;

                _currentFieldIndex = field.FieldNumber;
            }
            else
            {
                pictureBoxPreview.Image   = null;
                labelCurrentPosition.Text = "";
            }

            UpdateButtons();
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            object updateFieldLock = new object();

            MediaFile.FrameField updateField = null;
            long updateFieldElapsed          = 0L;
            int  updateFieldCount            = 0;

            var updateTimer = new System.Windows.Forms.Timer();

            updateTimer.Interval = 20;
            updateTimer.Tick    += new EventHandler((sender2, e2) =>
            {
                MediaFile.FrameField field;
                double elapsed;
                int fieldNumber;
                lock (updateFieldLock)
                {
                    field       = updateField;
                    elapsed     = updateFieldElapsed;
                    fieldNumber = updateFieldCount;
                }
                if (field != null)
                {
                    //SetPreviewFrame(frame);
                    pictureBoxPreview.Image = field.Image;

                    if (elapsed > 0.0)
                    {
                        var fps = 1000.0 * fieldNumber / elapsed;
                        labelCurrentPosition.Text = fps.ToString("0.00");
                    }
                }
            });
            updateTimer.Start();

            RunOnBackgroundThread(() =>
            {
                var stopwatch = new System.Diagnostics.Stopwatch();
                stopwatch.Start();

                for (int i = 0; (i < _videoFile.TotalFields); i += 1)
                {
                    var field = _videoFile.GetVideoFrameField(i);

                    lock (updateFieldLock)
                    {
                        updateField        = field;
                        updateFieldElapsed = stopwatch.ElapsedMilliseconds;
                        updateFieldCount   = i + 1;
                    }

                    if (updateFieldElapsed > 5000)
                    {
                        break;
                    }
                }

                this.Invoke(new Action(() =>
                {
                    updateTimer.Stop();
                    updateTimer.Dispose();
                }));
            });
        }