Search Unity

Bug When running url imported from aws s3 on the video player, I get errors.

Discussion in 'Audio & Video' started by mayquartet, Feb 20, 2024.

  1. mayquartet


    Dec 7, 2021
    When running url imported from awss3 on the video player, I get errors like "AVFoundationVideoMedia error while reading" and "VideoPlayer cannot play url".

    I'm using the following code to get url of the video in aws s3.

    Code (CSharp):
    1. public async Task<string> GetObjectUrl(AWSCredentials credentials, string keyName)
    2.     {
    3.         using (var client = new AmazonS3Client(credentials, RegionEndpoint.APNortheast2))
    4.         {
    5.             try
    6.             {
    7.                 GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
    8.                 {
    9.                     BucketName = BUCKET_NAME,
    10.                     Key = keyName,
    11.                     Expires = DateTime.Now.AddMinutes(10)
    12.                 };
    14.                 return client.GetPreSignedURL(request);
    15.             }
    16.             catch (AmazonS3Exception e)
    17.             {
    18.                 // If the bucket or the object do not exist
    19.                 Debug.Log($"Error: '{e.Message}'");
    20.                 return null;
    21.             }
    22.         }
    23.     }
    This code receives url in the form of "https://~?X-Amz-Expires=600&X-Amz-Security-Token=~".

    But if I give this url to url in video player, "AVFoundationVideoMedia error while reading 'url' Context: AVFoundationVideoMedia::OpenForRead found no video tracks
    Error details: <Empty>" error and "VideoPlayer cannot play url: 'url' Cannot read file." Error appears.

    I originally used the version of unity 2021.3.8f1, which I had no problem with when using it, but this happened after upgrading the version to unity 2022.3.11f1.

    I need to stream a video and I don't want to download and play the video through Unity WebRequest.

    Someone says that from the 2022 version onwards, there must be a clear URL ending in .mp4, but how do you proceed with executing a video player through a URL when there is an https and an authentication token query in one URL?
  2. unity_DDA77FA296C3E6002ABD


    Jan 30, 2023
    This happens to us as well. Hoping this gets fixed!
    Rafael_CS likes this.
  3. Rafael_CS


    Sep 16, 2013
    Same problem here... seems impossible to play a Video with presigned s3 url on Unity 2022.3.18f...

    Makes zero sense as its working on previous versions.
    Last edited: Mar 13, 2024