Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to add video uploading, encoding and streaming functionality to my Rails app?

What is the best way to add video uploading, encoding and streaming functionality to my Rails app ?

I'm thinking about a mix as : Rails app + Video Online Encoder + Amazon S3. What do you think ?

For the Video Online Encoder (VOE), which one is the easier to use with Rails : heywatch, panvidea, encoding.com, pandastream, ... ?

By the way, the application will allow users to play streamed videos with dynamic Texts, Schemas and Sounds added to them at the run time. There's an example :

  1. in rails app (backoffice or frontoffice) : Video upload (.mov, .avi, ...)
  2. VOE : video encoding in FLV format + storage in Amazon S3
  3. in rails app, backoffice : in a home-made Flash application, "add" to the video a Text and a Schemas showed after 1 minute for example (informations stored in the Rails app DB).
  4. in rails app, frontoffice : play the streamed video from Amazon S3 (+Cloudfront) in a home-made Flash player which show dynamicaly the Text and the Schema over the video after 1 minute of playing.

The part I really don't understand is the FLV video Stream. I was thinking that Cloudfront could do that.

I hope I'm clear enough ;-)

Thank you all for your answers !

like image 771
fro_oo Avatar asked Oct 11 '10 15:10

fro_oo


2 Answers

Disclaimer: I am a co-founder for transloadit.com.

I would discourage you from rolling your own solution. The link alexy13 posted will certainly get you an application that can receive user videos and encode them. However, you'll end up with a few limitations:

  • Resized videos will be distorted unless their aspect ratio is 4:3. To avoid that you need to sniff their dimension before the conversion and then apply a set of padding -vfilters to ffmpeg. Sniffing the dimension correctly will require a cocktail of at least 2 command lines tools (ffmpeg itself and exiftool) + a bunch of crazy code to deal with display aspect ratios that differ from the pixel aspect ratios.
  • Not all videos will convert. Sometimes you need to do additional sniffing on the video content and set some custom flags, otherwise you'll receive an error. Granted, 95% of all videos will probably work - but getting those last 5% is hard.
  • You will need an additional web server that does the video encoding, otherwise your site will be very sluggish while a video is being encoded. You can work around this by using the nice command to limit the CPU resources used by ffmpeg, but that will result in significantly longer encoding times.

This is a short list of problems, but generally you are ~100 hours away from having a system that runs without hickups and can deal with some load.

So I would encourage you to re-consider going with a service. Our competitors are quite nice, but of course I'd also be very happy if you would check out our service (transloadit.com) or shoot me an email at [email protected] if you have any questions.

There is also a Rails3 sample application for using transloadit with paperclip and S3:

http://github.com/joerichsen/transloadit-paperclip-example

--fg

like image 101
Felix Geisendörfer Avatar answered Nov 04 '22 17:11

Felix Geisendörfer


Zencoder looks cool and it probably has the API support you want. Use flash for the player I'm guessing? You will need FMS or Red5 for that. Here is a link to a really simple example that transcodes something stored in S3 for you, in Ruby of course!: http://zencoder.com/docs/integration-libraries/#library

like image 28
Preston Marshall Avatar answered Nov 04 '22 19:11

Preston Marshall