Skip to content
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

Add support to visualmetrics to identify key frames matching the given colors #2119

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

aosmond
Copy link
Contributor

@aosmond aosmond commented May 2, 2024

This patch updates the visualmetrics.py and visualmetrics-portable.py scripts to allow it to identify and record timestamps for frames that match the given color configuration. This consists of an RGB value with fuzz (anything +/- fuzz matches) and a fraction between 0 and 1 of the required percentage of each channel from the histogram that must match it.

This is intended to be used in Firefox automation to collect metrics with respect to video playback latency.

@aosmond aosmond force-pushed the ao_visualmetrics_video_latency branch from 51a0aad to 511421d Compare May 3, 2024 03:25
@gmierz
Copy link
Collaborator

gmierz commented May 3, 2024

Hi @aosmond, interesting metric! Can you provide an example video, and command that we could test this with along with the expected output from it?

@gmierz gmierz requested review from soulgalore and gmierz May 3, 2024 13:00
@aosmond aosmond force-pushed the ao_visualmetrics_video_latency branch from 511421d to 4044474 Compare May 3, 2024 17:37
@aosmond
Copy link
Contributor Author

aosmond commented May 3, 2024

@gmierz
I added an example zip/description here:
https://gist.github.com/aosmond/4daa941cf36670e2ab0f7ecbeb66ed00

This should yield in browsertime.json under "visualmetrics" when the poster, first video frame, second video frame and last video frame are displayed.

@aosmond aosmond force-pushed the ao_visualmetrics_video_latency branch from 4044474 to ec129bb Compare May 7, 2024 00:26
@aosmond aosmond force-pushed the ao_visualmetrics_video_latency branch from ec129bb to a179153 Compare May 13, 2024 19:26
@aosmond
Copy link
Contributor Author

aosmond commented May 13, 2024

Updated according to your feedback @gmierz. You can see this working in conjunction with Firefox CI in my try pushes which I am just polishing up now:
https://treeherder.mozilla.org/jobs?repo=try&revision=2bbf558778ffbf707ccfed5a49d24ecc7a0e8e59

I also updated the visualmetrics scripts to accept an individual range for each channel, as well as annotating the video with the key color frame information (if available).

@aosmond
Copy link
Contributor Author

aosmond commented May 13, 2024

The mozilla CI side is tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=1896524

Copy link
Collaborator

@gmierz gmierz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ for the visual metrics script changes, just a nit and a small question below. Thanks for fixing up the calculation method!

Copy link
Member

@soulgalore soulgalore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering could this just be a change in visualmetrics-portable.py and then add a generic way to pass on parameters to that script from Browsertime, and then you could have your magic analysing it in your ci?

@aosmond aosmond force-pushed the ao_visualmetrics_video_latency branch from 5048a0a to d984511 Compare May 21, 2024 12:22
@aosmond
Copy link
Contributor Author

aosmond commented May 21, 2024

I'm wondering could this just be a change in visualmetrics-portable.py and then add a generic way to pass on parameters to that script from Browsertime, and then you could have your magic analysing it in your ci?

I'm happy to make whatever changes are necessary for a merge :). But I'm a bit uncertain as to what that would look like, as I didn't make too many changes outside the python scripts, just what I thought was necessary to get the information out and annotate the videos. What parts would you like removed?

I already do a post processing phase on the raw key color data in our CI to normalize things in case it didn't get a first frame, but found a second frame, etc.

