问题
I am trying to play a .h264 file on my website(A file with .h264 suffix, not .mp4!) Is there any way I can do this? The html tag doesn't seem to support it.
The website is running on a Raspberry pi, and it impossible to convert them automatically to mp4, because it will crash the backend. The videos are generated by a camera mounted on the raspberry pi.
html:
% if loaded_video is not None:
<video width="720" height="480" controls>
<source src="/movies/{{loaded_video.name}}" type="video/mp4" />
Your browser does not support the video tag.
</video>
Even when loading the video url directly, all I see is gibberish.
Can anyone help me? Thanks
回答1:
You can use the broadway emscripten javascript h264 decoder port to display h264 files in a browser. If you seek for real-time, you'll also need a websocket server/relay and make sure you are sending properly chunked NAL (h264 frames). I wrote a project for this very precise purpose (live stream from rpi cam to a browser using raw h264), see "github h264-live-player"
回答2:
A web browser will not play a raw .264 file. It must be put into a container such as mp4. If it is live video, many moderns browsers can use media source extensions to play a fragmented mp4 (m4s)
it impossible to convert them automatically to mp4, because it will crash the backend.
Then this is a bug. Fix the crash.
@sjagr
Yes, h.264 is not royalty free, but wrapping it an an mp4 does not remove that restriction. *.264 is just h.264 NAULs saved in annexB format. It is part of the h.264 specification.
来源:https://stackoverflow.com/questions/28076088/play-h264-files-webplayer