alskipp/ASScreenRecorder

FPS

Closed this issue · 12 comments

How can I manage the fps?

Thank you.

The information can probably be found here

You could try the following within the setUpWriter method.

 _videoWriterInput.mediaTimeScale = FPS;
 _videoWriter.movieTimeScale = FPS;

I'm getting warning: Unable to write buffer to video.
It means appendPixelBuffer return NO (line 266).

I did another way by setting frameInterval property of _displayLink.

I did another way by setting frameInterval property of _displayLink.

Cunning plan : )

:D

I have another question.
How can I implement pause/resume functionality?
I tried to play with _displayLink.paused property. It works, but not as I expect.
In the exported video I see a frozen screen (the screen from where I paused recording) for some time interval (actually this is the interval between pause and resume) and after the image changes.
In other words, lets say if I started the recording on time1 and stopped on time 2, and paused on time3 and resumed on time4, then the video duration still will be (time2-time1):

Start_________________________________________________________________________Stop
|__frozen screen_******************|
(time1)(time3)(time4)____(time2)

So what I should do, to cut that time interval (from time3 to time4) from the video, or prevent from recording when it paused?

Unfortunately the functionality you want is not implemented. A workaround would be to stop recording instead of pausing, then record a new video for the next section. You would then need to use AVFoundation to combine the separate videos into one when you're finished.

The ability to pause recording is probably feasible to add to the current code base, but it's not something I have time to implement personally.

I think I found the solution, again :D
I'm collecting the timestamps of pause and resume times in the array, and then I remove that intervals from elapsed:

        CFTimeInterval elapsed = _displayLink.timestamp - self.firstTimeStamp;
        if (self.pauseResumeTimeRanges.count) {
            for (int i = 0; i < self.pauseResumeTimeRanges.count; i += 2) {
                double pausedTime = [self.pauseResumeTimestamps[i] doubleValue];
                double resumeTime = [self.pauseResumeTimestamps[i+1] doubleValue];
                elapsed -= resumeTime - pausedTime;
            }
        }

        CMTime time = CMTimeMakeWithSeconds(elapsed, 1000);

Cunning plan, huh? :))

I wonder if you can achieve the same result by checking _isRecording in the writeVideoFrame method? I've not actually tried to see if it would work, but the idea is: you'd set _isRecording to NO to pause the recording and restart by setting it back to YES. Then you'd need to check before writing the video frame:

if (![_videoWriterInput isReadyForMoreMediaData] && !_isRecording) return;

Having not actually tried this idea out, I can't guarantee it'll work. Seems reasonable?

That will give same result as setting _displayLink.paused to NO. Because the issue is with _displayLink.timestamp value. It always returns the time value associated with the last frame that was displayed.

Fair point. Perhaps another technique would be to pause the displayLink, capture the paused time, then adjust the self.firstTimeStamp before resuming recording?

Either way, good luck with your mission!

Thank you :)

@arturdev @alskipp Can you guys please help me with this issue #15 :( , Thanks in advance