I have a Rails app using Paperclip to upload and store videos on Amazon S3. I'm not particularly interested converting the video files into another format, or adding watermarks, nothing fancy. I just want to create thumbnails from the videos to use as poster images on my video players.
I see that Amazon Elastic Transcoder allows for free thumbnail creation (or rather, they don't charge for thumbnail creation), and since I'm already using Amazon services, I wanted to see if I can use this for my thumbnails.
Does anyone know how to set the input/output options such that no file is generated aside from thumbnails? Could I just do the following?
transcoder = AWS::ElasticTranscoder::Client.new
transcoder.create_job(
pipeline_id: APP_CONFIG[Rails.env][:pipeline_id],
input: {
key: VIDEOPATH,
frame_rate: 'auto',
resolution: 'auto',
aspect_ratio: 'auto',
interlaced: 'auto',
container: 'auto'
},
output: {
key: , #LEAVE THIS BLANK TOO?
preset_id: , #LEAVE THIS BLANK?
thumbnail_pattern: "thumbnail",
rotate: '0'
}
)
No.
There are no functions for creating only thumbnails.
It also is not possible to create a new transcoding job without actually transcoding anything. The input parameters require, at minimum, the name of an input video. The output parameters require, at minimum, the name of the output file and a preset ID. Parameters are checked prior to starting the job, and there are no options which would prevent the job from executing while creating a thumbnail.
You can read about all of the available functions here:
http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/api-reference.html
Give ffmpeg a look. It can be a little bit of a hassle to install, but it can create thumbnails from videos.
Amazon Elastic Transcoder does provide functionality for thumbnails.
http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/preset-settings.html#preset-settings-thumbnails
It looks like you do indeed have to transcode a video file in order to get thumbnails though.
As mentioned in other comments, you need to pay the transcoding price for Elastic transcoder to generate a thumbnail.
Another similar option Amazon provides is MediaConvert. With MediaConvert, you can add an additional output of a number of image files that will be taken using a formula you need to provide (pick an image every X frames). As with Elastic Transcoder, this is expensive for getting only a thumbnail, and you are still not sure that the thumbnails you get are good images (not blurry and representative of the video).
As mentioned in another comment, using FFMpeg will work better in comparison. It's a pretty solution if you can maintain the infrastructure to do it (some sort of processing queue, running ffmpeg, and then uploading thumbnails).
Full disclosure: We faced a similar problem. Our volume was large enough that generating thumbnails by hand was getting cumbersome, and we'd often get blank thumbnails because it's hard to predict which frame is good across different videos. So we built a product that fixes this pain for us (and others in the same boat): https://mediamachine.io/
Instead of getting random thumbnails with no meaning (and, what is worst, paying for them), we use a ML algorithm to get the most representative thumbnail of the video, saving time AND money.
Related
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.
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).
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...
User can upload any video of any type... after that I need to convert this video to *.flv
How can I do this using RoR?
We do this with paperclip and ffmpeg. Paperclip allows you to add custom processors to a Paperclip attachment. We created such a processor which just calls ffmpeg on the command line to create the flash version of the video. ffmpeg even allows you to extract stills from the video for thumbnail representations.
With paperclip and ffmpeg and flvtool2
Have look at this gist with all you'll need. https://gist.github.com/507804
It has:
Video to thumbnails
Video to flash
Correct geometry calculations etc...
There are two ways to do it, yourself or hosted solution.
If you want to do it yourself, start with Bert's solution and go from there. Remember transcoding is CPU intensive, so you likely need to have a another server/on-demand instance doing this
If you want to go for a hosted solution, see Kaltura.com or encoding.com
sign up for pandastream - available as a heroku add-on as is zencoder
they're not cheap options though so maybe look around for something less costly first
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