HTML 5 video (ogv) and MIME types

与世无争的帅哥 提交于 2020-01-04 06:41:25

问题


I can't figure out the following problem:

I use HTML 5 video on my web site. For crossbrowser support, I keep video in "mov" and "ogv" formats, so that Firefox can play it.

In ./config/initializers/mime_types.rb I have the following code:

Rack::Mime::MIME_TYPES.merge!({
  ".ogg"     => "application/ogg",
  ".ogx"     => "application/ogg",
  ".ogv"     => "video/ogg",
  ".oga"     => "audio/ogg",
  ".mp4"     => "video/mp4",
  ".m4v"     => "video/mp4",
  ".mp3"     => "audio/mpeg",
  ".m4a"     => "audio/mpeg"
})

It works on my local machine, but won't on a production server.

I've tried many ways to make this work:

Rails: MIME type issues with .m4v files

Setting Mime Type for .ogv files in Rails Development Environment

Make OGG Video work with Rails

None of these helped me, and I'm completely stuck.


回答1:


On the production server or machine, if you are using a web server such as Nginx or Apache you need to declare those mime types within the respective config files for the server to rexognise it. Has this been done?




回答2:


I observed a strange behavior where some of the ogv files gave a application/ogg mime type rather than video/ogg. Please check the mime type of the file you are uploading very carefully.



来源:https://stackoverflow.com/questions/4204602/html-5-video-ogv-and-mime-types

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