Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
571 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>ffmpeg.wasm video-only example - Record Plugin for Video.js</title> | ||
|
||
<link href="//vjs.zencdn.net/7.10.2/video-js.min.css" rel="stylesheet"> | ||
<link href="//unpkg.com/videojs-record/dist/css/videojs.record.min.css" rel="stylesheet"> | ||
<link href="assets/examples.css" rel="stylesheet"> | ||
|
||
<script src="//vjs.zencdn.net/7.10.2/video.min.js"></script> | ||
<script src="//unpkg.com/recordrtc/RecordRTC.js"></script> | ||
<script src="//unpkg.com/webrtc-adapter/out/adapter.js"></script> | ||
<script src="//unpkg.com/@ffmpeg/ffmpeg/dist/ffmpeg.min.js"></script> | ||
|
||
<script src="//unpkg.com/videojs-record/dist/videojs.record.min.js"></script> | ||
<script src="//unpkg.com/videojs-record/dist/plugins/videojs.record.ffmpeg-wasm.js"></script> | ||
|
||
<script src="browser-workarounds.js"></script> | ||
|
||
<style> | ||
/* change player background color */ | ||
#myVideo { | ||
background-color: #54a86b; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<video id="myVideo" playsinline class="video-js vjs-default-skin"></video> | ||
|
||
<script> | ||
var options = { | ||
controls: true, | ||
width: 320, | ||
height: 240, | ||
fluid: false, | ||
bigPlayButton: false, | ||
controlBar: { | ||
volumePanel: false | ||
}, | ||
plugins: { | ||
record: { | ||
audio: false, | ||
video: true, | ||
maxLength: 20, | ||
displayMilliseconds: true, | ||
debug: true, | ||
convertEngine: 'ffmpeg.wasm', | ||
convertWorkerURL: '//unpkg.com/@ffmpeg/core/dist/ffmpeg-core.js', | ||
// convert recorded data to MP4 (and copy over audio data without encoding) | ||
convertOptions: ['-c:v', 'libx264', '-preset', 'slow', '-crf', '22', '-c:a', 'copy', '-f', 'mp4'], | ||
// specify output mime-type | ||
pluginLibraryOptions: { | ||
outputType: 'video/mp4' | ||
} | ||
} | ||
} | ||
}; | ||
|
||
// apply some workarounds for certain browsers | ||
applyVideoWorkaround(); | ||
|
||
var player = videojs('myVideo', options, function() { | ||
// print version information at startup | ||
videojs.log('Using video.js', videojs.VERSION, | ||
'with videojs-record', videojs.getPluginVersion('record'), | ||
'and recordrtc', RecordRTC.version); | ||
}); | ||
// error handling | ||
player.on('deviceError', function() { | ||
console.log('device error:', player.deviceErrorCode); | ||
}); | ||
|
||
player.on('error', function(element, error) { | ||
console.error(error); | ||
}); | ||
|
||
// user clicked the record button and started recording | ||
player.on('startRecord', function() { | ||
console.log('started recording!'); | ||
}); | ||
|
||
// user completed recording and stream is available | ||
player.on('finishRecord', function() { | ||
// the blob object contains the recorded data that | ||
// can be downloaded by the user, stored on server etc. | ||
console.log('finished recording: ', player.recordedData); | ||
}); | ||
|
||
// converter completed and stream is available | ||
player.on('finishConvert', function() { | ||
// the convertedData object contains the recorded data that | ||
// can be downloaded by the user, stored on server etc. | ||
console.log('finished converting: ', player.convertedData); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# ffmpeg.wasm plugin | ||
|
||
[FFmpeg](https://ffmpeg.org) is the Swiss-army knife of media transcoding. This plugin allows | ||
you to run FFmpeg in the browser and perform on-the-fly transcoding of recorded data. | ||
|
||
This plugin uses [ffmpeg.wasm](https://github.com/ffmpegwasm/ffmpeg.wasm) that provides a | ||
Webassembly / Javascript port of FFmpeg. | ||
|
||
## Example | ||
|
||
- [online demo](https://collab-project.github.io/videojs-record/demo/video-only-ffmpegwasm.html) | ||
- [demo source](https://github.com/collab-project/videojs-record/blob/master/examples/plugins/video-only-ffmpegwasm.html) | ||
|
||
## Usage | ||
|
||
Install the library: | ||
|
||
```console | ||
npm install --save @ffmpeg/ffmpeg @ffmpeg/core | ||
``` | ||
|
||
Include the library and place it before any other scripts: | ||
|
||
```html | ||
<script src="@ffmpeg/ffmpeg/dist/ffmpeg.min.js"></script> | ||
``` | ||
|
||
Import the plugin: | ||
|
||
```javascript | ||
import FFmpegWasmEngine from 'videojs-record/dist/plugins/videojs.record.ffmpeg-wasm.js'; | ||
``` | ||
|
||
And configure the `ffmpeg.wasm` `convertEngine`. For example: | ||
|
||
```javascript | ||
record: { | ||
audio: true, | ||
video: true, | ||
maxLength: 20, | ||
debug: true, | ||
// enable ffmpeg.wasm plugin | ||
convertEngine: 'ffmpeg.wasm', | ||
convertWorkerURL: '../../node_modules/@ffmpeg/core/dist/ffmpeg-core.js', | ||
// convert recorded data to MP4 (and copy over audio data without encoding) | ||
convertOptions: ['-c:v', 'libx264', '-preset', 'slow', '-crf', '22', '-c:a', 'copy', '-f', 'mp4'], | ||
// specify output mime-type | ||
pluginLibraryOptions: { | ||
outputType: 'video/mp4' | ||
} | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
Options for this plugin: | ||
|
||
| Option | Value | Description | | ||
| --- | --- | --- | | ||
| `convertEngine` | `ffmpeg.wasm` | Enables the plugin. | | ||
| `convertOptions` | `['-f', 'mp3', '-codec:a', 'libmp3lame', '-qscale:a', '2']` | Array of arguments for FFmpeg. | | ||
| `pluginLibraryOptions` | `{outputType: 'video/mp4'}` | Specify output mime-type and other options. | | ||
| `convertWorkerURL` | `/path/to/@ffmpeg/core/dist/ffmpeg-core.js` | Specify encoding worker. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.