当前位置: 首页>>代码示例>>C#>>正文


C# AviWriter类代码示例

本文整理汇总了C#中AviWriter的典型用法代码示例。如果您正苦于以下问题:C# AviWriter类的具体用法?C# AviWriter怎么用?C# AviWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AviWriter类属于命名空间,在下文中一共展示了AviWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartRecordingThread

        private void StartRecordingThread(string videoFileName, ISeleniumTest scenario, int fps)
        {
            fileName = videoFileName;

            using (writer = new AviWriter(videoFileName)
            {
                FramesPerSecond = fps,
                EmitIndex1 = true
            })
            {
                stream = writer.AddVideoStream();
                this.ConfigureStream(stream);

                while (!scenario.IsFinished || forceStop)
                {
                    GetScreenshot(buffer);

                    //Thread safety issues
                    lock (locker)
                    {
                        stream.WriteFrame(true, buffer, 0, buffer.Length);
                    }

                }
            }

        }
开发者ID:JevgenijsSaveljevs,项目名称:SeleniumMag,代码行数:27,代码来源:VideoRecorder.cs

示例2: Main

        static void Main(string[] args)
        {
            var endOfRec = DateTime.Now.Add(TimeSpan.FromSeconds(30));
            using (var writer = new AviWriter("test.avi")
            {
                FramesPerSecond = 15,
                EmitIndex1 = true
            })
            {
                var stream = writer.AddVideoStream();

                stream.Width = Screen.PrimaryScreen.WorkingArea.Width;
                stream.Height = Screen.PrimaryScreen.WorkingArea.Height;
                stream.Codec = KnownFourCCs.Codecs.Uncompressed;
                stream.BitsPerPixel = BitsPerPixel.Bpp32;

                var googleChrome = new TestCase();

                Task.Factory.StartNew(() =>
                {
                    googleChrome.Scenario("http://www.google.com", "что посмотреть сегодня?");
                });

                var buffer = new byte[Screen.PrimaryScreen.WorkingArea.Width * Screen.PrimaryScreen.WorkingArea.Height * 4];
                while (!TestCase.isFinished)
                {
                    GetScreenshot(buffer);
                    stream.WriteFrame(true, buffer, 0, buffer.Length);
                }
            }

            Console.WriteLine("Execution Done");
        }
开发者ID:JevgenijsSaveljevs,项目名称:SeleniumMag,代码行数:33,代码来源:Program.cs

示例3: ImageProvider

        private ImageProvider m_imageProvider = new ImageProvider(); /* Create one image provider. */

        #endregion Fields

        #region Constructors

        /* Set up the controls and events to be used and update the device list. */
        public MainForm()
        {
            InitializeComponent();

            /* Register for the events of the image provider needed for proper operation. */
            m_imageProvider.GrabErrorEvent += new ImageProvider.GrabErrorEventHandler(OnGrabErrorEventCallback);
            m_imageProvider.DeviceRemovedEvent += new ImageProvider.DeviceRemovedEventHandler(OnDeviceRemovedEventCallback);
            m_imageProvider.DeviceOpenedEvent += new ImageProvider.DeviceOpenedEventHandler(OnDeviceOpenedEventCallback);
            m_imageProvider.DeviceClosedEvent += new ImageProvider.DeviceClosedEventHandler(OnDeviceClosedEventCallback);
            m_imageProvider.GrabbingStartedEvent += new ImageProvider.GrabbingStartedEventHandler(OnGrabbingStartedEventCallback);
            m_imageProvider.ImageReadyEvent += new ImageProvider.ImageReadyEventHandler(OnImageReadyEventCallback);
            m_imageProvider.GrabbingStoppedEvent += new ImageProvider.GrabbingStoppedEventHandler(OnGrabbingStoppedEventCallback);

            /* Provide the controls in the lower left area with the image provider object. */
            sliderGain.MyImageProvider = m_imageProvider;
            sliderExposureTime.MyImageProvider = m_imageProvider;
            sliderHeight.MyImageProvider = m_imageProvider;
            sliderWidth.MyImageProvider = m_imageProvider;
            comboBoxPixelFormat.MyImageProvider = m_imageProvider;

            /* Update the list of available devices in the upper left area. */
            UpdateDeviceList();

            /* Enable the tool strip buttons according to the state of the image provider. */
            EnableButtons(m_imageProvider.IsOpen, false);
             //   hDev = Pylon.CreateDeviceByIndex(0);
            aw = new AviWriter();
        }
