Beispiel #1
0
        private void thread_DoWork(CancellationToken token)
        {
            MFFrame[] arrFrames = new MFFrame[COUNT];
            while (!token.IsCancellationRequested)
            {
                M_AV_PROPS props = new M_AV_PROPS();
                props.vidProps.eInterlace = eMInterlace.eMI_Progressive;

                for (int i = 0; i < COUNT; i++)
                {
                    lock (m_objLock)
                    {
                        if (m_arrLives[i] != null && m_arrLiveState[i])
                        {
                            // Get next frame
                            try
                            {
                                m_arrLives[i].SourceFrameConvertedGetByTime(ref props, -1, -1,
                                                                            out arrFrames[i], " scaling_quality=2 async_id=ch" + i.ToString());
                                m_arrPreviews[i].ReceiverFramePut(arrFrames[i], -1, "");
                                if (m_arrWritersState[i])
                                {
                                    m_arrWriters[i].ReceiverFramePut(arrFrames[i], -1, "");
                                }

                                Marshal.FinalReleaseComObject(arrFrames[i]);
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void thread_DoWork(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                if (decode)
                {
                    MFFrame frame = null;

                    M_AV_PROPS properties = new M_AV_PROPS {
                        vidProps = new M_VID_PROPS {
                            eVideoFormat = eMVideoFormat.eMVF_Custom, nWidth = 800, nHeight = 600, fccType = eMFCC.eMFCC_ARGB32
                        }
                    };
                    //M_AV_PROPS properties = new M_AV_PROPS { vidProps = new M_VID_PROPS { eVideoFormat = eMVideoFormat.eMVF_HD720_50p, fccType = eMFCC.eMFCC_ARGB32 } };
                    m_objReader.SourceFrameConvertedGet(ref properties, -1, out frame, "");

                    frame.MFVideoGetBytes(out var size, out var buffer);
                    Console.Out.WriteLine($"Frame size: {size}");

                    frame.MFAVPropsGet(out var frameProperties, out var sampleCount);
                    Console.Out.WriteLine($"Expected: {properties.vidProps.nWidth}, {properties.vidProps.nHeight}, {properties.vidProps.fccType}");
                    Console.Out.WriteLine($"Found: {frameProperties.vidProps.nWidth}, {frameProperties.vidProps.nHeight}, {frameProperties.vidProps.fccType}");

                    m_objPreview.ReceiverFramePut(frame, -1, "");

                    Marshal.FinalReleaseComObject(frame);
                }
            }
        }
Beispiel #3
0
        private IntPtr GetHBitmapCore(double position)
        {
            MFrame mFrame = null;

            _mfileObj.FileFrameGet(position, 0.0, out mFrame);
            M_AV_PROPS m_AV_PROPS = default(M_AV_PROPS);

            mFrame.FrameAVPropsGet(out m_AV_PROPS);

            m_AV_PROPS.vidProps.nWidth    = m_AV_PROPS.vidProps.nWidth / 5;
            m_AV_PROPS.vidProps.nHeight   = m_AV_PROPS.vidProps.nHeight / 5;
            m_AV_PROPS.vidProps.nRowBytes = m_AV_PROPS.vidProps.nRowBytes / 5;
            MFrame mFrame2 = null;

            mFrame.FrameConvert(ref m_AV_PROPS.vidProps, out mFrame2, string.Empty);
            long value = 0L;

            mFrame2.FrameVideoGetHbitmap(out value);

            Marshal.ReleaseComObject(mFrame);
            Marshal.ReleaseComObject(mFrame2);
            mFrame2 = null;
            mFrame  = null;

            return(new System.IntPtr(value));
        }
Beispiel #4
0
        private void thread_DoWork(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                if (encode)
                {
                    MFFrame frame = null;

                    M_AV_PROPS props = new M_AV_PROPS();
                    props.vidProps.eVideoFormat = eMVideoFormat.eMVF_HD1080_25p;

                    //m_objReader.IMFSource_SourceFrameGet(-1, out frame, "");
                    m_objReader.SourceFrameConvertedGet(ref props, -1, out frame, "");

                    if (cg)
                    {
                        ShowPluggin(m_objCharGen, ref frame);
                    }

                    m_objWriter.ReceiverFramePut(frame, -1, "");

                    m_objPreview.ReceiverFramePut(frame, -1, "");

                    Marshal.FinalReleaseComObject(frame);
                }
            }
        }
        private void mImageBoxPreview_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_pKey != null && e.Button == MouseButtons.Left)
            {
                M_AV_PROPS props = new M_AV_PROPS();
                m_pFrame.FrameAVPropsGet(out props);
                int nOrigPictureWidth  = props.vidProps.nWidth;
                int nOrigPictureHeigth = Math.Abs(props.vidProps.nHeight);

                int nScaledImageX = e.X + mImageBoxPreview.HorizontalScroll.Value;
                int nScaledImageY = e.Y + mImageBoxPreview.VerticalScroll.Value;

                double dblScaleFactor = (double)nOrigPictureWidth / (double)mImageBoxPreview.ScaledImageWidth;

                int nOriginalImageX = (int)(nScaledImageX * dblScaleFactor);
                int nOriginalImageY = (int)(nScaledImageY * dblScaleFactor);

                object pFrame;
                string strConfig = "type='" + comboBoxDetectType.Text + "' max_keys='" + numericKeys.Value.ToString() + "'";

                if (checkBoxExcludePts.Checked)
                {
                    m_pKey.KeyExcludePoint(nOriginalImageX, nOriginalImageY, strConfig, out pFrame);
                }
                else
                {
                    m_pKey.KeyAddPoint(nOriginalImageX, nOriginalImageY, strConfig, out pFrame);
                }

                UpdatePicture(pFrame);
            }
        }
Beispiel #6
0
        private void FillVideoFormats()
        {
            comboBoxVideoFormat.Items.Clear();

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_Custom);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_NTSC);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_NTSC_2398);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_NTSC_16x9);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_PAL);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_PAL_16x9);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD720_50p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD720_5994p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD720_60p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_2398p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_24p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_25p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_2997p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_30p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_50i);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_5994i);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_60i);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_50p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_5994p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_HD1080_60p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_2398p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_24p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_25p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_50p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_5994p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_DCI_60p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_2398p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_24p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_2K_25p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_DCI_2398p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_DCI_24p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_DCI_25p);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_50i);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_5994i);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_60i);

            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_50p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_5994p);
            comboBoxVideoFormat.Items.Add(eMVideoFormat.eMVF_4K_UHD_60p);
            comboBoxVideoFormat.SelectedIndex = 0;

            m_avProps = new M_AV_PROPS();
            m_avProps.vidProps.eVideoFormat = (eMVideoFormat)comboBoxVideoFormat.SelectedItem;
        }
