MP4 video not playing on Firefox in the <video> tag, plays if directly opened

删除回忆录丶 提交于 2019-12-06 08:30:26

Firefox tells you the problem in the error message in the console. It's 3GP format rather than MP4:

HTTP "Content-Type" of "video/3gpp" is not supported. Load of media resource ...recording.mp4 failed.

You can corroborate that with ffprobe. I've truncated the output.

  Metadata:
    major_brand     : isom
    minor_version   : 0
    compatible_brands: isom3gp4
    creation_time   : 2015-12-18 14:54:58
    location        : +44.4413+026.0771/
    location-eng    : +44.4413+026.0771/
  Duration: 00:00:08.22, start: 0.000000, bitrate: 17235 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17106 kb/s, 30.05 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2015-12-18 14:54:58
      handler_name    : VideoHandle
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 123 kb/s (default)
    Metadata:
      creation_time   : 2015-12-18 14:54:58
      handler_name    : SoundHandle

The important part is compatible_brands: isom3gp4. 3GP is a similar file format to MP4 in that they are both based on the ISO base media format but they're not the same. Browsers and applications that can play both might not mind that the file isn't the format specified in the content type header.

I think Firefox may have been able to play these files until version 41, based on other mentions I've seen of the same error with files which apparently were playing before it updated. So I'd bet that's the change rather than something on your server.

Transmuxing the video and audio into an MP4 container results in a playable file (albeit the high bitrate and high h.264 profile aren't ideal for web delivery, but that's a different story).

ffmpeg -i recording.mp4 -codec copy output.mp4

By the way, I wouldn't take what a browser plays when you open the file directly as representative of what will in a video element in the same browser. They often behave differently.

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