mirror of
https://github.com/bitinflow/rerun-encoder.git
synced 2026-03-13 21:56:01 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df803afe2b | ||
|
|
2644c30bf2 |
@@ -3,8 +3,6 @@ import {EncoderListeners, EncoderOptions, Settings, User, Video} from "../../sha
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import axios, {AxiosInstance} from "axios";
|
import axios, {AxiosInstance} from "axios";
|
||||||
|
|
||||||
const ffmpeg = require('fluent-ffmpeg')
|
|
||||||
|
|
||||||
export class Encoder {
|
export class Encoder {
|
||||||
private readonly id: string;
|
private readonly id: string;
|
||||||
private readonly input: string;
|
private readonly input: string;
|
||||||
@@ -42,15 +40,25 @@ export class Encoder {
|
|||||||
async encode(): Promise<void> {
|
async encode(): Promise<void> {
|
||||||
this.listeners.onStart(this.id)
|
this.listeners.onStart(this.id)
|
||||||
|
|
||||||
|
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
|
||||||
|
console.log('ffmpegPath', ffmpegPath)
|
||||||
|
const ffmpeg = require('fluent-ffmpeg')
|
||||||
|
ffmpeg.setFfmpegPath(ffmpegPath)
|
||||||
|
let totalTime = 0;
|
||||||
ffmpeg(this.input)
|
ffmpeg(this.input)
|
||||||
.outputOptions(this.getOutputOptions())
|
.outputOptions(this.getOutputOptions())
|
||||||
.output(this.output)
|
.output(this.output)
|
||||||
.on('start', () => {
|
.on('start', () => {
|
||||||
console.log('start')
|
console.log('start')
|
||||||
})
|
})
|
||||||
.on('progress', (progress) => {
|
.on('codecData', data => {
|
||||||
console.log('progress', progress)
|
totalTime = parseInt(data.duration.replace(/:/g, ''))
|
||||||
this.listeners.onProgress(this.id, progress.percent)
|
})
|
||||||
|
.on('progress', progress => {
|
||||||
|
const time = parseInt(progress.timemark.replace(/:/g, ''))
|
||||||
|
const percent = (time / totalTime) * 100
|
||||||
|
console.log('progress', percent)
|
||||||
|
this.listeners.onProgress(this.id, percent)
|
||||||
})
|
})
|
||||||
.on('end', async () => {
|
.on('end', async () => {
|
||||||
console.log('end')
|
console.log('end')
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "rerun-encoder",
|
"name": "rerun-encoder",
|
||||||
"private": true,
|
"private": true,
|
||||||
"productName": "Rerun Encoder",
|
"productName": "Rerun Encoder",
|
||||||
"version": "1.0.1",
|
"version": "1.0.3",
|
||||||
"description": "Official Rerun Encoder App for Rerun Manager",
|
"description": "Official Rerun Encoder App for Rerun Manager",
|
||||||
"main": "dist-electron/main/index.js",
|
"main": "dist-electron/main/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -57,6 +57,7 @@
|
|||||||
"vue-tsc": "^1.1.7"
|
"vue-tsc": "^1.1.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
||||||
"@koa/cors": "^4.0.0",
|
"@koa/cors": "^4.0.0",
|
||||||
"axios": "^1.3.4",
|
"axios": "^1.3.4",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
|
|||||||
Reference in New Issue
Block a user