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_screenshot_zxd

v1.0.5

Published

一个video视频截图小插件基于javascript原生实现,可以返回图片文件或者base64图片

Downloads

7

Readme

更新说明

--v1.0.5
通过webpack打包压缩
--v1.0.3
修复手机竖屏拍摄视频播放,截图不完成的问题

一个使用原生js制作的建议截图功能的插件,利用原生的js,canvas生成图片,简单精简,有其他需求可以直接拓展

安装

npm i video_screenshot_zxd -D

使用

在需要引用的文件中导入
import { screenshot,dataURLtoBlob} from 'video_screenshot'

1. screenshot('video','image/png',isBase64,fileName).then(res=>{...}).catch(...)
'video' 表示要截取的 video 的 id
'image/png' 表示返回的 图片格式,支持'image/png' || 'image/jpeg'
isBase64: bool tue 表示返回图片的base64,则 fileName 可不填
            false 表示返回的文件对象,此时需要填写返回文件对象的 fileName

screenshot  函数会返回一个promise图片的base64 的 dataURL 或者 文件对象
            如果设置返回的base64,后面也可以手动调用dataURLtoBlob,转成文件对象返回
eg:screenshot('video','image/png',true,fileName).then(res=>{
        // res => dataURL
        let file = dataURLtoBlob(res,'fileName')
    })
2. dataURLtoBlob 函数 可以将 dataURL 转换成一个文件对象
let file = dataURLtoBlob(dataURL,'fileName')

具体在vue2中使用如下

<template>
    <div class="hello" >
        <div id="div">
        <img id="logo" src="../assets/logo.png" alt="">
        <video :src="src" crossOrigin="anonymous" controls="controls" width="1300" height="760" id="video"></video>
        </div>
        <hr>
        <button @click="JT">截图</button>
        <hr>
        <img v-if="imgBase64" :src="imgBase64" alt="">
    </div>
</template>

<script>
import { screenshot,dataURLtoBlob} from 'video_screenshot_zxd'
export default {
    name: 'HelloWorld',
    props: {
        msg: String
    },
    data(){
        return{
            src:require('../assets/1.mp4'),
            imgBase64:null
        }
    },
    methods:{
        JT(){
            screenshot('video','image/png',true).then(res=>{
                console.log(res);
                this.imgBase64 = res;

                let file = dataURLtoBlob(res,'截图文件')

                console.log(file)
            })
        }
    }
}
</script>