Use these common tips to start converting online videos to animated GIF's with GrabzIt's Ruby API. However before you start remember that after calling the url_to_animation method the save or save_to method must be called to capture the video.
The only parameter that is required is the URL of the MP4, AVI or other online video to convert into an animated GIF.
grabzItClient.url_to_animation("http://www.example.com/video.avi") # Then call the save or save_to method
GrabzIt's Ruby API can also convert Vimeo or YouTube video's directly to animated GIF's, just specify the URL of the page that the Vimeo or YouTube video appears on and the video it contains will be converted into an animated GIF. However because this service relies on a third-party website it can not be guaranteed to work for every video.
grabzItClient.url_to_animation("https://www.youtube.com/watch?v=a1Y73sPHKxw") # Then call the save or save_to method
You can pass a custom identifier into the setCustomId
method of the AnimationOptions class as shown below, this value is then returned to your GrabzIt Ruby handler. For instance this custom identifier could be a database identifier, allowing a animated GIF to be associated with a particular database record.
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzIt::AnimationOptions.new() options.customId = "123456" grabzItClient.url_to_animation("https://www.youtube.com/watch?v=a1Y73sPHKxw", options) # Then call the save method grabzItClient.save("http://www.example.com/handler/index")
To capture a single frame from a video you need to set the duration and the frames per second parameters to be 1. You can then get your required frame by setting the start position parameter.
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzIt::AnimationOptions.new() options.framesPerSecond = 1 options.duration = 1 options.start = 3 grabzItClient.url_to_animation("http://www.example.com/video.avi", options) # Then call the save or save_to method grabzItClient.save_to("result.gif")