I'm just trying to save same frames on video from a buffer, where I properly saved the Bitmap Frame, and the Time Stamp, of the frame.
writer1 = new VideoFileWriter();
this.writer1.Width = this.videoSourceEndo.VideoResolution.FrameSize.Width;
this.writer1.Height = this.videoSourceEndo.VideoResolution.FrameSize.Height;
this.writer1.VideoCodec = VideoCodec.H264;
this.writer1.BitRate = (this.videoSourceEndo.VideoResolution.FrameSize.Height * this.videoSourceEndo.VideoResolution.FrameSize.Width * 30);
this.writer1.VideoOptions["preset"] = "superfast";
this.writer1.VideoOptions["tune"] = "zerolatency";
writer1.Open("test_HDMI.mp4");
(...)
writer1.WriteVideoFrame(endoFrameBuffer[endoFrameBuffer.Tail],endoFrameBuffer.getframetime(endoFrameBuffer.Tail));
But on visual studio (not on the first frame) I'm getting this error: Accord.Video.VideoException: 'Error while writing video frame. Error -22: Invalid argument. See console output for more details.'
And on console: Application provided invalid, non monotonically increasing dts to muxer in stream 0: 512 >= 512
I don't know the reason for that because on debug all values seems right. (Please let me know if you need more code)
time_base
's correctly (which I don't see here). So your problem lies hereendoFrameBuffer.getframetime(endoFrameBuffer.Tail)
let's see the code – the kamilzpublic TimeSpan getframetime(int index) { return _timeBuffer[index]; }
– Eduardo PretoendoFrameBuffer.Enqueue(eventArgs.Frame,DateTime.Now - _firstFrameTime.Value);
when the newframe event is fired. Then On the other thread I'm just recording each frame from the RingBuffer. – Eduardo Pretofps
is that video stream (because pts=512 is unusual to me). IsgetFrameTime
method returnspts
value ?. – the kamilz