Thanks, The_Island. I have made a bug report. If it is easier, perhaps you can take a look at that and let me know what you see from it.
For this test, I made a simple video using 29 frames of PNGs using FFMPEG to create a spinning glowing transparent cube:
ffmpeg -start_number 1 -i c:/tmp/%04d.png -r 60 -c:v libvpx -crf 10 -b:v 2M -pix_fmt yuva420p -auto-alt-ref 0 -metadata:s:v:0 alpha_mode="1" c:/tmp/output.webm
Just for reference, I even included FFMPEG.exe and the source PNGs in the test project:
The output video appears as follows inside Unity, correctly recognized as 60 fps as encoded:
Then I wrote the following project:
public class App : MonoBehaviour
{
VisualElement bgVE;
Label label;
VideoPlayer videoPlayer;
// Start is called before the first frame update
void Start()
{
Application.targetFrameRate = (int)Screen.currentResolution.refreshRateRatio.value;
VisualElement rootVE = gameObject.GetComponent<UIDocument>().rootVisualElement;
bgVE = new VisualElement();
bgVE.style.width = bgVE.style.height = new Length(100, LengthUnit.Percent);
bgVE.style.backgroundColor = Color.white;
rootVE.Add(bgVE);
label = new Label();
label.style.color = Color.green;
label.style.fontSize = 20;
label.style.position = Position.Absolute;
bgVE.Add(label);
VideoClip clip = Resources.Load<VideoClip>("output");
RenderTexture rt = new RenderTexture((int)clip.width, (int)clip.height, 32);
videoPlayer = gameObject.AddComponent<VideoPlayer>();
videoPlayer.clip = clip;
videoPlayer.targetTexture = rt;
videoPlayer.isLooping = true;
videoPlayer.Play();
VisualElement videoVE = new VisualElement();
videoVE.style.width = videoVE.style.height = new Length(100, LengthUnit.Percent);
videoVE.style.backgroundImage = Background.FromRenderTexture(rt);
videoVE.style.unityBackgroundScaleMode = ScaleMode.ScaleToFit;
bgVE.Add(videoVE);
}
// Update is called once per frame
void Update()
{
string debug = "";
if (videoPlayer != null) {
debug += "VIDEO FPS: " + videoPlayer.frameRate + " \nSCREEN FPS: " + (1f / Time.deltaTime);
}
label.text = debug;
}
}
This creates the following screen display with a spinning cube and frame rate outputs:
I then ran the following test settings under “Default” with the following results:
SETTING 1: TRANSCODE, AUTO OR H264 CODEC, KEEP ALPHA:
Android Result:
SCREEN FPS 60, VIDEO FPS 30 (terrible jerky motion, does not run in any remotely normal way)
Video looks mostly correct otherwise, transparency permitted but with sharp alpha clipping - no glow effect evident.
Windows Editor Result:
SCREEN FPS 60, VIDEO FPS 25.58075 (motion is smooth and normal)
Video looks correct except again transparency is permitted only with sharp alpha clipping - no glow effect evident.
SETTING 2: NO TRANSCODE:
Android Result:
SCREEN FPS 60, VIDEO FPS 30 (terrible jerky motion, does not run in any remotely normal way)
Video has green lines all over, has black background instead of alpha, glow is evident against black background, generally looks ridiculous
Windows Editor Result:
SCREEN FPS 60, VIDEO FPS 60 (motion is smooth and normal)
Video looks correct except transparency is permitted again with only sharp alpha clipping - no glow effect evident.
SETTING 3: TRANSCODE, VP8 CODEC, KEEP ALPHA:
Android Result:
SCREEN FPS 60, VIDEO FPS 60 - Gives correct frame rate output, but nothing is visible - video is not rendered, just a big black box.
Windows Editor Result:
SCREEN FPS 60, VIDEO FPS 25.58075 (motion is smooth and normal but wrong frame rate)
Video looks correct except again transparency is permitted only with sharp alpha clipping - no glow effect evident.
I don’t have an iOS/iPhone device to test but I will need this working in iOS also.
TO SUMMARIZE:
(1) No way to currently get smooth transparent video playback at correct frame rate on Android (very big problem).
(2) Can get smooth transparent playback on Windows by not Transcoding there.
(3) Unsure what the outcome would be on iOS/iPhone.
(4) Even when transparency is allowed, it is only with a sharp alpha edge - under no circumstances is glow manifested.
Thanks for any further feedback or suggestions.
Bug Report: IN-31790