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?
Missing last frames
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Missing last frames
Several frames may be buffered and processed with some delay. So I suggest to stop recording after some delay.
-
- Posts: 3
- Joined: Tue Sep 11, 2018 2:29 pm
- Location: Czech
- Contact:
Missing last frames
Do you get some kind of error messages during saving or opening the animation or are the frames just gone?
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Missing last frames
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.
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
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.
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.
Last edited by panlab_mf on Mon Apr 08, 2019 2:12 pm, edited 1 time in total.
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Missing last frames
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.
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
I'm going to test it lowering the frame rate from 25 FPS to 15 FPS. And let you know.