示例#1
0
文件: Video.cs 项目: ratsil/bethe.btl
            public PixelsMap FrameNextVideo()
            {
                cTimings.TotalRenew();
                try
                {
                    _cPixelsMap = _cPMDuo.cCurrent;
                    _cPixelsMap.Move(stPixelArea.nLeft, stPixelArea.nTop);                      // были проблемы в транзишене. т.к. PM многоразовый, то кто-то его мог мувнуть (плейлист) и на место не класть.
                    ffmpeg.net.Frame cFrame = _cFile.FrameNextVideoGet();                       //_cFormatVideo,
                    cTimings.Restart("ffmpeg_framenext");
                    if (null != cFrame)
                    {
                        int nOffset    = 0;
                        int nOffsetBot = 0;
                        int nLine      = _cFormatVideo.nWidth * _cFormatVideo.nBitsPerPixel / 8;
                        int nBotDiff   = _cFormatVideo.nHeight - (stContainerArea.nHeight - stArea.nTop);
                        if (720 == _cFormatVideo.nWidth && 576 == _cFormatVideo.nHeight)                          // инверсия полей нужна только на sd
                        {
                            nOffset = nLine;
                        }

                        if (stArea.nTop < 0)
                        {
                            nOffset += (-stArea.nTop) * nLine;
                        }
                        if (nBotDiff > 0)
                        {
                            nOffsetBot = nBotDiff * nLine;
                        }

                        _cPixelsMap.CopyIn(cFrame.pBytes + nOffset, cFrame.nLength - nOffset - nOffsetBot);                          // сдвигаем фрейм на строчку вверх (это если не HD, а PAL)
                        cTimings.Restart("copy_in");
                        cFrame.Dispose();
                        cTimings.Restart("dispose");
                        //GC.Collect(1, GCCollectionMode.Force_d);  // худший вариант был
                        //GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized);  // этот лучший был  ------- уехало в байтилус  -------
                        //GC.Collect(GC.MaxGeneration, GCCollectionMode.Force_d);   // гипотеза (ТАК и оказалось!!!!) - т.к. сборка спонтанная высвобождает сразу много мусора и и лочит этим copyin и вышибает пробки у БлэкМэджика
                        //cTimings.Restart("GCcollect. " + System.Runtime.GCSettings.LatencyMode + ".");
                        nFrameCurrentVideo++;
                    }
                    else if (bEOF)
                    {
                        return(null);
                    }
                    cTimings.Stop("framenext", "eof_getting", 20);
                    ffmpeg.net.File.Input.nBTLCurrentBuffer = Baetylus.nCurrentDeviceBufferCount;
                    return(_cPixelsMap);
                }
                catch (Exception ex)
                {
                    (new Logger()).WriteError(ex);
                    _cFile.Close();
                }
                return(null);
            }
示例#2
0
文件: Video.cs 项目: ratsil/bethe.btl
 public void SkipAudio()
 {
     try
     {
         ffmpeg.net.Frame cFrame = _cFile.FrameNextAudioGet();                      //_cFormatVideo,
         if (null != cFrame)
         {
             cFrame.Dispose();
             nFrameCurrentAudio++;
         }
     }
     catch (Exception ex)
     {
         (new Logger()).WriteError(ex);
     }
 }
示例#3
0
            public Bytes FrameNext()
            {
                Bytes aRetVal = null;

                ffmpeg.net.Frame cFrame = _cFile.FrameNextAudioGet();
                if (null != cFrame)
                {
                    (new Logger()).WriteDebug2("btl.audio getting bytes (from=2) [len=" + cFrame.nLength + "][bufferlen=" + cFrame.nLengthBuffer + "]");
                    aRetVal = Baetylus._cBinM.BytesGet(cFrame.nLength, 2);
                    cFrame.CopyBytesTo(aRetVal.aBytes);
                    cFrame.Dispose();
                }
                if (null != aRetVal && 0 < aRetVal.Length)
                {
                    nFrameCurrent++;
                }
                if (bEOF && null == cFrame)
                {
                    return(null);
                }
                return(aRetVal);
            }
示例#4
0
文件: Video.cs 项目: ratsil/bethe.btl
            public Bytes FrameNextAudio()
            {
                Bytes aRetVal = null;

                try
                {
                    ffmpeg.net.Frame cFrame = _cFile.FrameNextAudioGet();                      //_cFormatAudio
                    if (null != cFrame)
                    {
                        aRetVal = Baetylus._cBinM.BytesGet(cFrame.nLength, 4);
                        cFrame.CopyBytesTo(aRetVal.aBytes);
                        cFrame.Dispose();
                    }
                    if (null != aRetVal && 0 < aRetVal.Length)
                    {
                        nFrameCurrentAudio++;
                    }
                }
                catch (Exception ex)
                {
                    (new Logger()).WriteError(ex);
                }
                return(aRetVal);
            }