Beispiel #7
0
        private void thread_DoWork(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                if (encode || live)
                {
                    MFFrame    frameLive = null;
                    MFFrame    frameFile = null;
                    M_AV_PROPS props     = new M_AV_PROPS();
                    if (live)
                    {
                        M_VID_PROPS vidProps = new M_VID_PROPS();
                        vidProps.eVideoFormat = eMVideoFormat.eMVF_HD1080_5994i;
                        m_objLive.FormatVideoSet(eMFormatType.eMFT_Input, ref vidProps);
                        props.vidProps.eVideoFormat = eMVideoFormat.eMVF_Custom;
                        m_objLive.SourceFrameConvertedGet(ref props, -1, out frameLive, "");
                    }
                    if (encode)
                    {
                        props.vidProps.eVideoFormat = eMVideoFormat.eMVF_HD1080_5994i;

                        m_objReader.SourceFrameConvertedGet(ref props, -1, out frameFile, "");
                        if (frameLive != null)
                        {
                            frameLive.MFOverlay(frameFile, null, 0, 0, 0, "audio_gain=0", "ch1");
                        }
                    }

                    if (frameLive != null)
                    {
                        m_objPreview.ReceiverFramePut(frameLive, -1, "");
                    }
                    else
                    {
                        m_objPreview.ReceiverFramePut(frameFile, -1, "");
                    }

                    if (frameLive != null)
                    {
                        Marshal.FinalReleaseComObject(frameLive);
                    }
                    if (frameFile != null)
                    {
                        Marshal.FinalReleaseComObject(frameFile);
                    }
                }
            }
        }
Beispiel #8
0
        private void thread_DoWork(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                if (encode)
                {
                    MFFrame frame = null;

                    M_AV_PROPS props = new M_AV_PROPS();
                    props.vidProps.eVideoFormat = eMVideoFormat.eMVF_Disabled;

                    m_objReader.SourceFrameConvertedGet(ref props, -1, out frame, "");

                    m_objPreview.ReceiverFramePut(frame, -1, "");

                    Marshal.FinalReleaseComObject(frame);
                }
            }
        }
