mirror of
https://github.com/bitinflow/rerun-encoder.git
synced 2026-03-13 21:56:01 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df803afe2b |
@@ -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,18 +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;
|
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
|
||||||
|
console.log('ffmpegPath', ffmpegPath)
|
||||||
|
const ffmpeg = require('fluent-ffmpeg')
|
||||||
ffmpeg.setFfmpegPath(ffmpegPath)
|
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.2",
|
"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": {
|
||||||
|
|||||||
Reference in New Issue
Block a user