Skip to content

Commit

Permalink
ffmpeg: refactor FFmpegInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
amishshah committed Aug 22, 2019
1 parent d7b997e commit 87f5da9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/core/FFmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ const { Duplex } = require('stream');

let FFMPEG = {
command: null,
info: null,
output: null,
};

const VERSION_REGEX = /version (.+) Copyright/mi;

Object.defineProperty(FFMPEG, 'version', {
get() {
return VERSION_REGEX.exec(FFMPEG.info)[1];
return VERSION_REGEX.exec(FFMPEG.output)[1];
},
enumerable: true,
});
Expand Down Expand Up @@ -101,7 +101,7 @@ class FFmpeg extends Duplex {
*
* console.log(`Using FFmpeg version ${ffmpeg.version}`);
*
* if (ffmpeg.info.includes('--enable-libopus')) {
* if (ffmpeg.output.includes('--enable-libopus')) {
* console.log('libopus is available!');
* } else {
* console.log('libopus is unavailable!');
Expand All @@ -117,7 +117,7 @@ class FFmpeg extends Duplex {
if (result.error) throw result.error;
Object.assign(FFMPEG, {
command: source,
info: Buffer.concat(result.output.filter(Boolean)).toString(),
output: Buffer.concat(result.output.filter(Boolean)).toString(),
});
return FFMPEG;
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion test/ffmpeg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { roughlyEquals, streamToBuffer } = require('./util');
test('FFmpeg transcoder available', () => {
expect(prism.FFmpeg).toBeTruthy();
expect(prism.FFmpeg.getInfo().command).toBeTruthy();
expect(prism.FFmpeg.getInfo().info).toBeTruthy();
expect(prism.FFmpeg.getInfo().output).toBeTruthy();
expect(prism.FFmpeg.getInfo().version).toBeTruthy();
});

Expand Down

0 comments on commit 87f5da9

Please sign in to comment.