Jan Kaifer
Jan Kaifer

Reputation: 704

My Flask app is not properly serving videos on raspberry, but normally on my laptop

I've got flask server for streaming movies. Everything works fine while server runs on normal computer (laptop with arch) but when raspberry serves the video (using flask's static folder) I'm unable to skip (forced to watch sequentially), so when I close browser in middle of movie I have to watch it all over again, that's pretty annoying. I'm using just <video> tag with <source> linked to static .mp4 file served by flask.

I don't know if this could be cause by just fact that raspberry cannot stream full HD video properly, but when I'm watching sequentially I have no issues.

Whole project is on GitHub so If you want to look at the code:

"movie player" template is here

code that generates that "movie player" html is here

Thanks for any suggestions.

PS: I have got rapsberry 3 model B and movies are stored on 4TB NTFS HDD.

EDIT: Tried 8GB Fat32 USB stick and still same problem.

Requested minimal working example:

HTML - part of video_player_main.html

<video controls="controls" autoplay="autoplay" style="margin: auto; display: block;">
    <source src="{{ url_for("static", filename="movies/%s" % filename) }}" type="video/mp4">
    Get better browser!!!
</video>

Flask generating website

@video_player.route("/play/<path:movie>")
def play(movie):
    return render_template("video_player_main.html", filename=movie)

HDD with movies is mounted on ./static/movies/

Upvotes: 1

Views: 755

Answers (1)

payne
payne

Reputation: 14177

What MIME type is being returned by the Flask server for the static movie files in each case? Use the wget command (or something similar) to see what's being returned.

You are likely getting different MIME types on the different systems, which is causing your browser to handle the video streams slightly differently. Note that the browser doesn't care about the file extension; it goes by the MIME type returned by the server.

Flask uses the mimetype Python library to figure out what MIME type to use, based on the file extension. It uses a bunch of local files to make guesses, see: https://github.com/python/cpython/blob/2.7/Lib/mimetypes.py#L40

Upvotes: 1

Related Questions