Editly not working, trying ffmpeg concat demuxer
This commit is contained in:
commit
17d59d4885
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/node_modules/
|
||||
*.mp4
|
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
ffmpeg -i odcinek1-kuba.wav -ac 1 -filter:a aresample=8000 -map 0:a -c:a pcm_s16le -f data - | hexdump
|
||||
|
||||
^ daje waveform w dwubajtowych intach
|
2353
package-lock.json
generated
Normal file
2353
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
17
package.json
Normal file
17
package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "vizualizer",
|
||||
"version": "1.0.0",
|
||||
"description": "ffmpeg -i odcinek1-kuba.wav -ac 1 -filter:a aresample=8000 -map 0:a -c:a pcm_s16le -f data - | hexdump",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"editly": "^0.3.0"
|
||||
}
|
||||
}
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "node",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"sourceMap": true,
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"allowJs": false,
|
||||
"strictNullChecks": true,
|
||||
"esModuleInterop": true,
|
||||
"outDir": "build"
|
||||
}
|
||||
}
|
78
visualize.ts
Normal file
78
visualize.ts
Normal file
@ -0,0 +1,78 @@
|
||||
const editly = require("editly");
|
||||
|
||||
const graph_density = 1000;
|
||||
|
||||
const threshold_at_point = 1;
|
||||
|
||||
const inertia_s = 0.1;
|
||||
const inertia_samples = inertia_s * graph_density;
|
||||
|
||||
let position = 0;
|
||||
let last_swap_position = 0;
|
||||
|
||||
const s = (n: number) => Math.round(n / graph_density);
|
||||
|
||||
const minutes = (units: number) => Math.floor(s(units) / 60);
|
||||
|
||||
const formatTime = (units: number) =>
|
||||
`${minutes(units)}:${Math.floor(s(units) % 60)}`;
|
||||
|
||||
let keep_loud_until = 0;
|
||||
|
||||
let total_speaking = 0;
|
||||
|
||||
const results: [string, number][] = [];
|
||||
|
||||
process.stdin.on("readable", () => {
|
||||
let chunk: Buffer | null;
|
||||
let was_loud_last_time = false;
|
||||
while ((chunk = process.stdin.read()) !== null) {
|
||||
for (let i = 0; i < chunk.byteLength; i++) {
|
||||
position++;
|
||||
const byte = chunk[i];
|
||||
const volume = Math.abs(byte - 128);
|
||||
const is_loud: boolean =
|
||||
volume > threshold_at_point || position < keep_loud_until;
|
||||
if (is_loud) {
|
||||
total_speaking++;
|
||||
}
|
||||
if (is_loud != was_loud_last_time) {
|
||||
results.push([
|
||||
is_loud ? "silence" : "speaking",
|
||||
position - last_swap_position,
|
||||
]);
|
||||
last_swap_position = position;
|
||||
was_loud_last_time = is_loud;
|
||||
}
|
||||
if (volume > threshold_at_point) {
|
||||
keep_loud_until = position + inertia_samples;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
process.stdin.on("end", () => {
|
||||
console.log(results);
|
||||
const spec = {
|
||||
outPath: "./out.mp4",
|
||||
width: 800,
|
||||
height: 600,
|
||||
fps: 30,
|
||||
defaults: { transition: { duration: 0 } },
|
||||
audioFilePath: "/home/kuba/Downloads/odcinek1-kuba.wav",
|
||||
clips: results.map((e) => ({
|
||||
duration: s(e[1]),
|
||||
layers: [
|
||||
{
|
||||
type: "title",
|
||||
text: e[0] === "silence" ? " " : "Kuba Mówi",
|
||||
position: "center",
|
||||
},
|
||||
],
|
||||
})),
|
||||
fast: true,
|
||||
};
|
||||
console.log(spec);
|
||||
editly(spec).then(() => console.log("done!"));
|
||||
console.log(formatTime(total_speaking));
|
||||
});
|
Loading…
Reference in New Issue
Block a user