A common request from webmasters is how to easily show a video preview without loading a video. The common way to achieve this is by converting a video into an animated GIF. This animated GIF can then be used to preview the video on websites and social media. GrabzIt's JavaScript API makes creating GIFs simple.
Below is an example of how to convert a YouTube video into an animated GIF. However there are many more options you can use to customize your animated GIF. For instance, the size of the GIF could be changed or a custom watermark overlaid. Or even the number of frames per second or the duration of the animation altered.
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("https://www.youtube.com/watch?v=7GqClqvlObY",
{"format": "gif"}).Create();
</script>
GrabzIt can also convert Vimeo videos into animated GIFs, in exactly the same way that it converts YouTube videos. Just pass the URL of the web page that contains the Vimeo video. To the url
parameter and pass "gif" to the format
parameter, as shown below.
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("https://vimeo.com/134957666",
{"format": "gif"}).Create();
</script>
GrabzIt can also convert normal online videos such as MP4. Simply pass the video URL to the url
parameter, while setting the format
parameter to "gif". In the same way as the above example.
Using GrabzIt it is possible to capture a single frame from YouTube, Vimeo or standard videos.
In order to do so you need to set the duration
and fps
parameters to be 1. Then set the format
parameter to "gif". Finally find the position in the video of the frame you want to extract and note the number of seconds. Then pass this value to the start
parameter.
Note that currently frames can only be returned as GIFs.
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("https://www.example.com/myvideo.mp4",
{"format": "gif", "start":1, "fps ":"1", "duration":"1"}).Create();
</script>