简体   繁体   English

HTML5视频元素无法播放没有音频编解码器的.mp4

[英]HTML5 Video element not playing an .mp4 with no audio codec

I'm trying to upload a video to a Angular app using ng-file-upload . 我正在尝试使用ng-file-upload将视频上传到Angular应用程序。 All works fine until I try and upload a .mp4 video with no audio codec. 一切正常,直到我尝试上传没有音频编解码器的.mp4视频。 The video element shows, it shows the correct duration in the control panel, it just doesn't play. 视频元素显示,它在控制面板中显示正确的播放时间,只是不播放。 Clicking play does nothing, the first frame is not shown. 单击播放没有任何作用,不会显示第一帧。

If I upload any other .mp4 that contains audio the video plays without error. 如果我上载任何其他包含音频的.mp4,视频将正常播放。

Below is the information I can see about the file that is failing, as you can see only the video codec is listed for this file. 以下是我可以看到的有关失败文件的信息,因为您只能看到该文件仅列出了视频编解码器。

在此处输入图片说明

Here is the 'more info' for another .mp4 file that has audio, this one uploads perfectly fine and plays in the HTML5 video element with no errors. 这是另一个具有音频的.mp4文件的“更多信息”,该文件可以完美上传并且可以正确播放HTML5视频元素。

在此处输入图片说明

As you can see, the video that works states the audio codec as AAC, which is expected for .mp4, and shows Audio Channels "2", i'm unsure of the purpose of 'Audio Channels' is in all honesty. 如您所见,可以正常工作的视频将音频编解码器设置为AAC(适用于.mp4),并显示音频通道“ 2”,我不确定“音频通道”的用途是真的。

I've been debugging this thing all day and the only difference in files that I can see is in the above images. 我整天都在调试该东西,而我可以看到的文件唯一的区别就是上面的图像。

Should HTML5 video player play a .mp4 video without any audio codec listed? HTML5视频播放器应播放没有列出任何音频编解码器的.mp4视频吗?

What leads me to think the audio has a role to play in this is w3schools description of an Mpeg-4 file: w3schools对Mpeg-4文件的描述使我认为音频在其中起着作用:

MP4 = MPEG 4 files with H264 video codec and AAC audio codec MP4 =带有H264视频编解码器和AAC音频编解码器的MPEG 4文件

Has anyone had this issue before? 有人遇到过这个问题吗?

Edit 编辑

After adding a listener to the error event on the video I can see that I get a MediaError object with code 3 as a value, so this is a decoding issue I can see . 在视频中添加一个侦听错误事件后,我可以看到我与代码3的值MediaError对象,所以这是一个解码的问题,我可以看到

Screenshot below 下面的屏幕截图

在此处输入图片说明

Further edit 进一步编辑

I've now debugged this as far as going into Chromes 'media-internals' logs. 现在,我已经调试了Chrome浏览器的“媒体内部”日志。 The error Chrome is encountering is now confirmed to be because of the missing audio, see the screenshot below: 现在确认Chrome遇到错误是由于缺少音频,请参见以下屏幕截图:

在此处输入图片说明

Unsure why an error isn't clearly thrown because of this. 不确定为什么因此没有明确抛出错误。 Is this the end of the line, it's weird because if I upload the video to Facebook it uploads just fine. 这是行的结尾吗,这很奇怪,因为如果我将视频上传到Facebook,它就可以上传。

I'd advice you to check if the .mp4 file is properly converted. 我建议您检查.mp4文件是否正确转换。 I've already checked it on my computer and it should be normally played - just video with no audio (Ubuntu 14.04, Chrome 51.0.2704.106). 我已经在计算机上检查了它,应该可以正常播放-只是视频而没有音频(Ubuntu 14.04,Chrome 51.0.2704.106)。

Use ffmpeg to check the available media tracks: 使用ffmpeg检查可用的媒体轨道:

ffmpeg -i input_file.mp4

Then try to use the source with audio track and convert it to one without an audio. 然后尝试使用带有音轨的源并将其转换为无音频的源。 This command will remove all audio tracks: 此命令将删除所有音轨:

ffmpeg -i input_file.mp4 -vcodec copy -an output_file.mp4

HTML5 specification doesn't tell what should happen when we don't have a proper codec for one of the media tracks. 当我们没有适当的编解码器用于媒体轨道之一时,HTML5规范无法说明应该怎么办。 Just for reference - HTML5 仅供参考-HTML5

It's always a good idea to check the playback on any other player, VLC is a good one for reference. 检查其他任何播放器的播放总是一个好主意,VLC是一个很好的参考。

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

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