开发者ID:artemisvision,项目名称:PylonVideoCapture,代码行数:35,代码来源:MainForm.cs

示例4: Recorder

        public Recorder(RecorderParams Params)
        {
            this.Params = Params;

            if (Params.CaptureVideo)
            {
                // Create AVI writer and specify FPS
                writer = Params.CreateAviWriter();

                // Create video stream
                videoStream = Params.CreateVideoStream(writer);
                // Set only name. Other properties were when creating stream,
                // either explicitly by arguments or implicitly by the encoder used
                videoStream.Name = "Captura";
            }

            try
            {
                int AudioSourceId = int.Parse(Params.AudioSourceId);

                if (AudioSourceId != -1)
                {
                    if (Params.CaptureVideo)
                    {
                        audioStream = Params.CreateAudioStream(writer);
                        audioStream.Name = "Voice";
                    }

                    audioSource = new WaveInEvent
                    {
                        DeviceNumber = AudioSourceId,
                        WaveFormat = Params.WaveFormat,
                        // Buffer size to store duration of 1 frame
                        BufferMilliseconds = (int)Math.Ceiling(1000 / writer.FramesPerSecond),
                        NumberOfBuffers = 3,
                    };
                }
            }
            catch
            {
                var dev = Params.LoopbackDevice;

                SilencePlayer = new WasapiOut(dev, AudioClientShareMode.Shared, false, 100);

                SilencePlayer.Init(new SilenceProvider(Params.WaveFormat));

                SilencePlayer.Play();

                if (Params.CaptureVideo)
                {
                    audioStream = Params.CreateAudioStream(writer);
                    audioStream.Name = "Loopback";
                }

                audioSource = new WasapiLoopbackCapture(dev) { ShareMode = AudioClientShareMode.Shared };
            }

            if (Params.CaptureVideo)
            {
                screenThread = new Thread(RecordScreen)
                {
                    Name = typeof(Recorder).Name + ".RecordScreen",
                    IsBackground = true
                };
            }
            else WaveWriter = Params.CreateWaveWriter();

            if (Params.CaptureVideo) screenThread.Start();

            if (audioSource != null)
            {
                audioSource.DataAvailable += AudioDataAvailable;

                if (Params.CaptureVideo)
                {
                    videoFrameWritten.Set();
                    audioBlockWritten.Reset();
                }

                audioSource.StartRecording();
            }
        }
开发者ID:gitter-badger,项目名称:Captura,代码行数:82,代码来源:Recorder.cs

示例5: Recorder

        public Recorder(string fileName, 
            FourCC codec, int quality, 
            int audioSourceIndex, SupportedWaveFormat audioWaveFormat, bool encodeAudio, int audioBitRate)
        {
            System.Windows.Media.Matrix toDevice;
            using (var source = new HwndSource(new HwndSourceParameters()))
            {
                toDevice = source.CompositionTarget.TransformToDevice;
            }

            screenWidth = (int)Math.Round(SystemParameters.PrimaryScreenWidth * toDevice.M11);
            screenHeight = (int)Math.Round(SystemParameters.PrimaryScreenHeight * toDevice.M22);

            // Create AVI writer and specify FPS
            writer = new AviWriter(fileName)
            {
                FramesPerSecond = 10,
                EmitIndex1 = true,
            };

            // Create video stream
            videoStream = CreateVideoStream(codec, quality);
            // Set only name. Other properties were when creating stream,
            // either explicitly by arguments or implicitly by the encoder used
            videoStream.Name = "Screencast";

            if (audioSourceIndex >= 0)
            {
                var waveFormat = ToWaveFormat(audioWaveFormat);

                audioStream = CreateAudioStream(waveFormat, encodeAudio, audioBitRate);
                // Set only name. Other properties were when creating stream,
                // either explicitly by arguments or implicitly by the encoder used
                audioStream.Name = "Voice";

                audioSource = new WaveInEvent
                {
                    DeviceNumber = audioSourceIndex,
                    WaveFormat = waveFormat,
                    // Buffer size to store duration of 1 frame
                    BufferMilliseconds = (int)Math.Ceiling(1000 / writer.FramesPerSecond),
                    NumberOfBuffers = 3,
                };
                audioSource.DataAvailable += audioSource_DataAvailable;
            }

            screenThread = new Thread(RecordScreen)
            {
                Name = typeof(Recorder).Name + ".RecordScreen",
                IsBackground = true
            };

            if (audioSource != null)
            {
                videoFrameWritten.Set();
                audioBlockWritten.Reset();
                audioSource.StartRecording();
            }
            screenThread.Start();
        }
