Skip to content

Commit

Permalink
Some ffmpeg fail to return progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostzero committed Mar 3, 2023
1 parent 2644c30 commit df803af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions electron/rerun-manager/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {EncoderListeners, EncoderOptions, Settings, User, Video} from "../../sha
import * as fs from "fs";
import axios, {AxiosInstance} from "axios";

const ffmpeg = require('fluent-ffmpeg')

export class Encoder {
private readonly id: string;
private readonly input: string;
Expand Down Expand Up @@ -42,18 +40,25 @@ export class Encoder {
async encode(): Promise<void> {
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)

let totalTime = 0;
ffmpeg(this.input)
.outputOptions(this.getOutputOptions())
.output(this.output)
.on('start', () => {
console.log('start')
})
.on('progress', (progress) => {
console.log('progress', progress)
this.listeners.onProgress(this.id, progress.percent)
.on('codecData', data => {
totalTime = parseInt(data.duration.replace(/:/g, ''))
})
.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 () => {
console.log('end')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rerun-encoder",
"private": true,
"productName": "Rerun Encoder",
"version": "1.0.2",
"version": "1.0.3",
"description": "Official Rerun Encoder App for Rerun Manager",
"main": "dist-electron/main/index.js",
"scripts": {
Expand Down

0 comments on commit df803af

Please sign in to comment.