Ask A Question


You’re not receiving notifications from this thread.

Live Stream Video w/ Rails

Wali Chaudhary asked in Tips

Hey Chris could you do a video on live streaming video with ActionCable or integrating it with an gem? Thanks!


I don't know too much about it, but most of that won't be going through Rails or ActionCable. You want to be sending raw data over the wire, so you wouldn't be using WebSockets or Rails for that. WebRTC is designed for this, but Javascript in the browser so it lives outside of Rails / ActionCable.

Really if you want to do live streaming, I'd use a service like or for powering it.

I haven't done this before, so I can't relaly make a good screencast on it for you just yet. At some point I'd like to, but it's a complex topic so it'll probably take a while when I do get around to diving in.


Understood, thanks for the tips! I was just wondering about how the process itself works and if it could be done through Rails since I don't know much live video either. From what I've looked at, there must be some sort of flash implementation, javascript on the browser, and HTTP streaming.


I don't think you need Flash for anything these days. Also keep in mind that HTTP streaming can be used to describe streaming HTTP responses, not necessarily video. For example, you could use HTTP streaming to send realtime updates for a chatroom (before websockets were the better solution). HLS is similar to MPEG-DASH in that it's a video streaming protocol that uses HTTP. Kind of confusing stuff.

Then there's all this WebRTC stuff that's very similar, but another rabbit hole to understand. Apple doesn't support any of the WebRTC things yet, so you have workarounds for that as well I believe.

I feel like it's gonna take a lot of reading to get my head wrapped around all this, but it's some really neat stuff. I'm super fresh to all this stuff, so my descriptions of it could be way off as well. :)


live streaming would be an interesting feature for my latest mobile app with the coming of 5G to many countries, it may be the future for many mobile apps.

I found many apis services offering live streaming, very easy to implement for incredible prices.
Some of this services are not available wordwide, for example Indonesia banned Vimeo and Tokbox.

This is the result of my research:

390$ per month for 5 hours

165$ per month for 2.000 GB Bandwith

0.004$ per participant per minute

Considering most of the apps do not become successfull, I may consider building the feature very quickly with twillio and react native, support it until it is not too expensive.

I could support up to 20 live streamings from 20 different locations, assisted from 4 users on average for 3 minutes length, just long enough so that users can check the weather/surf conditions.

Cost per minute 0.004$ * 20 video streams * 3 minutes length * 4 users = 0,96 $ per day.
30 $ per month on average with Twillio. You just need to make sure the user is streaming decent content and for a short period of time.

I did work on a video/live streaming project in the past, but I did not work on the RTMP data flow responsible for the live streaming.

Some of the tools I used were OpenSource, for example the vidibus/vidibus-recording gem should allow you to set up the rtmp streaming.

As described in the vidibus-recording gem, creating a live stream should as easy as running recording.start, where recording is an instance of your MyCustomRecording class (but I believe it's much more complex then that..)

class MyCustomRecording
  include Mongoid::Document
  include Vidibus::Recording::Mongoid

but I don't think is no easy thing to set up, I don't even have an idea of what you have to use, HLS, RTMP or WebRTC.

I believe the issue is not only setting up the video stream data flow between the live streaming mobile source and the server, but distributing the live streaming via cdn to make sure the video is accessible worldwide

seems twillio is the best option for me right now to deliver this feature quickly hopefully getting on the 5G wave in advance. I believe the introduction of new technologies will change the way Mobile devices are being used and create opportunities for new applications streaming on 5G.

The main question is now how much will it cost (time + servers cost) to migrate from Twillio to my own Ruby on Rails infrastructure for live streaming, as you can not scale an application at $0.01 x User / Minute.

on my way around the web I found also post, which uses a library rvideo

I'm asking the same question to André Pankratz owner of the vidibus open source project.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,969+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.