【问题标题】:Ruby and Webrick Video StreamingRuby 和 Webrick 视频流
【发布时间】:2012-02-07 19:47:45
【问题描述】:

我正在开发一个将流式传输视频数据库的网络应用程序,但我在使用 Webbrick 和 HTML5 视频时遇到了困难。我正在使用一个简单的 HTML 标签,但视频似乎不会出现。有什么帮助吗? (顺便说一句,文件路径是正确的)。

这是我的 HTML 代码:

<div id="lr_video">

<%= video_tag (["videos/final_video.mp4", "final_video.ogg", "movie.webm"], :size => "320x240", :controls => true, :autobuffer => true) %>

</div>

我的 Ruby 代码:

在 config/application.rb 中:

...
..
    #HTML5 Video !!!
    config.assets.paths << "#{Rails.root}/public/assets/videos"

..
...

现在我使用 Webrick 作为生产服务器,我将视频放在“/public/assets/videos”下,但视频没有显示

有什么帮助吗?

【问题讨论】:

  • 尝试 "320x240", :controls => true, :autobuffer => true) %>
  • 尝试 "320x240", :controls => true, :autobuffer => 真) %>

标签: ruby html webrick


【解决方案1】:

您发送的视频可能带有错误的 Content-Type 标头。

检查输出

curl -I http://localhost:3000/assets/final_video.mp4 | grep Content-Type

应该说

Content-Type: video/mp4

如果没有,那么您应该修复内容类型标头的生成。

【讨论】:

  • 您需要调整该行以适应您的设置;类似'curl -I devserver:8012/TheSite/videos/final_video.mp4'。
  • 好的,我试过了,'curl -I 0.0.0.0:3000/public/assets/videos/final_video.mp4' 并且 webrick 给我返回了这个:'ActionController::RoutingError (No route matches [GET] "/public/assets/videos/final_video.mp4 "):' 既然我在上面定义了,怎么会这样?
  • URI 路径是/assets/final_video.mp4/assets/videos/final_video.mp4,而不是/public/videos/...。所以试试http://0.0.0.0:3000/assets/final_video.mp4
  • 太好了,我现在得到了“Content-Type: video/mp4”,但视频不会再显示了。
  • 这方面有什么进展吗?有完全相同的问题,尝试了一切,没有运气:(
猜你喜欢
  • 2011-05-08
  • 1970-01-01
  • 2012-05-01
  • 2011-06-08
  • 1970-01-01
  • 2012-04-29
  • 1970-01-01
  • 2021-10-03
  • 1970-01-01
相关资源
最近更新 更多