Code Monkey home page Code Monkey logo

cheetah-capture's Introduction

cheetah-capture

cheetah
基于自定义编译ffmpeg的截帧工具,支持Mp4、Mov、Avi、Webm、Mkv等主流格式。

API

initCapture({workerPath, wasmPath}) => Promise<capture> 初始化worker环境,拉取wasm,返回capture方法 接受参数如下

参数 类型 含义 是否必须
workerPath URL / string woker路径,eg:node_modules/dist/capture.worker.js,因为有woker有同源限制,你可以传递BlobUrl来解决 y
wasmPath URL / string wasm路径,eg:node_modules/dist/capture.worker.wasm y

capture: (args) => void 在worker里执行截帧方法 接受参数如下

参数 类型 含义 是否必须
info number[] / number 传递number是按照数目抽帧,传递数组是指定抽帧的时间 y
path string workerfs建立文件目录 n
file File / blob 文件 y
onChange (prev: PrevType, now: nowType, info: {width: number, height: number, duration: number}) => void 当抽帧结果变化的回调 n
onSuccess (prev: PrevType) => void 当抽帧结束并成功的回调 n
onError (errmeg: string) => void 当抽帧过程出现错误的回调 n

例子可以参考 demo/index.html

依赖库&编译工具

  • ffmpeg-3.4.8
  • emscripten

准备工作

  git pull
  # Download and install the latest SDK tools.
  ./emsdk install latest
  # Make the "latest" SDK "active" for the current user. (writes .emscripten file)
  ./emsdk activate latest
   # Activate PATH and other environment variables in the current terminal
   source ./emsdk_env.sh
  • emsdk 需要安装于代码库根目录

编译脚本

script下面是编译脚本 build_ffmpeg-3.4.8.sh 编译本地c编译环境的ffmpeg的lib库 build-emcc.sh 编译emcc环境需要的ffmpeg的lib库,编译结果lib/ffmpeg-emcc build_wasm.sh 使用ems编译wasm 和 glue code & worker code build.sh 同上以及生成dts类型

demo运行

demo文件夹下index.html 使用live server启动即可,live-server --port=5501

调试环境准备

在已经完成准备工作的前提

  • 若进行c环境调试 scripts目录下执行sh build_ffmpeg-3.4.8.sh编译你的对应环境的lib,sh reload.sh执行capture.c 文件。
  • 进行js环境调试,先执行build-emcc.sh生产emcc环境需要的ffmpeg的lib库,如若已有库直接执行 sh build-wasm.sh,包含npm run webpack-capture以及emcc编译命令,前者生成index.js以及capture.worker.js,后者生成capture.worker.js(包含emcc的胶水代码) 和capture.worker.wasm
  • html环境引入,直接引入index.js即可,umd变量cheetahCapture

关于版本控制

版本的hash不会在类库层面去做 倾向于业务方使用打包工具来做。

提交及发包

本地提交npm run commit 更新并写入changelognpm run release

cheetah-capture's People

Contributors

jinzhan avatar hixuanxuan 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.