捕获和转换Web的工具

使用Node.js将在线视频转换为GIF动画

Node.js API

使用 GrabzIt的Node.js API 转换在线视频 into动画GIF。 但是,您必须记住,对于以下任何示例,要创建动画GIF, save or save_to 方法必须在 url_to_animation 方法。

基本选项

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

client.url_to_animation("http://www.example.com/video.avi");
//Then call the save or save_to method

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

使用GrabzIt的Node.js API将Vimeo或YouTube视频直接转换为GIF动画,只需指定显示Vimeo或YouTube视频的页面的URL,然后转换其中包含的视频 into动画GIF。 但是,由于此服务依赖第三方网站,因此不能保证每个视频都可以使用。

client.url_to_animation("https://www.youtube.com/watch?v=a1Y73sPHKxw");
//Then call the save or save_to method

自订识别码

您可以将自定义标识符传递给 url_to_animation 方法,如下所示,然后将该值传递回您的GrabzIt Node.js处理程序。 例如,该自定义标识符可以是数据库标识符,从而允许将动画GIF与特定的数据库记录相关联。

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};
client.url_to_animation("https://www.youtube.com/watch?v=a1Y73sPHKxw", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});

从视频捕获单帧

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

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"start":3, "duration":1, "framesPerSecond":1};
client.url_to_animation("http://www.example.com/video.avi", options);
//Then call the save or save_to method
client.save_to("result.gif", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});