简体   繁体   English

HTML 5视频播放失败

[英]HTML 5 Video Playback Fails

Usable public link here: https://muwadev3.millikin.edu/muportal/public/streamingMedia.jsp?id=ab7cfb20f103a44a49d14244ae0a3f2f 此处可用的公共链接: https : //muwadev3.millikin.edu/muportal/public/streamingMedia.jsp? id =ab7cfb20f103a44a49d14244ae0a3f2f

The HTML elements are dynamically generated by the JSP code, and I've modified its output a number of times to try different things. HTML元素是由JSP代码动态生成的,我已经多次修改了其输出以尝试其他操作。 It should be similar to the following: 它应类似于以下内容:

<video id="viewer" width="320" height="240" controls preload>
    <source id="mp4Src" src="https://muwadev3.millikin.edu/muportal/secure/pages/features/StreamingMedia/index.jsp?f=ab7cfb20f103a44a49d14244ae0a3f2f.mp4" type="video/mp4">
    <source id="webmSrc" src="https://muwadev3.millikin.edu/muportal/secure/pages/features/StreamingMedia/index.jsp?f=ab7cfb20f103a44a49d14244ae0a3f2f.mp4" type="video/webm">
    <source id="oggSrc" src="https://muwadev3.millikin.edu/muportal/secure/pages/features/StreamingMedia/index.jsp?f=ab7cfb20f103a44a49d14244ae0a3f2f.mp4" type="video/ogg">

For some time, I've been working on building what amounts to a cross-device video playback server. 一段时间以来,我一直在努力构建相当于跨设备视频播放服务器的服务器。 I'm working within a Tomcat/JSP environment, which handles uploading the user's file, converts the file to mp4/webm/ogg behind the scenes, and should make the video file available on the viewer page when it's finished converting. 我正在Tomcat / JSP环境中工作,该环境可处理上载用户的文件,将文件转换为幕后的mp4 / webm / ogg,并应在完成转换后在查看器页面上提供视频文件。

That all works well (finally!) after some playing around and building. 经过一番游戏和构建后,一切正常(最终!)。 However, my issue is with the playback of the video tag. 但是,我的问题是视频标签的播放。 My intended behavior is to load a video tag with separate source tags, each containing a reference to one of the file types. 我的预期行为是加载带有单独源标签的视频标签,每个源标签都包含对一种文件类型的引用。 After perusing "Dive Into HTML5" and various other resources, I determined that getting those formats should cover all of the major browsers. 在仔细阅读了“ Dive Into HTML5”和其他各种资源后,我确定获取这些格式应涵盖所有主要的浏览器。 I wanted to provide both download and viewing capability for users, so they are made directly available by a separate page (which works perfectly) which immediately begins downloading the file. 我想为用户提供下载和查看功能,因此可以通过一个单独的页面直接使它们可用(该页面运行良好),该页面立即开始下载文件。 The viewing page is sourced from this download page, and the link between them seems to be perfect, always returning a 200 status when examining the requests on the page. 查看页面来自此下载页面,它们之间的链接似乎很完美,在检查页面上的请求时始终返回200状态。

Despite the indications of the reference material, the only file that plays between Firefox and Chrome is the ogg version of the file-- whereas I expected webm to be supported generally, using the other file types as fallbacks. 尽管有参考资料的指示,但在Firefox和Chrome之间播放的唯一文件是该文件的ogg版本-而我希望使用其他文件类型作为后备,一般都支持webm。 Chrome disabled the controls, and shows a black background, while Firefox has given both complaints of "No video with supported format and MIME type found" as well as "Video can't be played because the file is corrupt". Chrome禁用了控件,并显示了黑色背景,而Firefox则抱怨“找不到支持格式和MIME类型的视频”以及“由于文件损坏而无法播放视频”。

I know my files work properly, because retrieving them from the download page allows me to play them in VLC with no issue, and I can similarly play them directly from my host machine after using the same conversion. 我知道我的文件可以正常工作,因为从下载页面检索它们可以使我在VLC中播放它们而没有问题,并且在使用相同的转换后,我可以直接从主机上直接播放它们。

The only incongruity I can find is that the file utility (on Linux or Windows through GNUWin32) reports the webm file as "application/octet-stream", though the serving page correctly sets the header as video/webm. 我可以找到的唯一不一致之处是,尽管服务页面正确地将标头设置为video / webm,但文件实用程序(在Linux或Windows上通过GNUWin32)将webm文件报告为“ application / octet-stream”。

Typically I would use the Chrome Developer Tool and Firebug to get debugging information, but those are summarily unhelpful, failing to provide any information about why decoding failed, or why playback doesn't work. 通常,我会使用Chrome开发者工具和Firebug来获取调试信息,但是这些信息总体上是无济于事的,无法提供有关为何解码失败或为什么播放不起作用的任何信息。

I've made sure that the Tomcat server configuration includes each of the filetypes in its mime-type configuration, tried with and without the codecs declaration within the source tags, and also tried moving to a src="path/to/serving/page" attribute on the video tag (eliminating the source elements). 我已确保Tomcat服务器配置在其mime类型配置中包括每个文件类型,并尝试在源标签中使用和不使用编解码器声明,还尝试移动到src =“ path / to / serving / page视频标签上的“”属性(消除了源元素)。

This has been tested on the current Chrome build 42.0.2311.152 m, on Canary build 44.0.2402.0 canary (64-bit), Firefox ESR 31.5.3, and Firefox Developer Edition 39.0a2. 已在当前的Chrome版本42.0.2311.152 m,Canary版本44.0.2402.0 canary(64位),Firefox ESR 31.5.3和Firefox Developer Edition 39.0a2上进行了测试。

So-- is there a better way than plugging-and-chugging with different options to troubleshoot HTML 5 video playback? 因此,有没有比通过插拔选项来解决HTML 5视频播放更好的方法了? Am I missing anything obvious? 我有什么明显的遗漏吗?

Okay, so at issue was the video source/file download page, which was not working perfectly. 好的,问题在于视频源/文件下载页面,该页面无法正常运行。 Examining the video files with Notepad++ or vi showed that the downloaded file contained two blank lines before the rest of the data, which was identical to the contents of a similarly-encoded file from my local machine. 使用Notepad ++或vi检查视频文件后发现,下载的文件在其余数据之前包含两个空行,这与本地计算机上类似编码文件的内容相同。

The source page was a JSP along the lines of 源页面是一个类似以下内容的JSP:

<% //set imports %>
<% //set content headers %>
<% //send file with FileInputStream reading from hard drive %>

Each of the JSP output blocks included a carriage return, which outputted two blank lines before also outputting the contents of the encoded file. 每个JSP输出块都包含一个回车符,该回车符输出两个空行,然后再输出编码文件的内容。 One way to fix this is to smear the tags together like so 解决此问题的一种方法是像这样将标签涂抹在一起

<% //set imports
%><% //set content headers
%><% //output file%>

This can also be accomplished with the following: 这也可以通过以下方式完成:

<%@ page trimDirectiveWhitespaces="true" %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM