Capture preview image from a video file
npm install video-frame-cover --save
Browser usage
<script src="https://unpkg.com/video-frame-cover@2.0.4/dist/index.global.js"></script>
<script src="https://cdn.jsdelivr.net/npm/video-frame-cover@2.0.4/dist/index.global.js"></script>
Javascript
import videoFrameCover from "video-frame-cover";
videoFrameCover({
url: this.videoUrl, // video url
quality: 0.9,
imageType: 'image/jpeg',
isCheckBackgroundColor: true, // Check whether the image is a solid color
success: (res, e) => {
this.imgsrc = res
}
})
Type: String
Default: true
video link
Type: Number
Default: false
The default value is 1. If the value is 0, a black screen may be displayed
Type: Number
Default: false
Image quality 0.2-0.95 If the value is 1, the size of base64 will be increased
Type: Number
Default: false
Generate image width, height will be calculated according to video aspect ratio
Type: String
Default: false
Image type image/png
is similar to this format
Type: Boolean
Default: false
Whether to verify that the picture is a solid color, the default is false
, if enabled, the picture is a solid color, and the next second video picture will be automatically obtained
Download video frame pictures
Get the video picture of the previous second
Get the next second video picture
time
how many seconds of the picture to get the specified frame video picture
const videoFrame = videoFrameCover({
url: './thwj.mp4',
quality: 0.9,
imageType: 'image/jpeg',
isCheckBackgroundColor: true, // Check whether the image is a solid color
success: (res, e) => {
this.imgsrc = res
}
})
videoFrame.downloadFile(this.imgsrc)
videoFrame.previousFrame()
videoFrame.nextFrame()
videoFrame.appointFrame(23) // Picture at 23 seconds