Add correction factor in video time calculation
Test: npm run build:all && npm run test:all Change-Id: I0cfdff9fbbc15a4ad5d5a21c0f4df44335291830
This commit is contained in:
@@ -20,20 +20,21 @@ describe('Viewer ScreenRecording', () => {
|
||||
beforeAll(async () => {
|
||||
browser.manage().timeouts().implicitlyWait(1000);
|
||||
browser.get('file://' + E2eTestUtils.getProductionIndexHtmlPath());
|
||||
}),
|
||||
it('processes trace and renders view', async () => {
|
||||
await E2eTestUtils.uploadFixture(
|
||||
'traces/elapsed_and_real_timestamp/screen_recording_metadata_v2.mp4'
|
||||
);
|
||||
await E2eTestUtils.closeSnackBarIfNeeded();
|
||||
await E2eTestUtils.clickViewTracesButton();
|
||||
});
|
||||
|
||||
const viewer = element(by.css('viewer-screen-recording'));
|
||||
expect(await viewer.isPresent()).toBeTruthy();
|
||||
it('processes trace and renders view', async () => {
|
||||
await E2eTestUtils.uploadFixture(
|
||||
'traces/elapsed_and_real_timestamp/screen_recording_metadata_v2.mp4'
|
||||
);
|
||||
await E2eTestUtils.closeSnackBarIfNeeded();
|
||||
await E2eTestUtils.clickViewTracesButton();
|
||||
|
||||
const video = element(by.css('viewer-screen-recording video'));
|
||||
expect(await video.isPresent()).toBeTruthy();
|
||||
expect(await video.getAttribute('src')).toContain('blob:');
|
||||
expect(await video.getAttribute('currentTime')).toEqual('0');
|
||||
});
|
||||
const viewer = element(by.css('viewer-screen-recording'));
|
||||
expect(await viewer.isPresent()).toBeTruthy();
|
||||
|
||||
const video = element(by.css('viewer-screen-recording video'));
|
||||
expect(await video.isPresent()).toBeTruthy();
|
||||
expect(await video.getAttribute('src')).toContain('blob:');
|
||||
expect(await video.getAttribute('currentTime')).toBeCloseTo(0, 0.001);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,12 +17,17 @@
|
||||
import {Timestamp} from './timestamp';
|
||||
|
||||
class ScreenRecordingUtils {
|
||||
// Video time correction epsilon. Without correction, we could display the previous frame.
|
||||
// This correction was already present in the legacy Winscope.
|
||||
private static readonly EPSILON_SECONDS = 0.00001;
|
||||
|
||||
static timestampToVideoTimeSeconds(firstTimestamp: Timestamp, currentTimestamp: Timestamp) {
|
||||
if (firstTimestamp.getType() !== currentTimestamp.getType()) {
|
||||
throw new Error('Attempted to use timestamps with different type');
|
||||
}
|
||||
const videoTimeSeconds =
|
||||
Number(currentTimestamp.getValueNs() - firstTimestamp.getValueNs()) / 1000000000;
|
||||
Number(currentTimestamp.getValueNs() - firstTimestamp.getValueNs()) / 1000000000 +
|
||||
ScreenRecordingUtils.EPSILON_SECONDS;
|
||||
return videoTimeSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user