Beispiel #9
0
        private void thread_DoWork(CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                MFFrame frame1 = null;
                MFFrame frame2 = null;
                MFFrame frame3 = null;
                MFFrame frame4 = null;
                MFFrame frame5 = null;

                M_AV_PROPS props = new M_AV_PROPS();

                props.vidProps.eInterlace = eMInterlace.eMI_Progressive;
                if (start1)
                {
                    m_objReader1.SourceFrameConvertedGet(ref props, -1, out frame1, "");
                    m_objWriter1.ReceiverFramePut(frame1, -1, "");
                    m_objPreview1.ReceiverFramePut(frame1, -1, "");
                }
                if (start2)
                {
                    m_objReader2.SourceFrameConvertedGet(ref props, -1, out frame2, "");
                    m_objWriter2.ReceiverFramePut(frame2, -1, "");
                    m_objPreview2.ReceiverFramePut(frame2, -1, "");
                }
                if (start3)
                {
                    m_objReader3.SourceFrameConvertedGet(ref props, -1, out frame3, "");
                    m_objWriter3.ReceiverFramePut(frame3, -1, "");
                    m_objPreview3.ReceiverFramePut(frame3, -1, "");
                }
                if (start4)
                {
                    m_objReader4.SourceFrameConvertedGet(ref props, -1, out frame4, "");
                    m_objWriter4.ReceiverFramePut(frame4, -1, "");
                    m_objPreview4.ReceiverFramePut(frame4, -1, "");
                }
                if (start5)
                {
                    m_objReader5.SourceFrameConvertedGet(ref props, -1, out frame5, "");
                    m_objWriter5.ReceiverFramePut(frame5, -1, "");
                    m_objPreview5.ReceiverFramePut(frame5, -1, "");
                }

                if (frame1 != null)
                {
                    Marshal.ReleaseComObject(frame1);
                }
                if (frame2 != null)
                {
                    Marshal.ReleaseComObject(frame2);
                }
                if (frame3 != null)
                {
                    Marshal.ReleaseComObject(frame3);
                }
                if (frame4 != null)
                {
                    Marshal.ReleaseComObject(frame4);
                }
                if (frame5 != null)
                {
                    Marshal.ReleaseComObject(frame5);
                }
            }
        }
Beispiel #10
0
        private void thread_DoWork(CancellationToken token)
        {
            MFFactoryClass _factory = new MFFactoryClass();

            while (!token.IsCancellationRequested)
            {
                if (decode)
                {
                    MFFrame frame = null;

                    string path = String.Format(@"\\MLDiskStation\MLFiles\Trash\Roman\NetTestFiles\LG_jazz\LG_jazz\LG_jazz{0:d7}.jpg", index);

                    Debug.WriteLine("Picture:" + index.ToString());
                    index = ++index == 291 ? 0 : index; //291 is count of pictures in image sequences

                    {
                        Bitmap bmp = (Bitmap)System.Drawing.Image.FromFile(path);

                        Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
                        System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb);

                        M_AV_PROPS avProps = new M_AV_PROPS();
                        avProps.vidProps.eVideoFormat = eMVideoFormat.eMVF_HD1080_30p;
                        avProps.vidProps.fccType      = eMFCC.eMFCC_RGB32;
                        avProps.vidProps.nWidth       = bmp.Width;
                        avProps.vidProps.nHeight      = -1 * bmp.Height; // Negative height for top-bottom RGB images (if positive->bottom-top)
                        avProps.vidProps.nRowBytes    = bmpData.Stride;  // distance between lines

                        _factory.MFFrameCreateFromMem(ref avProps, bmpData.Scan0.ToInt64(), 0, 0, out frame, "");

                        bmp.UnlockBits(bmpData);

                        bmp.Dispose();
                    }

                    M_AV_PROPS props;
                    int        samples;
                    frame.MFAVPropsGet(out props, out samples);
                    props.vidProps.eVideoFormat = eMVideoFormat.eMVF_HD1080_30p;
                    props.vidProps.dblRate      = 30.0;
                    props.vidProps.nAspectX     = 16;
                    props.vidProps.nAspectY     = 9;

                    MFFrame frameConvert;
                    int     nRest = 0;
                    frame.MFConvert(ref props, out frameConvert, out nRest, "", "");

                    m_objPreview.ReceiverFramePut(frameConvert, 0, "");
                    m_objWriter.ReceiverFramePut(frameConvert, -1, "");
                    if (stopWr)
                    {
                        m_objWriter.WriterClose(0);
                    }

                    Marshal.ReleaseComObject(frameConvert);
                    Marshal.ReleaseComObject(frame);

                    GC.Collect();
                }
            }
        }