Play .h264 files webplayer

喜夏-厌秋 提交于 2019-12-25 04:28:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!