Streaming Live with Red5 Media Server

Are you excited about Google Hangouts? Would you be even more excited to implement live streaming yourself?
Today we will take a look under the hood of broadcasting and even start implementing our own mini hangout.
A bit of theory
Live streaming is based on RTMP protocol. It is able to transfer video, audio and generally any data in real-time over Internet between server and client.
The most popular combination for video/audio streaming is Adobe Flash Player as a client software and a proprietary Adobe Flash Media Server as a server software. Another option is Wowza Streaming solutions.
Luckily for us there is an open-source Red5 Media Server—the most popular if not the only one stable of all open-source media streaming servers. We will be leveraging Red5 to dive into RTMP world and the cutting edge streaming technologies.
Exploring Red5 Media Server
Download and install Red5 Media Server for your environment from here. Now it is time to implement a sweeping live stream between our two laptops.
Red5 comes with the set of demo applications (http://localhost:5080/demos/) that are very handy to base the development on. Demo applications can be installed via the Installer …
video audio
RailsConf 2012: What’s Next in Rails?
I tend to walk away from every RailsConf feeling that there was a trend for each conference. In 2009, I thought the trend was Passenger, in 2010, NoSQL and Rails 3 was all the rage, and in 2011, many of the talks were related to CoffeeScript and SASS. While there was some of these technical specifics at this conference, I felt that the overarching trend this year is that several folks that are extremely involved in Rails (DHH, Yehuda Katz, Aaron Patterson, etc.) are very passionately involved in the course correction needed to keep Rails relevent.
As I mentioned in my blog article on Day 1, DHH talked about progress. DHH focused on the limitations of progress (loss aversion) and how and why people move from curious to suspicious when working with technology. He didn’t delve into any of the Rails 4 details, but simply ended by sharing that Rails 4 will break and challenge things.
On Day 2, Aaron Patterson covered a discussion about what it means to incur technical debt, and how developers have different thresholds of how much technical debt is tolerated.

He talked about the types of refactoring needed to reduce technical debt. He ended his talk with a slide that said, “be …
conference rails
RailsConf 2012: Day Three
It’s Day 3 of RailsConf 2012 here in Austin Texas. Check out my posts from Day 1 and Day 2.
RailsConf 5k
To kick off the day, I ran the low-key RailsConf 5k along the lake here in Austin. I’m glad that this event was organized — I think it’s good to take a mental break from all the conference activities.
RubyRogues
This morning kicked off with a RubyRogues live session. The topic for today’s podcast was a discussion about what Rails developers care about and/or should care about. I thought that the answers apply to developers in general. Below are some of the topics covered in the talk.
-
- James focused on the point that experimentation is important and to perceive all code as experimental.
-
- Avdi’s main argument was a suggestion to practice deliberate and mindful coding. While he believes that there is a place for the “shut up and code” mentality in some projects depending on risk, it’s not acceptable to have this perspective when it comes to community sharing of knowledge.
- Avdi recommends that exercising introspection by reviewing your code and explaining it to someone else (how and why) will make you a better programmer and communicator. …
conference ruby rails
RailsConf 2012: Day Two
I’m here in Austin for Day 2 of RailsConf 2012. Here’s a quick run-down of a few talks I attended today. Read about a couple of sessions I attended on Day 1 here.
Let’s Make the Web Faster
One of the talks I attended on Day 2 was Let’s Make the Web Faster — tips from the trenches @ Google by Ilya Grigorik. Ilya works on the MTWF (make the web faster) team at Google; one of their goals is not only to make Google’s web applications faster, but also to make a bigger impact on web performance by developing and contributing to tools. I found a few main takeaways from Ilya’s talk:
-
Navigation Timing Spec: The navigation timing spec defining an interface for web applications to access timing information related to navigation and elements. You can look at this timing information by checking out the performance object in a console:
Example output of navigation timing spec data.
-
Site Speed Tools in Google Analytics: Google Analytics now has elements of the page speed broken down that allows you to compare page load times and examine what the bottlenecks in the system are. To get there, you go to Content => Site Speed => Page Timings in Google Analytics. You can also measure and …
conference performance ruby rails
Using CarrierWave without an ORM in Spree
I was recently adding some settings to Spree (an open source Ruby on Rails ecommerce framework) using Spree’s built-in preferences system and found myself needing to upload an image as part of the settings. Our application was already using CarrierWave to handle some other uploads and wanted to use it to handle the uploading for my current image as well. Since the only setting I was setting was the image and there would only ever be one image, I didn’t want to tie the setting to ActiveRecord. So I did some reading and found that you can tie a CarrierWave to a class without an ORM. The documentation on this is very sparse so I resorted to reading through the code to figure out how to get it working. After hours of playing with it I finally got it working. With the current movement in the Rails community to move more toward an Object Oriented approach to building applications, I’ve decided to document this here so that others will be able to quickly tie CarrierWave uploaders to their non-persisted classes.
The uploader I’ll be working on is to add a banner to the checkout process in Spree (0.60.x). The idea is to store the image url in Spree::Config (the general preferences mechanism …
ruby rails
RailsConf 2012: Day One
Today kicks off the official first day of RailsConf 2012, in Austin, Texas (yesterday RailsConf unofficially kicked off with Ignite Rails). This is my fourth RailsConf, and I’ve found that I get increasingly more out of each one as my time working with Rails has accumulated.
The morning started with a keynote by DHH. DHH talked about progress and keeping an interest in something because it continues to make progress. Initially, the Rails community had a negative reaction to progress like Ruby 1.9, Rails 3, the Asset Pipeline and CoffeeScript, but after the initial learning curve, the new tools and progress was appreciated by the community. DHH talked about how there have been many studies on what prevents people from progressing, and one of those causes is loss aversion, meaning that people hate losing or failing enough that it prevents them from advancing. To me, the point of his talk was to prepare everyone for Rails 4 and how it will challenge and break things. Rails 4 is admittedly not coming out anytime soon, so he didn’t touch on any specifics.
Using Backbone.js with Rails
One session talk I attended was Using Backbone.js with Rails by Sarah Mei of Pivotal Labs. Backbone is …
conference javascript rails
Byte-swap an entire file using perl
I recently needed to byte-swap an input file, and came up with an easy way with perl:
$ perl -0777ne 'print pack(q{V*},unpack(q{N*},$_))' inputfile > outputfile
This will byte-swap 4-byte sequences. If you need to byte-swap 2-byte sequences, you can just adjust the formats for pack/unpack to the lower-case version like so:
$ perl -0777ne 'print pack(q{v*},unpack(q{n*},$_))' inputfile > outputfile
(Of course there are more efficient ways to handle this, but for a quick and dirty job this may just be what you need.)
We use the -0777 option to ensure perl reads the input file in its entirety and doesn’t affect newlines, etc.
perl
Deconstructing an OO Blog Designs in Ruby 1.9
I’ve become interested in Avdi Grimm’s new book Object on Rails, however I found the code to be terse. Avdi is an expert Rubyist and he makes extensive use of Ruby 1.9 with minimal explanation. In all fairness, he lobbies you to buy Peter Cooper’s Ruby 1.9 Walkthrough. Instead of purchasing the videos, I wanted to try and deconstruct them myself.
In his first chapter featuring code, Mr. Grimm creates a Blog and Post class. For those of you who remember the original Rails blog demo, the two couldn’t look more different.
Blog#post_source
In an effort to encourage Rails developers to think about relationships between classes beyond ActiveRecord::Relation, he creates his own interface for defining how a Blog should interact with a “post source”.
# from http://objectsonrails.com/#sec-5-2
class Blog
# ...
attr_writer :post_source
private
def post_source
@post_source ||= Post.public_method(:new)
end
end
The code above defines the Blog class and makes available post_source= via the attr_writer method. Additionally, it defines the attribute reader as a private method. The idea being that a private method can be changed without breaking the class’s API. If we decide we want …
ruby