Question about uploaded files in ruby - ruby-on-rails

When uploading a file I know I can access its properties but is it always the same or it varies? I mean, I am writing an app for myself where I can upload songs or videos to my server to watch later, and I'd like to populate the info about said files automatically as much as possible so I was wondering if it's possible to get things like length, quality, name, artists, artwork, or pick a first image like youtube does for its videos?
I'm fairly new to ruby (using rails) so I am unsure as to where to find this or if it's even possible

You can do that using FFMpeg (read the license first).
FFMpeg gives you everything you were asking about and some more.
it's very powerful.
For mp3, check out mp3-info, I haven't used it before but looks promising...

Related

Select local video, shorten length, then upload video in a rails application

I need any idea to do this with javascript in ruby on rails application.
I want the user to upload a video, then the file has to be shortened from either start or finish. The purpose of that is to make the video smaller in size.
Then the video should be uploaded to server.
I have looked at https://github.com/danielcebrian/rangeslider-videojs but maybe someone knows a better solution
For uploading I have looked at FFmpeg, for cropping the video server side.
First off I should point out that if the editing process needs user interaction in the browser then this is not a simple problem, it's pretty complex and there's a lot of ways you could do it.
Uploading is a pretty easy part nowadays, as the built in rails ActiveStorage module works pretty well.
Now, if you don't need to edit videos in the browser, just want to clip them down to a specific size, then that is not too bad. You can indeed just have rails call ffmpeg with system. The -ss option is the flag you need, it's for cropping video.
If you do need user editing of videos in browser then you'll need to investigate a good JavaScript plugin for this, because it's not something that is going to be quick to write by hand.

Creating Videos in a Ruby On Rails app?

I'm looking for a way of taking an audio asset and jpeg from my app that are both stored on Amazon S3 and merge them into a video that's format will be accepted at Youtube. Basically, the song with static album artwork for the duration.
I've seen this post that refers to Ming-Ruby Create videos programatically? but i'm wondering if the Gem is active and maintained or if anyone else has experience of doing something similar and can offer some tips or alternative approaches?
You could look into using ffmpeg. Here's some examples of creating a video slideshow of images. http://ffmpeg.org/trac/ffmpeg/wiki/Create%20a%20video%20slideshow%20from%20images I'm sure you could find info out there on how to also add in audio. At that point you should just need to find a ffmpeg gem to wrap the calls you need to make or work directly with it via system calls (be careful with that though).

Progressive Video Download on iOS

I am trying to implement Progressive Downloading of a video in my iOS application that can be played through AVPlayer. I have already implemented a downloader module that can download the files to the iPad. However, I have discovered I cannot play a file that is still being written to
So, as far as I can tell, my only solution would be through downloading a list of file 'chunks' and then keep playing through every file as they are ready (ie: downloaded), probably using HLS
Searching I have come across this question which implements the progressive download through hls but other than that, I can find no other way
However, I keep coming across search results that say how to configure web servers to leverage the iOS support for HTTP Progressive Downloading, but with no mention of how to do it from the iOS side
So, any one have any ideas and/or experience about this?
EDIT: I have also found there could be a way of doing it other way around (ie: streaming, then writing streamed data to disk) which was suggested by this question but still cannot get it to work as it seems it does not work with non-local assets!
From what you say, you might want to change approach and attempt to stream the file. Downloading and playing at the same time, I would say is the definition of Streaming. I hate when people post links to the Apple documentation but in this instance reading a tiny bit of this documentation will help you more than I ever can. It should all make sense if you are lready working with connections and video, you just need to change your approach.
The link: https://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/streamingmediaguide/Introduction/Introduction.html

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 :
in rails app (backoffice or frontoffice) : Video upload (.mov, .avi, ...)
VOE : video encoding in FLV format + storage in Amazon S3
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).
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 !
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 felix.geisendoerfer#transloadit.com 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
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
I would feel skeptical using a free third party online service. I would consider using server-side video encoding because the third-party web service could have variable performance, and could do basically anything to the video. If you don't have many CPU's then a third-party service might be a good choice.
EDIT: This Link should help you a bit

Using Ruby And Ubuntu With Optical Character Recognition

I am a university student and it's time to buy textbooks again. This quarter there are over 20 books I need for classes. Normally this wouldn't be such a big deal, as I would just copy and paste the ISBNs into Amazon. The ISBNs, however, are converted into an image on my school's book site. All I want to do is get the ISBNs into a string so I don't have to type each one by hand. I have used GOCR to convert the images into text, but I want to use it with a Ruby script so I can automate the process and do the same for my classmates.
I can navigate to the site. How can I save the image to a file on my computer (running UBUNTU), convert the image with GOCR, and finally save it to a file so I can then access them again with my Ruby script?
GOCR seems to be a good choice at first, but from what I can tell from my own "research", quality isn't quite sufficient for daily use. Maybe this could lead to a problem, depending on the image input. If it doesn't work out for you, try the "new" feature of Google Docs, which allows you to upload images for OCR. You can then retrieve the results using some google api ( there are tons out there, I'm using gdata-ruby-util which requires some hacking, though.
You could also use tesseract-ocr for the OCR part, it's also open source and in active development.
For the retrieval part, I would as well stick with hpricot, super-powerful and flexible.
Sounds like a cool project, and shouldn't be too hard if the ISBN images are stored in individual files.
This all can be run in the background:
download web page (net/http)
save metadata + image file for each book (paperclip)
run GOCR on all the images
All you need is a list of urls or a crawler (mechanize) and then you probably need to spend a few minutes writing a parser (see joe's post) for the university html pages.

Resources