Page 1 of 1

Missing last frames

Posted: Wed Aug 08, 2018 3:17 am
by oliver
I am using TRVCamera and TRVCamcorder to record the screen.

When I set TRVCamcorder->Active=false to quickly after the last keystroke, that last keystroke (which is visible on the screen) does not get recorded.

I tried adding a Sleep(1000) after the last keystroke before I set TRVCamcorder->Active=false, but that makes no difference.

How can I make sure, TRVCamcorder is done recording before I stop recording?

Re: Missing last frames

Posted: Wed Aug 08, 2018 11:19 am
by Sergey Tkachenko
Several frames may be buffered and processed with some delay. So I suggest to stop recording after some delay.

Missing last frames

Posted: Wed Sep 19, 2018 8:53 pm
by Sentorolar
Do you get some kind of error messages during saving or opening the animation or are the frames just gone?

Re: Missing last frames

Posted: Thu Sep 20, 2018 10:01 am
by Sergey Tkachenko
There are no errors.
RVMedia write frames exactly at interval specified in TRVCamRecorder.VideoFramePerSec, as precise as possible. The only possible reason for missing last frames here is too large value of TRVCamRecorder.VideoFramePerSec: if it's not possible to encode the required count of frames at this speed. But it's very unlikely.

When writing video with sound, another reason is possible. Sound is buffered for some time before writing, and when you stop recording, the last incomplete fragment of sound may be discarded, so the duration of sound will be less than the duration of video, and a video viewer may choose to display video using the sound duration, so last video frames will not be displayed. But I believe this difference is small, less than 1 second.

Re: Missing last frames

Posted: Mon Apr 08, 2019 9:52 am
by panlab_mf
Hi All,

I'm facing the same issue, more or less. In my case there is no audio source. I've tried several convinations : file formats; video codecs; local/remote cameras; frame rate with the same result: the recorded video file missing almost 2 second of recording.

I've added some debugging options to trace how many frames the camera gives, and how many frames the encoder receives. And even it matches the file missed almost 2 seconds all the time.

So, what can we do in order to have a video recorded duration that matches what we need?

I forget to mention that Im using the sample code "Delphi XE10.2 - VideRecorder" with two new options:
1) Timing recording options: a) Free recording; b) Preset duration (in seconds): [ 300 ] [secs];
2) Recording progress: elapsed time since the recording was started; updated each 100 milliseconds by a TTimer component

Then, when the elapsed time reachs the preset duration it calls the btnStopClick routine. But, when I look into the resulting video file it has only 298 seconds.

Thanks.

Re: Missing last frames

Posted: Mon Apr 08, 2019 11:25 am
by Sergey Tkachenko
RVMedia sets the proper video properties and pass frames to an encoder according to the specified frame rate.
Everything else is up to the encoder and we cannot modify it.

One thing is possible: receiving and writing frames is too slow, so RVMedia cannot feed the encoder with enough count of frames. Less frames - less video length. However, in this case, missing frames must be distributed through all the video, not in its end.
This situation could be detected in MRVFFMpegThreads.pas, in TRVFFMpegEncode.Execute. After executing the line
DiffInterval := FrameCount * FrameDiff - Interval,
DiffInterval must be negative all the time.
But it's hard to debug it, because any debugging tools (even OutputDebugString) slows down this thread and it affects the result.

I suggest to try recording with a lower frame rate.

Re: Missing last frames

Posted: Mon Apr 08, 2019 2:14 pm
by panlab_mf
I'm going to test it lowering the frame rate from 25 FPS to 15 FPS. And let you know.