網站管理員的一個常見要求是如何在不加載視頻的情況下輕鬆顯示視頻預覽。 實現此目的的常用方法是轉換視頻 into an animated GIF. You can use this animated GIF to preview the video on websites and social media. GrabzIt's JavaScript API 使創建GIF變得簡單。
以下是如何轉換YouTube視頻的示例 into動畫GIF。 但是有很多 更多的選擇 you can use to customize your animated GIF. For instance, a 習俗 watermark could be overlaid on the GIF. 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也可以轉換Vimeo視頻 into動畫GIF,其轉換方式與轉換YouTube視頻的方式完全相同。 只需傳遞包含Vimeo視頻的網頁的URL。 到 url
參數並將“ gif”傳遞給 format
參數,如下所示。
<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還可以轉換正常的在線視頻,例如MP4。 只需將視頻網址傳遞到 url
參數,同時設置 format
參數為“ gif”。 與上述示例相同。
使用GrabzIt可以從YouTube,Vimeo或標準視頻中捕獲單個幀。
To do so you need to set the duration
和 fps
參數為1。 然後設置 format
參數為“ gif”。 最後,找到要提取的幀在視頻中的位置,並記下秒數。 然後將此值傳遞給 start
參數。
Please note that you can currently only return frames 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>