@aosmond aosmond force-pushed the ao_visualmetrics_video_latency branch from d984511 to 32305f9 Compare May 21, 2024 14:24
@aosmond aosmond requested a review from soulgalore May 26, 2024 19:49
@@ -718,6 +723,12 @@ export function parseCommandLine() {
describe:
'Use the portable visual-metrics processing script (no ImageMagick dependencies).'
})
.option('visualMetricsKeyColor', {
type: 'array',
nargs: 8,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this is missmatch to the gist you provide with how to run it? I tried with bin/browsertime.js --visualMetrics true --video true --iterations 1 --visualMetricsKeyColor poster 120 250 250 20 0.75 --visualMetricsKeyColor first_frame 250 20 20 20 0.75 --visualMetricsKeyColor second_frame 20 20 250 20 0.75 --visualMetricsKeyColor last_frame 255 255 50 50 0.75 --browser firefox --video.framerate 60 https://www.sitespeed.io (I think that is in the example) but then I get "Not enough arguments following: visualMetricsKeyColor". Can you share how I can try it + do you know a live site where I can try?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated my gist at https://gist.github.com/aosmond/4daa941cf36670e2ab0f7ecbeb66ed00. I don't have a live site. It's primary purpose is to measure the latency of video playback, hence the special rainbow video I made, but in theory any video that displays a non-white solid color frame at some point would work.

…n colors.

This patch updates the visualmetrics.py and visualmetrics-portable.py
scripts to allow it to identify and record timestamps for frames that
match the given color configuration. This consists of an RGB value with
fuzz (anything +/- fuzz matches) and a fraction between 0 and 1 of the
required percentage of each channel from the histogram that must match it.
@aosmond aosmond force-pushed the ao_visualmetrics_video_latency branch from bcef641 to b189a99 Compare June 3, 2024 01:06
@aosmond aosmond requested a review from soulgalore June 3, 2024 14:36
@soulgalore soulgalore merged commit 1b1645a into sitespeedio:main Jun 4, 2024
13 checks passed
aosmond added a commit to aosmond/gecko that referenced this pull request Jun 6, 2024
…playback latency.

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

This patch updates the browsertime dependency to be built on the same
version as we currently use in CI, with addition of our own patches to
enable this while we wait to be merged. Until such a time, and until the
tests have proven stable, they have been set at tier 3.

The status of the merge can be seen at:
sitespeedio/browsertime#2119

Differential Revision: https://phabricator.services.mozilla.com/D210242
aosmond added a commit to aosmond/gecko that referenced this pull request Jun 6, 2024
…playback latency.

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

This patch requires an updated browsertime dependency once the following
pull request has been merged:
sitespeedio/browsertime#2119

Until then, the tests should remain disabled by default.

Differential Revision: https://phabricator.services.mozilla.com/D210242
aosmond added a commit to aosmond/gecko that referenced this pull request Jun 11, 2024
…playback latency.

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

Until the tests have proven stable, they have been set at tier 3.

The status of the merge can be seen at:
sitespeedio/browsertime#2119

Differential Revision: https://phabricator.services.mozilla.com/D210242
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Jun 12, 2024
…playback latency. r=perftest-reviewers,sparky

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

Until the tests have proven stable, they have been set at tier 3.

The status of the merge can be seen at:
sitespeedio/browsertime#2119

Differential Revision: https://phabricator.services.mozilla.com/D210242
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Jun 14, 2024
…playback latency. r=perftest-reviewers,sparky

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

Until the tests have proven stable, they have been set at tier 3.

The status of the merge can be seen at:
sitespeedio/browsertime#2119

Differential Revision: https://phabricator.services.mozilla.com/D210242
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jun 16, 2024
…playback latency. r=perftest-reviewers,sparky

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

Until the tests have proven stable, they have been set at tier 3.

The status of the merge can be seen at:
sitespeedio/browsertime#2119

Differential Revision: https://phabricator.services.mozilla.com/D210242

UltraBlame original commit: 9495d071271ff447bbe633af76131c289e00d471
aosmond added a commit to aosmond/gecko that referenced this pull request Aug 7, 2024
…playback latency.

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

This patch requires an updated browsertime dependency once the following
pull request has been merged:
sitespeedio/browsertime#2119

Until then, the tests should remain disabled by default.

Differential Revision: https://phabricator.services.mozilla.com/D210242
aosmond added a commit to aosmond/gecko that referenced this pull request Aug 7, 2024
… latency.

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

This patch requires an updated browsertime dependency once the following
pull request has been merged:
sitespeedio/browsertime#2119

Differential Revision: https://phabricator.services.mozilla.com/D210242
aosmond added a commit to aosmond/gecko that referenced this pull request Aug 7, 2024
…playback latency.

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

Until the tests have proven stable, they have been set at tier 3.

The status of the merge can be seen at:
sitespeedio/browsertime#2119

Differential Revision: https://phabricator.services.mozilla.com/D210242
aosmond added a commit to aosmond/gecko that referenced this pull request Aug 7, 2024
…playback latency.

The video under test is a simple recording of solid colors, where the
first frame is red, second frame is blue, subsequent frames alternate
between green and purple, and the final frame is yellow. This allows us
to identify what frame is being displayed and when in a browser agnostic
way.

This is achieved by updating the visualmetrics python script in
browsertime to identify frames which match a given color range, called
key color frames. The script will produce a list of which frames appear
when that we can use to estimate the playback latency. Note that the
annotated videos produced by the jobs will also be annotated to make it
clear which frames it believes are key color frames.

Until the tests have proven stable, they have been set at tier 3.

The status of the merge can be seen at:
sitespeedio/browsertime#2119

Differential Revision: https://phabricator.services.mozilla.com/D210242
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants