0
votes

I serve with code below a mp4 file:

import os
from starlette.responses import FileResponse
return FileResponse(
            filename_out,
            media_type="video/mp4",
            filename=os.path.basename(filename_out)
        )

In firefox, chrome and in android it works fine. Unfortunately it doesn't for the AVPlayer (used by the flutter video_player package) in IOS.

I found this thread iOS 10 AVPlayer will not stream video from URL with no extension and with video/mp4 as content type

However, the file extension is provided with the explicit filename and I'm confused about the header stuff. Has anybody similar experience and a solution?

Edit: In filename is e.g. video.mp4 after that with the test.client it looks like:

{'content-type': 'video/mp4', 'content-disposition': 'attachment; filename="video.mp4"', 
'content-length': '5909110', 'last-modified': 'Mon, 10 Feb 2020 21:23:10 GMT', 'etag': 'd4be0ee89866a2fdc6e2c2dc94c4bc21'} 

Attachment feels not right with/without it is a stream and works with common browser player and android but not in IOS. We use the flutter package video_player and _controller.value.initialized is always false with IOS, but true using a direct file from AWS not served by starlette:

 _controller = VideoPlayerController.network('urlWithMp4StreamOrAttachment',);

Thanks in advance, Christian

1
have you tried passing the content-type header and adding an extension to the filename_out variableHedde van der Heide
Thanks , but no luck see above.Christian
Does the video play in safari browser in a mac ? If it is not playing try using the inspect element and it will show you the exact error. If it is playing in mac safari then move onto iPhone Safari and check the same. It can give you some clue.Kautham Krishna
imgur.com/eyMAeZE looks like a problem with this range stuff. Changed the header, but still no sucess . {'content-type': 'video/mp4', 'content-range': 'bytes 0-1', 'accept-ranges': 'bytes', 'content-length': '5909110', 'last-modified': 'Mon, 10 Feb 2020 21:23:10 GMT', 'etag': 'd4be0ee89866a2fdc6e2c2dc94c4bc21'}Christian
You can always resort to serving these files over a proxy, like nginx (which is optimised for file serving)Hedde van der Heide

1 Answers

0
votes