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

Unable to perform the direct video streaming using get_presigned_url() when the object placed inside the folder #1057

Closed
Udayaprasad opened this issue Jan 11, 2021 · 15 comments

Comments

@Udayaprasad
Copy link

We are unable to stream the video object which is stored inside the folder, but I am able to download the video object and play it from my local computer.

bucket_name = "mybucket"
file_path = "/Users/name/Downloads/video1.mp4"
object_name = "videos/video1.mp4"

client.fput_object(bucket_name, object_name, file_path)

url = client.get_presigned_url(
        "GET",
        bucket_name,
        object_name)

print(url)

if the object_name is just video1.mp4 then I am able to play the video url from the following link otherwise, if we place the object like ('videos/video1.mp4'), then it is not playing

https://cuttopoint.com/player.html

@balamurugana
Copy link
Member

What error are you getting?

Please reopen the issue by sharing code how you generated presigned url.

@Udayaprasad
Copy link
Author

Udayaprasad commented Jan 11, 2021

I have shared the code in my first message. Here the problem is presigned URL generated by get_presigned_url() is not able to stream the video file if we stored it in a folder (object_name = "videos/video1.mp4"). I used to test/play the video URL using the following link.

https://cuttopoint.com/player.html

bucket_name = "mybucket"
file_path = "/Users/name/Downloads/video1.mp4"
object_name = "videos/video1.mp4"

client.fput_object(bucket_name, object_name, file_path)

url = client.get_presigned_url(
        "GET",
        bucket_name,
        object_name)

Note:- Presigned URL generated by get_presigned_url() is working if I store the video file without folder specification (object_name = "video1.mp4")

This is a high priority for us. Since it is not working when we store the video object within the folders... we are able to download and play it on my local computer but, not in the UI (not playable as a stream).

When we store the video object within the bucket (not in any folder), then it is playing from UI.

Thanks,
Uday

@balamurugana
Copy link
Member

balamurugana commented Jan 11, 2021

If I understand correctly, you are able to download the object using presigned url, but it is not playable as a stream. Please share what error you are getting.

Also you would need check whether your mp4 file is stream friendly.

@harshavardhana
Copy link
Member

When you are uploading the object set proper content-type such that browser can auto-stream it @Udayaprasad or make sure to add response-content-type header in presigned URL to add relevant content-type in the presigned response.

@Udayaprasad
Copy link
Author

If I understand correctly, you are able to download the object using presigned url, but it is not playable as a stream. Please share what error you are getting.

Also you would need check whether your mp4 file is stream friendly.

@balamurugana I have updated my previous question. No error is displaying while we trying to play the video in the UI. It just not happening.
We have observed this behavior only when we store the video within some folder inside the bucket, but when we store it directly (without storing it inside a folder), then the video is playing properly in the UI.

@Udayaprasad
Copy link
Author

@balamurugana your video will stream, because you had put within the bucket (without storing inside bucket/folder/2020.mp4).

In you case the bucket name is "myvideos" and object name is 2020.mp4.
Try storing the video using below configuration.

bucket_name = "myvideos"
object_name = "samplevideos/2020.mp4"

Then get the presigned_url from minIO and play it in below URL. It will not play.

https://cuttopoint.com/player.html

@balamurugana
Copy link
Member

@Udayaprasad You are completely wrong. In the URL

Service: https://play.min.io/
Bucket: issue-1057
Object /myvideos/2020.mp4
Query parameters: X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=Q3AM3UQ867SPQQA43P2F%2F20210112%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210112T062815Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=99bfdd6afe43ba3f98436459006ff547ae83f864ec71cb72065d059355bcfac1

@Udayaprasad
Copy link
Author

Udayaprasad commented Jan 12, 2021

@balamurugana Got it. I am wrong here. Below is my complete code. Can you suggest how to generate the presigned_url properly so that it will be playable from the UI?

import urllib3

client = Minio(
    "SERVER:PORT",
    access_key="ACCESS_KEY",
    secret_key="SECRET_KEY",
    secure=True,
    http_client=urllib3.ProxyManager(
        "http://PROXYSERVER:PROXYPORT/",
        timeout=urllib3.Timeout.DEFAULT_TIMEOUT,
        retries=urllib3.Retry(
            total=5,
            backoff_factor=0.2,
            status_forcelist=[500, 502, 503, 504],
        ),
    ),
)


bucket_name = "sample-bucket"
file_path = "/Users/uname/Downloads/video.mp4"
object_name = "videos/video1.mp4"


file_obj.fput_object(bucket_name, object_name,
                                       file_path)

objects = client.list_objects(
    bucket_name, recursive=True, start_after="videos/",
)

for obj in objects:
    logger.info(obj.object_name)

url = client.get_presigned_url(
    "GET",
    bucket_name,
    object_name,
    expires=timedelta(days=7)
)

Note:- I am using docker MinIO setup.
Version: image: minio/minio:RELEASE.2020-12-23T02-24-12Z

@balamurugana
Copy link
Member

@Udayaprasad there is nothing special code to generate presigned url. The way you use to generate presigned url is correct. Just use play.min.io and validate everything.

@balamurugana
Copy link
Member

@Udayaprasad Open an issue in minio/minio with all details

@Udayaprasad
Copy link
Author

@balamurugana Yes raised minio/minio#11263

@raammishra
Copy link

@Udayaprasad Any luck playing the video??

@shkr
Copy link

shkr commented May 8, 2022

Any instructions on how to play video from minio ?

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

No branches or pull requests

5 participants