Skip to content

Commit

Permalink
Merge f96a3ba into 2004aac
Browse files Browse the repository at this point in the history
  • Loading branch information
thijstriemstra committed Oct 31, 2020
2 parents 2004aac + f96a3ba commit d55edf3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# videojs-record changelog

## 4.2.0 - unreleased

- Fix issue with opus-recorder plugin (#519)


## 4.1.0 - 2020/08/11

- Fixed webpack externals configuration: it's no longer needed to
Expand Down
2 changes: 1 addition & 1 deletion docs/demo/audio-only-opus.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
displayMilliseconds: true,
audioEngine: 'opus-recorder',
audioSampleRate: 48000,
audioChannels: 2,
audioChannels: 1,
audioWorkerURL: 'lib/opus-recorder/encoderWorker.min.js'
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/opus-recorder.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ record: {
debug: true,
audioEngine: 'opus-recorder',
audioSampleRate: 48000,
audioChannels: 2,
audioChannels: 1,
audioWorkerURL: '../../node_modules/opus-recorder/dist/encoderWorker.min.js'
// use the pluginLibraryOptions option to specify optional settings for the
// opus-recorder library. For example:
Expand All @@ -62,5 +62,5 @@ Options for this plugin:
| `audioEngine` | `opus-recorder` | Enables the plugin. |
| `audioWorkerURL` | `/path/to/encoderWorker.min.js` | Path to encoder WebWorker file. |
| `audioSampleRate` | `48000` | The audio sample rate (in sample-frames per second) at which the `AudioContext` handles audio. Legal values are in the range of 22050 to 96000. |
| `audioChannels` | `2` | Number of audio channels. Using a single channel results in a smaller file size. |
| `audioChannels` | `1` | Number of audio channels. Using a single channel results in a smaller file size. |
| `pluginLibraryOptions` | `{}` | Specify optional settings for the opus-recorder library. |
2 changes: 1 addition & 1 deletion examples/plugins/audio-only-opus.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
displayMilliseconds: true,
audioEngine: 'opus-recorder',
audioSampleRate: 48000,
audioChannels: 2,
audioChannels: 1,
audioWorkerURL: '../../node_modules/opus-recorder/dist/encoderWorker.min.js'
// use the pluginLibraryOptions option to specify optional settings for the
// opus-recorder library. For example:
Expand Down
20 changes: 10 additions & 10 deletions src/js/plugins/opus-recorder-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class OpusRecorderEngine extends RecordEngine {
*
* @type {number}
*/
this.audioChannels = 2;
this.audioChannels = 1;
/**
* The length of the buffer that the internal `JavaScriptNode`
* uses to capture the audio. Can be tweaked if experiencing
Expand Down Expand Up @@ -92,13 +92,19 @@ class OpusRecorderEngine extends RecordEngine {
this.mediaType = mediaType;
this.debug = debug;

// create new AudioContext
let AudioContext = window.AudioContext || window.webkitAudioContext;
this.audioContext = new AudioContext();
this.audioSourceNode = this.audioContext.createMediaStreamSource(
this.inputStream);

// minimal default config
this.config = {
leaveStreamOpen: true,
numberOfChannels: this.audioChannels,
bufferLength: this.bufferSize,
encoderSampleRate: this.sampleRate,
encoderPath: this.audioWorkerURL
encoderPath: this.audioWorkerURL,
sourceNode: this.audioSourceNode
};

// extend config with optional options
Expand All @@ -107,19 +113,13 @@ class OpusRecorderEngine extends RecordEngine {
// create Recorder engine
this.engine = new Recorder(this.config);
this.engine.ondataavailable = this.onRecordingAvailable.bind(this);

// create new AudioContext
let AudioContext = window.AudioContext || window.webkitAudioContext;
this.audioContext = new AudioContext();
this.audioSourceNode = this.audioContext.createMediaStreamSource(
this.inputStream);
}

/**
* Start recording.
*/
start() {
this.engine.start(this.audioSourceNode).then(() => {
this.engine.start().then(() => {
// recording started ok
}).catch((err) => {
// can't start playback
Expand Down
2 changes: 1 addition & 1 deletion test/test-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const TestHelpers = {
recordPluginOptions.audioEngine = OPUSRECORDER;
recordPluginOptions.audioSampleRate = 48000;
recordPluginOptions.audioWorkerURL = '/base/node_modules/opus-recorder/dist/encoderWorker.min.js';
recordPluginOptions.audioChannels = 2;
recordPluginOptions.audioChannels = 1;
break;

case RECORDERJS:
Expand Down

0 comments on commit d55edf3

Please sign in to comment.