web-stories-wp
web-stories-wp copied to clipboard
Logic for when to recommend optimizing uploaded videos
Description
Recommendations to optimize existing video are currently implemented (behind a feature flag) using just dimensions of a video. This should be handled more robustly and needs more conversation about what all should go into that then was able to be handled for getting the initial implementation.
This ticket is to define the logic behind when to show a recommendation of optimizing an uploaded video in the prepublish checklist and then updating the necessary check in the PPC to implement.
Doc for collaboration: https://docs.google.com/document/d/1pPjoCqTDLnJQ4PCQ04W5c4dmuvt_S2Cz5GUbekYTsos/edit
Things to possibly take into consideration, off the top of my head:
- codecs
- file size (especially in relation to duration)
- frame rate
- dimensions
- whether video is coming from provider like VideoPress that already optimizes videos
- estimated size reduction (is it worth optimizing the video or would we only save a few KB anyway?)
Could also think about whether the same should be applied to newly uploaded videos.
/cc @choumx
Examples of data found in the REST API for media.


We have some of this data,
- File size
- bit rate
- dimensions
- video length
- Audio codex information.
From the looks of it, it depends on the source video, if we get this data or not.
After bug bash it feels a little unintuitive for a user when video will or will not be optimized and I think this ppc check is highlighting this a little.
Right now the check is just looking at the element.resource
to decide when it recommends to optimize the video, however what's unintuitive is how the properties are set on element.resource
such as isOptimized
and height
& width
depending on the upload method.
Anyway, I'm wondering how we can bridge this gap a little to make it a little more consistent/intuitive of a check for the user.
Not sure if we should be attacking this from the design side, infra or making more accommodations on the PPC side? Would love to get the conversation going on what we can do for next steps to make this feature a little more user friendly.
Thoughts @swissspidy @spacedmonkey @choumx @BrittanyIRL
Right now the check is just looking at the element.resource to decide when it recommends to optimize the video, however what's unintuitive is how the properties are set on element.resource such as isOptimized and height & width depending on the upload method.
Can you provide more details here? I tested inserting video from 3 different methods, drag and drop, insert from media picker and existing video from media library. All the values seem to be the same to me.
The rules currently, if upload via drag and drop, the video will be transcoded. If upload via WordPress media library or media picker they will not. Or if the video was uploaded per video transcoding feature was added. It is worth noting, we discussed enabling video transcoding if inserted via media picker.
I think we do need a little more consistent on when a video is transcoded in the first place, so this PPC should be needed.
After bug bash it feels a little unintuitive for a user when video will or will not be optimized and I think this ppc check is highlighting this a little.
Right now the check is just looking at the
element.resource
to decide when it recommends to optimize the video, however what's unintuitive is how the properties are set onelement.resource
such asisOptimized
andheight
&width
depending on the upload method.
width
and height
should always be available on the resource
object and refer to the resource's dimensions (not the element's dimensions on the canvas).
Currently, isOptimized
is only ever true
when the video was uploaded by drag & drop on the canvas / library and the user had video optimization turned on. Simple as that.
Anyway, I'm wondering how we can bridge this gap a little to make it a little more consistent/intuitive of a check for the user.
Not sure if we should be attacking this from the design side, infra or making more accommodations on the PPC side? Would love to get the conversation going on what we can do for next steps to make this feature a little more user friendly.
First and foremost we need to define what kind of factors we want to take into consideration to label a video as "needs optimization". Various potential factors were already mentioned further above, such as dimensions, file size, frame rate.
The difficulty there is finding the right thresholds/balance, especially for the file size (how big is too big?).
There might be some telemetry data that can help us better understand average file sizes users are trying to upload.
This is something that can be collaborated on in a short doc I think, before any engineering efforts are made.
@choumx @o-fernandez I want to circle back to this issue as it's in our 1.8 release and we're still unclear about what checks to add to narrow down when showing the recommendation to optimize an uploaded video. @embarks's doc in the issue description has some conversation and takes the initial ideas of what to possibly check as listed by @swissspidy in a comment above, but I think you two should be the ones to decide this.
@spacedmonkey would love your input on all of this as you are so much more well versed in this area.
I think we should bump this feature until we get some feedback about the current logic (just checking video resolution), especially since video optimization in PPC was only released a few days ago.
Agree with @choumx. The one other factor I'd consider is format if we allow back in adding a .mov file from the WP media library which may fail conversion when inserted. So having an extra check for .mov files and recommending conversion would be good. @BrittanyIRL @swissspidy
The one other factor I'd consider is format if we allow back in adding a .mov file from the WP media library which may fail conversion when inserted. So having an extra check for .mov files and recommending conversion would be good.
Just to clarify, since MOV files are not supported in stories & browsers, any failed conversion would result in the MOV file being removed from the story / not inserted in the first place. There should never be a case where there is a MOV file in a story.
The one other factor I'd consider is format if we allow back in adding a .mov file from the WP media library which may fail conversion when inserted. So having an extra check for .mov files and recommending conversion would be good.
Just to clarify, since MOV files are not supported in stories & browsers, any failed conversion would result in the MOV file being removed from the story / not inserted in the first place. There should never be a case where there is a MOV file in a story.
If failures are rare this can work, otherwise we can explore alternatives (e.g., allowing insertion but forcing optimization prior to publishing, or something similar).
We can ignore for now and monitor feedback.