npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

video-slice

v2.1.5

Published

video-slice是一款面向web视频切片的插件,视频切片获取多张图片或者指定时间的切片

Downloads

38

Readme

视频切片库,可获取视频某一帧或多帧的图片

使用方法

1.npm安装

npm i video-slice

2.引入

import { videoSlice } from "video-slice";

3.视频切片使用示例

import { videoSlice } from "video-slice";
const inputDom = document.getElementById("chooseFile");
inputDom?.addEventListener("change",(res)=>{
    const input:any = res.target
    //videoToImg为返回的实例
    const videoToImg = videoSlice({
        width:100, //宽度
        file:input.files[0], //视频文件
        success:()=>{
            //获取某个时间点的切片
            // videoToImg.setCurrentTime(0,1)
            //快速切片
            videoToImg.fastStart();
            //自动切片
            // videoToImg.start();
        },
        backImgFn:(res)=>{ //切片返回的地方
            console.log("返回的base64图片:"+res)
        },
        finish:()=>{
            console.log("完成")
        }
    })
})

参数结构

| 参数 | 说明 | 类型 | 可选值 | 默认值 | | :----:| :----: | :----: | :----: | :----: | | video | 视频dom节点 | HTMLVideoElement | - | - | | width | 返回的图片宽度 | number/string | - | video的宽度 | | height | 返回的图片高度 | number/string | - | video的高度 | | file | 视频文件,video如没src就必须传该参数 | File | - | - | | intervalTime | 当前视频切图的间隔多少毫秒,最小生效时间 | number | ≥200 | 1000 | | muted | 是否静音 | boolean | true/false | true | | success | 当视频加载完成触发,后续操作在这个函数里面执行 | () => void | - | - | | fail | 报错触发函数 | (value: string) => void | - | - | | finish | 完成自动切片后触发 | () => void | - | - | | backImgFn | 每次切片都会触发的返回base64的图片 | (value: string) => void | - | - |

方法说明

| 方法名称 | 说明 | 参数 | 参数是否必传 | | :----:| :----: | :----: | :----: | | start | 正常速度开始切片 | - | - | | fastStart | 快速间隔一定时间(毫秒)切片 | number 默认:200(需≥30)| 否 | | getSrc | 返回视频地址 | - | - | | getImgs | 获取切过的时间对应的图片对象 | - | - | | FileToBase64 | 传入文件返回base64 | 视频文件 | 是 | | setIntervalTime | 设置的间隔时间(毫秒) | number | 是 | | setCurrentTime | 切片第几秒的 | t:number, isSetTime:boolean | t:是, isSetTime:否 | | destroy | 销毁监听等 | - | - |