This project is archived and is in readonly mode.

#3358 ✓stale
Kouhei Sutou

[PATCH] support Range and If-Range on send_file and send_data

Reported by Kouhei Sutou | October 9th, 2009 @ 07:16 AM

We can stream multimedia data (videos, audios and so on) by send_file and/or send_data.

In HTML5, we can use and tag to play videos and audios on browser.
Many modern browsers, Firefox, Safari, Google Chrome and so on, support them.

For example, you can see Ogg/Theora video on Firefox at:
http://commons.wikimedia.org/wiki/File:Firefox_3.1b1_pre_(native_Vi...

You will see a control bar which includes play/suspend button, progress bar and volume control at the bottom of video player.

The current Firefox Ogg/Theora video player implementation requires HTTP "Range" supported HTTP server to display total length at the right of progress bar. If a HTTP server doesn't support "Range", progress bar doesn't work. It always indicates the end.
NOTE: Movie can be played correctly even if progress bar doesn't show correct progress.

In Rails, we use send_file and/or send_data to stream movies and/or audios but Rails doesn't support "Range". So we can't play a movie streamed by Rails with correct progress.

Here is a sample Rails application:

% ruby .../edge-rails/railties/bin/rails sample
% cd sample
% ln -fs .../edge-rails vendor/rails
% script/generate controller Streaming index
% vim app/controllers/streaming_controller.rb
app/controllers/streaming_controller.rb:
  class StreamingController < ApplicationController
    def index
      send_file(Rails.root.join("sample.ogv"), :layout => false, :type => "video/ogg")
    end
  end
% wget -O sample.ogv 'http://upload.wikimedia.org/wikipedia/commons/7/79/Firefox_3.1b1_pre_%28native_Videounterst%C3%BCtzung%29.ogg'
% script/server &
% vim /tmp/video.html
/tmp/video.html:
  <html>
    <body>
      <video src="http://localhost:3000/streaming/" controls="true" />
    </body>
 </html>
% firefox /tmp/video.html

You play the movie and then you will notice that progress bar is always filled and total length just indicates played time.

The attached patch supports HTTP "Range" and "If-Range". You will get correct progress with patched Rails.

Comments and changes to this ticket

  • Sidney

    Sidney April 11th, 2010 @ 11:11 PM

    Problem verified Rails 3.0.0 beta2

  • Sidney

    Sidney April 12th, 2010 @ 02:07 AM

    • Assigned user set to “Ryan Bigg”
  • Ryan Bigg

    Ryan Bigg April 12th, 2010 @ 02:11 AM

    • Assigned user cleared.

    I am not responsible for applying patches, only marking tickets as invalid / whatever in the system. I will, however, take a look at this patch and provide feedback later tonight.

  • Yehuda Katz (wycats)

    Yehuda Katz (wycats) April 13th, 2010 @ 05:25 AM

    • State changed from “new” to “incomplete”

    This patch no longer applies due to the change to using a SendFile middleware

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:43 PM

    • State changed from “incomplete” to “open”
    • Importance changed from “” to “”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:43 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages