RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
235 stars 28 forks source link

Error when loading video from CloudFront #438

Closed vpzomtrrfrt closed 4 years ago

vpzomtrrfrt commented 4 years ago

(Windows 10.0.18362, Unity 2018.4.24f1, AVPro Video 1.11.4)

Loading this video hosted on S3 works fine: https://vrigami.s3.amazonaws.com/CnkN0KNxpafGM2NzGBr5hDBP4Iv1ScN3.mp4

But trying to use this CloudFront distribution pointed at S3 doesn't: https://d3pk9p2ot72weq.cloudfront.net/CnkN0KNxpafGM2NzGBr5hDBP4Iv1ScN3.mp4

This vague error is logged:

[AVProVideo] Error: Loading failed.  File not found, codec not supported, video resolution too high or insufficient system resources.
UnityEngine.Debug:LogError(Object)
RenderHeads.Media.AVProVideo.MediaPlayer:UpdateErrors() (at Assets/AVProVideo/Scripts/Components/MediaPlayer.cs:2111)
RenderHeads.Media.AVProVideo.MediaPlayer:Update() (at Assets/AVProVideo/Scripts/Components/MediaPlayer.cs:1412)

The two links download the same file, so I don't know what would be different that's tripping up the video player

AndrewRH commented 4 years ago

The CloudFront URL with just http instead of https seems to work. There must be some issue with TLS/SSL....

jrjones commented 4 years ago

I've seen this behavior. You need to modify your CloudFront endpoint to not require any request headers OR pass the necessary request headers (which requires AVPro Video version 2.0.) Either technique should resolve the issue.

vpzomtrrfrt commented 4 years ago

What request headers would be required? Is it not passing Host?

jrjones commented 4 years ago

It depends on how you have things configured on the CloudFront side. If you're using the AWS default policies, it will be expecting an origin and access-control-request

image

Depending on your needs, you'll either need to send the necessary headers (which requires AVProVideo 2.0) or set up your own custom Cache Policy that doesn't require any headers be present (but don't do that if you're trying to restrict loading the videos to just your app!)

image

More info can be found here: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/add-origin-custom-headers.html

Note that I have no affiliation with Amazon or Renderheads, just trying to be helpful. 👍

vpzomtrrfrt commented 4 years ago

I wouldn't expect cache/origin policies affect required headers, but I don't really need headers passed anyway.

It still doesn't work even after changing the policies

MarkusNigrin commented 4 years ago

@jrjones @AndrewRH We'll experiment with this more and report back, that said, big thanks for being super helpful!!

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically closed because it has not had recent activity. If you wish to continue this issue, then please create a new issue as we do not monitor closed issues.