使用这些常见技巧,即可开始将在线视频转换为GIF动画 GrabzIt的ASP.NET 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
GrabzIt的ASP.NET 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 CustomId
的财产 AnimationOptions 类,如下所示,然后将该值返回到您的GrabzIt ASP.NET处理程序。 例如,该自定义标识符可以是数据库标识符,从而允许将动画GIF与特定数据库记录相关联。
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); AnimationOptions options = new AnimationOptions(); options.CustomId = "123456"; grabzIt.URLToAnimation("https://www.youtube.com/watch?v=a1Y73sPHKxw", options); //Then call the Save method grabzIt.Save("http://www.example.com/Home/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.FramesPerSecond = 1; options.Duration = 1; options.Start = 3; grabzIt.URLToAnimation("http://www.example.com/video.avi", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.gif");