Git Product home page Git Product logo

fast-preview's Introduction

Fast Preview Build Status

FOSSA Status

该库用于生成动态 webp 格式视频缩略图

CLI

$ npm install -g fast-preview-cli
$ fpreview /path/to/video.mp4

条件

fast-preview 需要安装 ffmpeg 才能工作。 如果设置了 FFMPEG_PATH 环境变量, fast-preview 将使用它作为 ffmpeg 可执行文件的完整路径。否则,它将尝试直接调用 ffmpeg(因此它应该在您的 PATH 中)。您还必须安装 ffprobe(在大多数发行版中它带有 ffmpeg)。同样,如果设置了 FFPROBE_PATH 环境变量,fast-preview 将使用它,否则它将尝试在 PATH 中调用它。

安装

$ npm install fast-preview

使用

fast-preview 模块返回一个构造器,你需要实例化并传入要转换的视频(目前支持 MP4 格式), 并使用实例调用 exec 方法

var FastPreview = require("fast-preview").default;
var preview = new FastPreview("video.mp4");
preview.exec();

你可以传入一些配置

var FastPreview = require('fast-preview');
var preview = new FastPreview('video.mp4',{
  clip_count: 5,
  clip_time: 5,
  clip_select_strategy: 'max-size', // max-size min-size random
  clip_range: [0.1,0.9],
  fps_rate: 10, // number -1(default)
  output: {
    type: 'buffer' // 'buffer'(default) 'file' 'dir'
    path?: ''      // 输出类型不是buffer时需要传入文件或目录的路径
  },
  speed_multi: 2,
  width: 320, // number -1(default)
  height: -1  // number -1(default)
});
preview.exec()

可以使用的 options:

  • clip_count: 要截取的视频片段的数量
  • clip_time: 每个片段持续时间(秒)
  • clip_select_strategy: 片段选择策略
  • clip_range: 片段选择范围(视频时间的百分比)
  • fps_rate: 图像帧率(-1: 保持原视频帧率)
  • speed_multi: 片段播放速度的倍数
  • output: 动态预览图生成的路径或 buffer
  • width: 视频缩放宽度, 默认-1(按高度等比缩放)
  • height: 视频缩放高度, 默认-1(按宽度等比缩放)

License

(The MIT License)

Copyright (c) 2021 PingChuanXi <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FOSSA Status

fast-preview's People

Contributors

turnerxi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.