public void GetSetOption() { using var writer = new VideoWriter("dummy2.avi", FourCCValues.MJPG, 10, new Size(640, 480)); Assert.True(writer.IsOpened()); writer.Set(VideoWriterProperties.Quality, 50); Assert.Equal(50, writer.Get(VideoWriterProperties.Quality), 3); }
public Capture(string videoUri, string fileUri, string codec = "MPEG") { _vsrc = new VideoCapture(videoUri, VideoCapture.API.Ffmpeg); _vsrc.ImageGrabbed += ImageGrabbed; _sink = new VideoWriter(fileUri, FourCC(codec), 0.25, new Size((int)_vsrc.GetCaptureProperty(CapProp.FrameWidth), (int)_vsrc.GetCaptureProperty(CapProp.FrameHeight)), _vsrc.GetCaptureProperty(CapProp.Monochrome) == 0); _sink.Set(VideoWriter.WriterProperty.NStripes, 1); }
public void GetSetOption() { const string fileName = "dummy2.avi"; try { using var writer = new VideoWriter(fileName, VideoCaptureAPIs.OPENCV_MJPEG, FourCC.MJPG, 10, new Size(640, 480)); Assert.True(writer.IsOpened()); Assert.Equal("CV_MJPEG", writer.GetBackendName()); Assert.True(writer.Set(VideoWriterProperties.Quality, 50), "VideoWriter.Set failed"); Assert.Equal(50, writer.Get(VideoWriterProperties.Quality), 3); } finally { DeleteFile(fileName); } }
internal void WriteFinalVideo(List <int> framesToRender, string audioFile) { using (outputVideo = new VideoWriter(tempVideo, Options.VIDEO_CODEC, (double)options.frame_rate, options.frame_size, true)) { outputVideo.Set(VideoWriter.WriterProperty.Quality, options.frame_quality / 100.00); //Update status every x frames, with a 0.1% rate var lastFrame = 0; var count = 0; foreach (var frame in framesToRender) { var adjframe = frame + 1; utils.ReportStatus("Writing frame {0} out of {1} {2}", count, framesToRender.Count, 2); count++; if (adjframe != lastFrame) { var framesToMove = adjframe - lastFrame; bool nextFrame = true; //move to next x frame for (var i = 0; i < framesToMove; i++) { nextFrame = inputVideo.Grab(); } if (!nextFrame) { return; } var img = new Mat(); inputVideo.Retrieve(img); outputVideo.Write(img); img.Dispose(); } lastFrame = adjframe; } utils.ReportStatus("Writing frame {0} out of {1} {2}", options.frame_count, options.frame_count, 2, last: true); } }