Add eslint & update README
This commit is contained in:
parent
31b4857437
commit
26aed33e69
6
.eslintrc
Normal file
6
.eslintrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extends": "airbnb-base",
|
||||||
|
"rules": {
|
||||||
|
"no-underscore-dangle": 0
|
||||||
|
}
|
||||||
|
}
|
@ -1,2 +1,4 @@
|
|||||||
|
.eslintrc
|
||||||
|
.github
|
||||||
tests
|
tests
|
||||||
examples
|
examples
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
FFmpeg.js
|
FFmpeg.js
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="#"><img alt="Tesseract.js" src="https://github.com/naptha/tesseract.js/raw/master/docs/images/cover.png"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
A FFmpeg WebAssembly version built from scratch, you can learn how to do it from this series of stories: [Build FFmpeg WebAssembly version (=ffmpeg.js)](https://medium.com/@jeromewus/build-ffmpeg-webassembly-version-ffmpeg-js-part-1-preparation-ed12bf4c8fac).
|
A FFmpeg WebAssembly version built from scratch, you can learn how to do it from this series of stories: [Build FFmpeg WebAssembly version (=ffmpeg.js)](https://medium.com/@jeromewus/build-ffmpeg-webassembly-version-ffmpeg-js-part-1-preparation-ed12bf4c8fac).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
BIN
docs/images/cover.png
Normal file
BIN
docs/images/cover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
1495
package-lock.json
generated
1495
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,8 @@
|
|||||||
"example": "examples"
|
"example": "examples"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha"
|
"test": "mocha",
|
||||||
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -26,5 +27,10 @@
|
|||||||
"homepage": "https://github.com/jeromewu/ffmpeg.js#readme",
|
"homepage": "https://github.com/jeromewu/ffmpeg.js#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ffmpeg/core": "^0.1.0"
|
"@ffmpeg/core": "^0.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "^6.1.0",
|
||||||
|
"eslint-config-airbnb-base": "^14.0.0",
|
||||||
|
"eslint-plugin-import": "^2.18.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module.exports = [
|
module.exports = [
|
||||||
'./ffmpeg', // args[0] is always binary path
|
'./ffmpeg', // args[0] is always binary path
|
||||||
'-nostdin', // Disable interaction mode
|
'-nostdin', // Disable interaction mode
|
||||||
'-loglevel',
|
'-loglevel',
|
||||||
'quiet',
|
'quiet',
|
||||||
];
|
];
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const { setModule } = require('./util/module');
|
|
||||||
const FFmpegCore = require('@ffmpeg/core');
|
const FFmpegCore = require('@ffmpeg/core');
|
||||||
|
const { setModule } = require('./util/module');
|
||||||
|
|
||||||
module.exports = () => (
|
module.exports = () => (
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve) => {
|
||||||
FFmpegCore()
|
FFmpegCore()
|
||||||
.then((Module) => {
|
.then((Module) => {
|
||||||
setModule(Module);
|
setModule(Module);
|
||||||
|
@ -4,7 +4,7 @@ const getFFmpeg = require('./util/getFFmpeg');
|
|||||||
const strList2ptr = require('./util/strList2ptr');
|
const strList2ptr = require('./util/strList2ptr');
|
||||||
const defaultArgs = require('./constants/defaultArgs');
|
const defaultArgs = require('./constants/defaultArgs');
|
||||||
|
|
||||||
module.exports = (inputPath, outputExt, options='') => {
|
module.exports = (inputPath, outputExt, options = '') => {
|
||||||
const Module = getModule();
|
const Module = getModule();
|
||||||
const data = new Uint8Array(fs.readFileSync(inputPath));
|
const data = new Uint8Array(fs.readFileSync(inputPath));
|
||||||
const iPath = `file.${inputPath.split('.').pop()}`;
|
const iPath = `file.${inputPath.split('.').pop()}`;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
let Module = null;
|
let Module = null;
|
||||||
|
|
||||||
exports.setModule = m => {
|
exports.setModule = (m) => {
|
||||||
Module = m;
|
Module = m;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ const { getModule } = require('./module');
|
|||||||
|
|
||||||
module.exports = (s) => {
|
module.exports = (s) => {
|
||||||
const Module = getModule();
|
const Module = getModule();
|
||||||
const ptr = Module._malloc((s.length+1)*Uint8Array.BYTES_PER_ELEMENT);
|
const ptr = Module._malloc((s.length + 1) * Uint8Array.BYTES_PER_ELEMENT);
|
||||||
for (let i = 0; i < s.length; i++) {
|
for (let i = 0; i < s.length; i += 1) {
|
||||||
Module.setValue(ptr+i, s.charCodeAt(i), 'i8');
|
Module.setValue(ptr + i, s.charCodeAt(i), 'i8');
|
||||||
}
|
}
|
||||||
Module.setValue(ptr+s.length, 0, 'i8');
|
Module.setValue(ptr + s.length, 0, 'i8');
|
||||||
return ptr;
|
return ptr;
|
||||||
};
|
};
|
||||||
|
@ -3,11 +3,11 @@ const str2ptr = require('./str2ptr');
|
|||||||
|
|
||||||
module.exports = (strList) => {
|
module.exports = (strList) => {
|
||||||
const Module = getModule();
|
const Module = getModule();
|
||||||
const listPtr = Module._malloc(strList.length*Uint32Array.BYTES_PER_ELEMENT);
|
const listPtr = Module._malloc(strList.length * Uint32Array.BYTES_PER_ELEMENT);
|
||||||
|
|
||||||
strList.forEach((s, idx) => {
|
strList.forEach((s, idx) => {
|
||||||
const strPtr = str2ptr(s);
|
const strPtr = str2ptr(s);
|
||||||
Module.setValue(listPtr + (4*idx), strPtr, 'i32');
|
Module.setValue(listPtr + (4 * idx), strPtr, 'i32');
|
||||||
});
|
});
|
||||||
|
|
||||||
return listPtr;
|
return listPtr;
|
||||||
|
Loading…
Reference in New Issue
Block a user