开发者ID:bobahml,项目名称:SharpAvi,代码行数:60,代码来源:Recorder.cs

示例6: CreateVideo

        public static void CreateVideo(List<Frame> frames, string outputFile)
        {
            var writer = new AviWriter(outputFile)
            {
                FramesPerSecond = 30,
                // Emitting AVI v1 index in addition to OpenDML index (AVI v2)
                // improves compatibility with some software, including
                // standard Windows programs like Media Player and File Explorer
                EmitIndex1 = true
            };

            // returns IAviVideoStream
            var stream = writer.AddVideoStream();

            // set standard VGA resolution
            stream.Width = 640;
            stream.Height = 480;

            // class SharpAvi.KnownFourCCs.Codecs contains FOURCCs for several well-known codecs
            // Uncompressed is the default value, just set it for clarity
            stream.Codec = KnownFourCCs.Codecs.Uncompressed;

            // Uncompressed format requires to also specify bits per pixel
            stream.BitsPerPixel = BitsPerPixel.Bpp32;

            var frameData = new byte[stream.Width * stream.Height * 4];

            foreach (var item in frames)
            {

                // Say, you have a System.Drawing.Bitmap
                Bitmap bitmap = (Bitmap)item.Image;

                // and buffer of appropriate size for storing its bits
                var buffer = new byte[stream.Width * stream.Height * 4];

                var pixelFormat = PixelFormat.Format32bppRgb;

                // Now copy bits from bitmap to buffer
                var bits = bitmap.LockBits(new Rectangle(0, 0, stream.Width, stream.Height), ImageLockMode.ReadOnly, pixelFormat);

                //Marshal.Copy(bits.Scan0, buffer, 0, buffer.Length);

                Marshal.Copy(bits.Scan0, buffer, 0, buffer.Length);

                bitmap.UnlockBits(bits);

                // and flush buffer to encoding stream
                stream.WriteFrame(true, buffer, 0, buffer.Length);

            }

            writer.Close();
        }
开发者ID:JollySwagman,项目名称:Super8,代码行数:54,代码来源:Video.cs

示例7: Main

        private static void Main(string[] args)
        {
            var firstFrame = CaptureScreen(null);

            var aviWriter = new AviWriter();
            var bitmap = aviWriter.Open("test.avi", 10, firstFrame.Width, firstFrame.Height);
            for (var i = 0; i < 25*5; i++)
            {
                CaptureScreen(bitmap);
                aviWriter.AddFrame();
            }

            aviWriter.Close();
        }
开发者ID:duszekmestre,项目名称:MoN.Messenger,代码行数:14,代码来源:Program.cs

示例8: StartRecord

        /// <summary>
        /// Records this instance.
        /// </summary>
        /// <exception cref="RedCell.Research.ResearchException">
        /// Filename must be set before recording.
        /// or
        /// A recording has already started.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">Filename must be set before recording.</exception>
        public void StartRecord()
        {
            // Automatic filename
            if (string.IsNullOrWhiteSpace(Filename))
                Filename = "Video_" + DateTime.Now.ToString("yyyyMMddHHmmss");

            if(_writer != null)
                throw new ResearchException("A recording has already started.");

            // Get video details from camera.
            if (StreamSetting == null)
                StreamSetting = Camera.StreamSetting;

            var encoder = new Mpeg4VideoEncoderVcm(StreamSetting.Width, StreamSetting.Height, StreamSetting.Framerate, 0, 50, KnownFourCCs.Codecs.X264);
            _writer = new AviWriter(Filename);
            _video = _writer.AddEncodingVideoStream(encoder, true, StreamSetting.Width, StreamSetting.Height);
            

            Camera.FrameAvailable += Camera_FrameAvailable;
        }
开发者ID:modulexcite,项目名称:FRESHER,代码行数:29,代码来源:AVLog.cs

