Skip to content Skip to sidebar Skip to footer

Tap To Record Like In Vine Using Javacv

I am trying to implement a tap to record feature like in vine. A sample for handling recording (not touch to record) provided in javacv is https://github.com/bytedeco/javacv/blob/m

Solution 1:

The easy (but imprecise) solution would be to estimate the average frame rate, and use t += 1000000/average_fps; recorder.setTimestamp(t); instead of looking at the actual timestamps.

To be more accurate, you can change onPreviewFrame() as follows:

long thisFrameTime = SystemClock.elapsedRealtime();
timestamps[i] = thisFrameTime;
long lastFrameTime = timestamps[imagesIndex < 2 ? startTime : (imagesIndex-2) % images.length)];
if (lastFrameTime > stopPauseTime) {
    timestampsForRecorder[i] = 1000 * (thisFrameTime - Math.max(stopPauseTime, lastFrameTime));
}

You can feed the second array, timestampsForRecorder, directly to the recorder.

Note that it's safer to use SystemClock.elapsedRealtime() everywhere:

This clock is guaranteed to be monotonic, and continues to tick even when the CPU is in power saving modes, so is the recommend basis for general purpose interval timing.


Post a Comment for "Tap To Record Like In Vine Using Javacv"