捕获和转换Web的工具

使用Java将在线视频转换为GIF动画

Java API

了解如何开始使用以下工具将在线视频转换为GIF动画 GrabzIt的Java API。 但是,在开始之前,请记住 URLToAnimation 方法 Save or SaveTo 必须调用捕获视频的方法。

基本选项

唯一需要的参数是要转换的MP4,AVI或其他在线视频的URL into动画GIF。

grabzIt.URLToAnimation("http://www.example.com/video.avi");
//Then call the Save or SaveTo method

将Vimeo或YouTube视频转换为GIF动画

GrabzIt的Java API还可以将Vimeo或YouTube视频直接转换为GIF动画,只需指定Vimeo或YouTube视频出现在其上的页面的URL,并将其包含的视频转换为 into动画GIF。 但是,由于此服务依赖第三方网站,因此不能保证每个视频都可以使用。

grabzIt.URLToAnimation("https://www.youtube.com/watch?v=a1Y73sPHKxw");
//Then call the Save or SaveTo method

自订识别码

您可以传递自定义标识符 into setCustomId 的方法 AnimationOptions 类,如下所示,然后将该值返回到您的GrabzIt Java处理程序。 在此示例中,自定义标识符可以是数据库标识符,从而允许将动画GIF与特定数据库记录相关联。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

AnimationOptions options = new AnimationOptions();
options.setCustomId("123456");

grabzIt.URLToAnimation("https://www.youtube.com/watch?v=a1Y73sPHKxw", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/handler");

从视频捕获单帧

要从视频中捕获单个帧,您需要将持续时间和每秒帧数参数设置为1。 然后,可以通过设置开始位置参数以匹配要提取的帧的时间来获取所需的帧。

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

AnimationOptions options = new AnimationOptions();
options.setFramesPerSecond(1);
options.setDuration(1);
options.setStart(3);

grabzIt.URLToAnimation("http://www.example.com/video.avi", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.gif");