示例9: StopCapture

        /// <summary>
        /// 画面キャプチャ(音声録音)の停止
        /// </summary>
        private void StopCapture()
        {
            foreach (var pair in m_WebSocketClients)
            {
                var data = new MessageData { type = MessageData.Type.StopCapture };
                var json = JsonConvert.SerializeObject(data);

                pair.Value.Send(json);
            }

            m_Capture.StopAsync();

            if (checkBox_sendAudio.Checked || checkBox_recordAudio.Checked)
            {
                m_Recorder.StopRecording();
            }

            if (m_AviWriter != null)
            {
                Debug.Log("" + m_AviVideoStream.FramesWritten);
                m_AviWriter.Close();
                m_AviWriter = null;
                m_AviVideoStream = null;
                m_AviAudioStream = null;
            }
        }
开发者ID:wawawa3,项目名称:ScreenShare,代码行数:29,代码来源:Form_tcp.cs

示例10: LoadSettings

        private void LoadSettings()
        {
            try
            {
                writer = new AviWriter("test.avi")
                    {
                        FramesPerSecond = 25,
                        // Emitting AVI v1 index in addition to OpenDML index (AVI v2)
                        // improves compatibility with some software, including
                        // standard Windows programs like Media Player and File Explorer
                        EmitIndex1 = true
                    };

                var encoder = new Mpeg4VideoEncoderVcm((int)numericWidth.Value, (int)numericHeight.Value, 25, 0, 100, KnownFourCCs.Codecs.Xvid);
            //                stream = writer.AddMotionJpegVideoStream(640, 480, quality: 100);
                //stream = writer.AddMpeg4VideoStream(640, 480, 30, quality: 70, codec: KnownFourCCs.Codecs.X264, forceSingleThreadedAccess: true);
                stream = writer.AddEncodingVideoStream(encoder, true, (int)numericWidth.Value, (int)numericHeight.Value);

                // set standard VGA resolution
                //            stream.Width = 640;
                //            stream.Height = 480;
                // class SharpAvi.KnownFourCCs.Codecs contains FOURCCs for several well-known codecs
                // Uncompressed is the default value, just set it for clarity

                //stream.Codec = KnownFourCCs.Codecs.MotionJpeg;
                // Uncompressed format requires to also specify bits per pixel
                //stream.BitsPerPixel = BitsPerPixel.Bpp32;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:rhpa23,项目名称:CaptureScreenPoc,代码行数:33,代码来源:Form1.cs

示例11: GetVideoFileWriter

        IVideoFileWriter GetVideoFileWriter(IImageProvider ImgProvider)
        {
            var selectedVideoSourceKind = VideoViewModel.SelectedVideoSourceKind;
            var encoder = VideoViewModel.SelectedCodec;

            IVideoFileWriter videoEncoder = null;
            encoder.Quality = VideoViewModel.Quality;

            if (encoder.Name == "Gif")
            {
                if (GifViewModel.Unconstrained)
                    _recorder = new UnconstrainedFrameRateGifRecorder(
                        new GifWriter(_currentFileName,
                            Repeat: GifViewModel.Repeat ? GifViewModel.RepeatCount : -1),
                        ImgProvider);

                else
                    videoEncoder = new GifWriter(_currentFileName, 1000/VideoViewModel.FrameRate,
                        GifViewModel.Repeat ? GifViewModel.RepeatCount : -1);
            }

            else if (selectedVideoSourceKind != VideoSourceKind.NoVideo)
                videoEncoder = new AviWriter(_currentFileName, encoder);
            return videoEncoder;
        }
开发者ID:MathewSachin,项目名称:Captura,代码行数:25,代码来源:MainViewModel.cs

示例12: CaptureStarted

 public void CaptureStarted(int width, int height, int pitch, TextureFormat format, bool flipVertical)
 {
     aviWriter = new AviWriter(File.Create("capture.avi", pitch * height), width, height, 60, !flipVertical);
 }
开发者ID:prepare,项目名称:SharpBgfx,代码行数:4,代码来源:Program.cs

示例13: CreateVideoStream

 public IAviVideoStream CreateVideoStream(AviWriter writer)
 {
     // Select encoder type based on FOURCC of codec
     if (Codec == KnownFourCCs.Codecs.Uncompressed) return writer.AddUncompressedVideoStream(Width, Height);
     else if (Codec == KnownFourCCs.Codecs.MotionJpeg) return writer.AddMotionJpegVideoStream(Width, Height, Quality);
     else
     {
         return writer.AddMpeg4VideoStream(Width, Height, (double)writer.FramesPerSecond,
             // It seems that all tested MPEG-4 VfW codecs ignore the quality affecting parameters passed through VfW API
             // They only respect the settings from their own configuration dialogs, and Mpeg4VideoEncoder currently has no support for this
             quality: Quality,
             codec: Codec,
             // Most of VfW codecs expect single-threaded use, so we wrap this encoder to special wrapper
             // Thus all calls to the encoder (including its instantiation) will be invoked on a single thread although encoding (and writing) is performed asynchronously
             forceSingleThreadedAccess: true);
     }
 }
开发者ID:gitter-badger,项目名称:Captura,代码行数:17,代码来源:Recorder.cs

示例14: recordHudToAVIToolStripMenuItem_Click

        private void recordHudToAVIToolStripMenuItem_Click(object sender, EventArgs e)
        {
            stopRecordToolStripMenuItem_Click(sender, e);

            CustomMessageBox.Show("Output avi will be saved to the log folder");

            aviwriter = new AviWriter();
            Directory.CreateDirectory(MainV2.LogDir);
            aviwriter.avi_start(MainV2.LogDir + Path.DirectorySeparatorChar +
                                DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".avi");

            recordHudToAVIToolStripMenuItem.Text = "Recording";
        }
开发者ID:Viousa,项目名称:MissionPlanner,代码行数:13,代码来源:FlightData.cs

示例15: CaptureDone

        private void CaptureDone(System.Drawing.Bitmap e)
        {
            const float parse_fps = 10.0f;
            float video_fps = me.fpsVideo;
            long max_size = me.trocearTamMB*1048576;
           
            
            if (saving_picture)
            {
                saving_picture = false;

                string path = me.PicturePath;
                if (path != null && path != "")
                {
                    DateTime dt = DateTime.Now;

                    if (!Directory.Exists(path))
                        Directory.CreateDirectory(path);

                    string filename = path + "\\PIC_"
                        + dt.Year.ToString("00") + dt.Month.ToString("00") + dt.Day.ToString("00")
                        + "-" + dt.Hour.ToString("00") + dt.Minute.ToString("00") + dt.Second.ToString("00") + ".jpg";

                    try
                    {
                        e.Save(filename, ImageFormat.Jpeg);
                    }
                    catch (Exception) { }
                }

            }

            if (starting_video)
            {
                starting_video = false;
                
                string path = me.VideosPath;
                if (path != null && path != "")
                {
                    DateTime dt = DateTime.Now;

                    if (!Directory.Exists(path))
                        Directory.CreateDirectory(path);

                    string filename = path + "\\VID_"
                        + dt.Year.ToString("00") + dt.Month.ToString("00") + dt.Day.ToString("00")
                        + "-" + dt.Hour.ToString("00") + dt.Minute.ToString("00") + dt.Second.ToString("00")+".avi";

                    avi_writer = new AviWriter();
                    avi_writer.avi_start(filename);

                    saving_video = true;
                    button15.Image = UAVConsole.Properties.Resources.video_red;
                }

            }
            else if (stoping_video)
            {
                saving_video = false;
                stoping_video = false;
                avi_writer.avi_close();
                avi_writer = null;
                
            }
            else if (saving_video && DateTime.Now.Ticks > video_last_tick)
            {
                video_last_tick = DateTime.Now.Ticks + (long)(TimeSpan.TicksPerSecond / video_fps);
                if (me.trocearVideo && max_size > 0 && avi_writer.current_lenght > max_size)
                {
                    avi_writer.avi_close();
                    avi_writer = new AviWriter();
                    DateTime dt = DateTime.Now;

                    string filename = me.VideosPath + "\\VID_"
                       + dt.Year.ToString("00") + dt.Month.ToString("00") + dt.Day.ToString("00")
                       + "-" + dt.Hour.ToString("00") + dt.Minute.ToString("00") + dt.Second.ToString("00") + ".avi";
                    avi_writer.avi_start(filename);
                }
                    avi_writer.SaveFrame(e, me.calidadVideo);
              
            }

            if (modem is ModemVideo && DateTime.Now.Ticks > parse_last_tick)
            {
                parse_last_tick = DateTime.Now.Ticks + (long)(TimeSpan.TicksPerSecond / parse_fps);
                ((ModemVideo)modem).SetImage(e);
            }

            capture.GrapImg2();
        }
开发者ID:rajeper,项目名称:ikarus-osd,代码行数:90,代码来源:FormIkarusMain.cs


注:本文中的AviWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。