-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix(chromium): make video recording duration close to real duration of the test run #38220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Drop excessive screencast frames coming from browser to comply with declared frame rate. Keep dropped frame for future use as the most current one. Keeps video recording from being too long comparing to real time of test run. Fixes microsoft#9611 microsoft#35776 microsoft#38219
Round last frame timestamp to multiply of interval calculated from declared frames per second. Keeps video recording from being too short comparing to real time of test run. Fixes microsoft#9611 microsoft#35776 microsoft#38219
Account for first screencast frame delay send by browser after start screencast request. Allow audio and video recording to be in sync. Fixes microsoft#9611 microsoft#35776 microsoft#38219
|
@Skn0tt @yury-s these are actually the same changes. I am trying my luck resubmitting them again but now with easy to reproduce test case (in #38219). I will glady respond to comments. To address previous concers:
Yes, the problem still presists. I do not think that tweaking framethrotter is a way to address this, because the purpouse of it is different. As I understandard it's main role is to not generate too much unncecessary data (for tracing) but allowing for bursts around actions. As per comment: The purpose of this change is to keep the frame rate stable in line with the declared fps so "giving some slack" is not an option :).
Yes, this changes the number of frames. Suppose that browser generates frame every 58 milliseconds. For every frame we receive we will end up pushing 1 frame to ffmpeg, loosing 18 ms of video time (with 25 fps we should have frame every 40 ms, 58 / 40 = 1.45 which is less than 1.5 so it is rounded to 1. With proposed change we will keep stable frame rate by adding additional frames every nth frame received. It is important to apply first change (dropping excessive frames), as this change alone could cause the frame rate to exceed the fps limit.
Yes but it is important in some use cases and does not hurt others. In our use case we measure time of execution of test scenarios steps/actions and present it visually to the user. Without this change we get about 150-250ms shorter video than expected. I thought it will be also valuable for people trying to sync with audio recording, but I discovered (#4870) that you are not keen on adding audio support at all. |
|
Here is my take: https://github.com/microsoft/playwright/pull/38228/files. I hope it reads better. |
|
Landed the alternative. Thanks for reminding and coming up with the fix though! |
|
@pavelfeldman about the change: // Pad with at least 1s of the last frame in the end for convenience.
// This also ensures non-empty videos with 1 frame.
const addTime = Math.max((monotonicTime() - this._lastWriteNodeTime) / 1000, 1);
this.writeFrame(Buffer.from([]), this._lastFrame.timestamp + addTime);Unfortunatelly this change ruins synchronization of video vs. test run's real time. I was trying to push change to add delay at the beginning of recording (calculated as difference between browsercontext creation time and timestamp of first frame received from browser), which would result in better synchronization (62bae71). In first try @yury-s (#10145 (comment)) argued against it as making video longer (about hunderds of millis at most). In the second try it was silently ignored. My aim was to make sync of video vs. test run better and finally to get rid of local patches. With this change it's a failure for me 😞 . Can you rethink this change, please? PS Sorry for adding comments in many places but i don't know which will get to you. |
Videos recorded with playwright using chromium engine are shorter or longer than what could be expected by measuring execution time. Causes:
Fixes #9611 #35776 #38219