Skip to content

JackPu/core-video-to-gif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

core-video-to-gif

A JavaScript Library To Convert Video Fragments To Gif.

中文文档

Get Started

NPM

$ npm install core-video-to-gif --save

CDN

<script src="./dist/core-video-to-gif.min.js"></script>
const v2g = new CoreVideoToGif({
    // specify the video element
    el: document.querySelector('video'),
    // video 的父容器
    parentEl: document.querySelector('.conatiner')
})
v2g.shot({
    // options,
    start: 5, // ms
    end: 8
}, (result) => {
    // ...
    image.src = result
})

Params

key Type Details Value
* el Element The video element <video ... >
workerScript String enable Web Worker Please inclued the [script](https://github.com/JackPu/core-video-to-gif/blob/master/examples/gif.worker.js), and specify the path
width Number The output git width 600(default: the video original height)
height Number The output gif image height 600(default: the video original height)
maxTime Number limit the time of gif animation 5(default: 10)
fps Number the frame per second 12(default: 6)
quality Number the quality of gif (1-10) The best is 10
onStartShot Function call when start shoting
onGifProcess Function call when making gif
onGifFinished Function call when gif output

“*” means it is required.

API

shot(params, callback)

You could use the method to get the video screenshots.

// get current screenshot
v2g.shot( (result) => {
   // ...
   image.src = result
})
// get screenshot from 5s - 8s
v2g.shot({
   // options,
   start: 5, // ms
   end: 8
}, (result) => {
   // ...
   image.src = result
})

params

key Type Details Value
start Number the screenshot start time 6(s)
end Number the screenshot end time 7(s)

upload(params, callback)

The api is still in draft. Not work!!!

Contributions

Your contributions and suggestions are welcome 😄😄😄

MIT License

About

A JavaScript Library To Convert Video Fragments To Gif

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published