| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

在canvas元素上播放视频的微型JS库:canvid.js

在canvas元素上播放视频的微型JS库:canvid.js。

canvid is a tiny library for playback of relatively short videos on canvas elements.

  • Why not just use HTML5 video?
    Because you can't embed and autoplay HTML5 videos on iOS! Yeah, that sucks.

  • Why is this better than using an animated GIF?
    Videos look kind of gross when converted to animated GIFs because of the colors sampling. Also the file size of video GIFs can get pretty huge. GIF is just not made for videos. JPG does a much better job of compressing video frames. Also, animated GIFs don't give you any playback controls. You can't pause a GIF or delay it's playback. With canvid you can do that.

  • Why only "relatively short" videos?
    As you see further down, the container format for canvid is a big image sprite of all the frames of each clip. Sadly, iOS limits the maximum image size (bigger image get sampled down), so that puts a limit on the maximum frames you can store.

Usage

var canvid = $('#my-video-div').canvid({      videos: {          clip1: { src: 'clip1.jpg', frames: 38, cols: 6 },          clip2: { src: 'clip2.jpg', frames: 43, cols: 6 }      },      width: 500,      height: 400,      loaded: function() {          canvid.play('clip1');          // reverse playback          // canvid.play('clip1', true);      }  });

如何将你的视频转成 JPG

First, convert you video into single frames using ffmpeg:

ffmpeg -i myvideo.mp4 -vf scale=375:-1 -r 5 frames/%04d.png

Then, use ImageMagicks montage to stich all the frames into one big image:

montage -border 0 -geometry 375x -tile 6x -quality 60% frames/*.png myvideo.jpg

项目主页:http://www.open-open.com/lib/view/home/1438954906254

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1438954906254.html
canvid.js JavaScript开发工具包