Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(local-recordings) remove recording time limit
Saúl Ibarra Corretgé607073c6694c
diff --git a/package-lock.json b/package-lock.jsonindex b5a9e0c72f..3873df7a83 100644--- a/package-lock.json+++ b/package-lock.json@@ -116,7 +116,6 @@"util": "0.12.1","uuid": "8.3.2","wasm-check": "2.0.1",- "webm-duration-fix": "1.0.4","windows-iana": "3.1.0","zxcvbn": "4.4.2"},@@ -11926,11 +11925,6 @@"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==","dev": true},- "node_modules/ebml-block": {- "version": "1.1.2",- "resolved": "https://registry.npmjs.org/ebml-block/-/ebml-block-1.1.2.tgz",- "integrity": "sha512-HgNlIsRFP6D9VKU5atCeHRJY7XkJP8bOe8yEhd8NB7B3b4++VWTyauz6g650iiPmLfPLGlVpoJmGSgMfXDYusg=="- },"node_modules/ecdsa-sig-formatter": {"version": "1.0.11","resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",@@ -15146,14 +15140,6 @@"node": ">=18"}},- "node_modules/int64-buffer": {- "version": "1.0.1",- "resolved": "https://registry.npmjs.org/int64-buffer/-/int64-buffer-1.0.1.tgz",- "integrity": "sha512-+3azY4pXrjAupJHU1V9uGERWlhoqNswJNji6aD/02xac7oxol508AsMC5lxKhEqyZeDFy3enq5OGWXF4u75hiw==",- "engines": {- "node": ">= 4.5.0"- }- },"node_modules/internal-slot": {"version": "1.1.0","resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz",@@ -24784,40 +24770,6 @@"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz","integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="},- "node_modules/webm-duration-fix": {- "version": "1.0.4",- "resolved": "https://registry.npmjs.org/webm-duration-fix/-/webm-duration-fix-1.0.4.tgz",- "integrity": "sha512-kvhmSmEnuohtK+j+mJswqCCM2ViKb9W8Ch0oAxcaeUvpok5CsMORQLnea+CYKDXPG6JH12H0CbRK85qhfeZLew==",- "dependencies": {- "buffer": "^6.0.3",- "ebml-block": "^1.1.2",- "events": "^3.3.0",- "int64-buffer": "^1.0.1"- }- },- "node_modules/webm-duration-fix/node_modules/buffer": {- "version": "6.0.3",- "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",- "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",- "funding": [- {- "type": "github",- "url": "https://github.com/sponsors/feross"- },- {- "type": "patreon",- "url": "https://www.patreon.com/feross"- },- {- "type": "consulting",- "url": "https://feross.org/support"- }- ],- "dependencies": {- "base64-js": "^1.3.1",- "ieee754": "^1.2.1"- }- },"node_modules/webpack": {"version": "5.95.0","resolved": "https://registry.npmjs.org/webpack/-/webpack-5.95.0.tgz",@@ -33888,11 +33840,6 @@"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==","dev": true},- "ebml-block": {- "version": "1.1.2",- "resolved": "https://registry.npmjs.org/ebml-block/-/ebml-block-1.1.2.tgz",- "integrity": "sha512-HgNlIsRFP6D9VKU5atCeHRJY7XkJP8bOe8yEhd8NB7B3b4++VWTyauz6g650iiPmLfPLGlVpoJmGSgMfXDYusg=="- },"ecdsa-sig-formatter": {"version": "1.0.11","resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",@@ -36190,11 +36137,6 @@"rxjs": "^7.8.1"}},- "int64-buffer": {- "version": "1.0.1",- "resolved": "https://registry.npmjs.org/int64-buffer/-/int64-buffer-1.0.1.tgz",- "integrity": "sha512-+3azY4pXrjAupJHU1V9uGERWlhoqNswJNji6aD/02xac7oxol508AsMC5lxKhEqyZeDFy3enq5OGWXF4u75hiw=="- },"internal-slot": {"version": "1.1.0","resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz",@@ -42956,28 +42898,6 @@"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz","integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="},- "webm-duration-fix": {- "version": "1.0.4",- "resolved": "https://registry.npmjs.org/webm-duration-fix/-/webm-duration-fix-1.0.4.tgz",- "integrity": "sha512-kvhmSmEnuohtK+j+mJswqCCM2ViKb9W8Ch0oAxcaeUvpok5CsMORQLnea+CYKDXPG6JH12H0CbRK85qhfeZLew==",- "requires": {- "buffer": "^6.0.3",- "ebml-block": "^1.1.2",- "events": "^3.3.0",- "int64-buffer": "^1.0.1"- },- "dependencies": {- "buffer": {- "version": "6.0.3",- "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",- "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",- "requires": {- "base64-js": "^1.3.1",- "ieee754": "^1.2.1"- }- }- }- },"webpack": {"version": "5.95.0","resolved": "https://registry.npmjs.org/webpack/-/webpack-5.95.0.tgz",diff --git a/package.json b/package.jsonindex 6de0f6245b..d7b5245885 100644--- a/package.json+++ b/package.json@@ -122,7 +122,6 @@"util": "0.12.1","uuid": "8.3.2","wasm-check": "2.0.1",- "webm-duration-fix": "1.0.4","windows-iana": "3.1.0","zxcvbn": "4.4.2"},diff --git a/react/features/recording/components/Recording/LocalRecordingManager.native.ts b/react/features/recording/components/Recording/LocalRecordingManager.native.tsindex 4547640110..8228b33245 100644--- a/react/features/recording/components/Recording/LocalRecordingManager.native.ts+++ b/react/features/recording/components/Recording/LocalRecordingManager.native.ts@@ -3,6 +3,7 @@ import { IStore } from '../../../app/types';interface ILocalRecordingManager {addAudioTrackToLocalRecording: (track: any) => void;isRecordingLocally: () => boolean;+ isSupported: () => boolean;selfRecording: {on: boolean;withVideo: boolean;@@ -40,6 +41,15 @@ const LocalRecordingManager: ILocalRecordingManager = {*/async startLocalRecording() { }, // eslint-disable-line @typescript-eslint/no-empty-function+ /**+ * Whether or not local recording is supported.+ *+ * @returns {boolean}+ */+ isSupported() {+ return false;+ },+/*** Whether or not we're currently recording locally.*diff --git a/react/features/recording/components/Recording/LocalRecordingManager.web.ts b/react/features/recording/components/Recording/LocalRecordingManager.web.tsindex fcd033d434..18ed526ad0 100644--- a/react/features/recording/components/Recording/LocalRecordingManager.web.ts+++ b/react/features/recording/components/Recording/LocalRecordingManager.web.ts@@ -1,11 +1,12 @@import i18next from 'i18next';import { v4 as uuidV4 } from 'uuid';-import fixWebmDuration from 'webm-duration-fix';import { IStore } from '../../../app/types';import { getRoomName } from '../../../base/conference/functions';import { MEDIA_TYPE } from '../../../base/media/constants';import { getLocalTrack, getTrackState } from '../../../base/tracks/functions';+import { isMobileBrowser } from '../../../base/environment/utils';+import { browser } from '../../../base/lib-jitsi-meet';import { isEmbedded } from '../../../base/util/embedUtils';import { stopLocalVideoRecording } from '../../actions.any';@@ -18,63 +19,54 @@ interface ILocalRecordingManager {addAudioTrackToLocalRecording: (track: MediaStreamTrack) => void;audioContext: AudioContext | undefined;audioDestination: MediaStreamAudioDestinationNode | undefined;+ fileHandle: FileSystemFileHandle | undefined;getFilename: () => string;initializeAudioMixer: () => void;isRecordingLocally: () => boolean;+ isSupported: () => boolean;mediaType: string;mixAudioStream: (stream: MediaStream) => void;recorder: MediaRecorder | undefined;- recordingData: Blob[];roomName: string;- saveRecording: (recordingData: Blob[], filename: string) => void;selfRecording: ISelfRecording;startLocalRecording: (store: IStore, onlySelf: boolean) => Promise<void>;stopLocalRecording: () => void;stream: MediaStream | undefined;- totalSize: number;+ writableStream: FileSystemWritableFileStream | undefined;}-const getMimeType = (): string => {- const possibleTypes = [- 'video/webm;codecs=vp8'- ];-- for (const type of possibleTypes) {- if (MediaRecorder.isTypeSupported(type)) {- return type;- }- }- throw new Error('No MIME Type supported by MediaRecorder');-};+/**+ * We want to use the MP4 container due to it not suffering from the resulting file+ * not being seek-able.+ *+ * The choice of VP9 as the video codec and Opus as the audio codec is for compatibility.+ * While Chrome does support avc1 and avc3 (we'd need the latter since the resolution can change)+ * it's not supported across the board.+ */+const PREFERRED_MEDIA_TYPE = 'video/mp4;codecs=vp9,opus';const VIDEO_BIT_RATE = 2500000; // 2.5Mbps in bits-const MAX_SIZE = 1073741824; // 1GB in bytes-// Lazily initialize.-let preferredMediaType: string;const LocalRecordingManager: ILocalRecordingManager = {- recordingData: [],recorder: undefined,stream: undefined,audioContext: undefined,audioDestination: undefined,roomName: '',- totalSize: MAX_SIZE,selfRecording: {on: false,withVideo: false},+ fileHandle: undefined,+ writableStream: undefined,get mediaType() {if (this.selfRecording.on && !this.selfRecording.withVideo) {return 'audio/webm;';}- if (!preferredMediaType) {- preferredMediaType = getMimeType();- }- return preferredMediaType;+ return PREFERRED_MEDIA_TYPE;},/**@@ -128,27 +120,6 @@ const LocalRecordingManager: ILocalRecordingManager = {return `${this.roomName}_${timestamp}`;},- /**- * Saves local recording to file.- *- * @param {Array} recordingData - The recording data.- * @param {string} filename - The name of the file.- * @returns {void}- * */- async saveRecording(recordingData, filename) {- // @ts-ignore- const blob = await fixWebmDuration(new Blob(recordingData, { type: this.mediaType }));- const url = URL.createObjectURL(blob);- const a = document.createElement('a');-- const extension = this.mediaType.slice(this.mediaType.indexOf('/') + 1, this.mediaType.indexOf(';'));-- a.style.display = 'none';- a.href = url;- a.download = `${filename}.${extension}`;- a.click();- },-/*** Stops local recording.*@@ -160,12 +131,10 @@ const LocalRecordingManager: ILocalRecordingManager = {this.recorder = undefined;this.audioContext = undefined;this.audioDestination = undefined;- this.totalSize = MAX_SIZE;- setTimeout(() => {- if (this.recordingData.length > 0) {- this.saveRecording(this.recordingData, this.getFilename());- }- }, 1000);+ this.writableStream?.close().then(() => {+ this.fileHandle = undefined;+ this.writableStream = undefined;+ });}},@@ -179,13 +148,23 @@ const LocalRecordingManager: ILocalRecordingManager = {async startLocalRecording(store, onlySelf) {const { dispatch, getState } = store;+ this.roomName = getRoomName(getState()) ?? '';++ // Get a handle to the file we are going to write.+ const options = {+ startIn: 'downloads',+ suggestedName: `${this.getFilename()}.mp4`,+ };++ // @ts-expect-error+ this.fileHandle = await window.showSaveFilePicker(options);+ this.writableStream = await this.fileHandle?.createWritable();+// @ts-ignoreconst supportsCaptureHandle = Boolean(navigator.mediaDevices.setCaptureHandleConfig) && !isEmbedded();const tabId = uuidV4();this.selfRecording.on = onlySelf;- this.recordingData = [];- this.roomName = getRoomName(getState()) ?? '';let gdmStream: MediaStream = new MediaStream();const tracks = getTrackState(getState());@@ -280,13 +259,9 @@ const LocalRecordingManager: ILocalRecordingManager = {mimeType: this.mediaType,videoBitsPerSecond: VIDEO_BIT_RATE});- this.recorder.addEventListener('dataavailable', e => {- if (e.data && e.data.size > 0) {- this.recordingData.push(e.data);- this.totalSize -= e.data.size;- if (this.totalSize <= 0) {- dispatch(stopLocalVideoRecording());- }+ this.recorder.addEventListener('dataavailable', async e => {+ if (this.recorder && e.data && e.data.size > 0) {+ await this.writableStream?.write(e.data);}});@@ -308,6 +283,22 @@ const LocalRecordingManager: ILocalRecordingManager = {this.recorder.start(5000);},+ /**+ * Whether or not local recording is supported.+ *+ * @returns {boolean}+ */+ isSupported() {+ return browser.isChromiumBased()+ && !browser.isElectron()+ && !browser.isReactNative()+ && !isMobileBrowser()++ // @ts-expect-error+ && typeof window.showSaveFilePicker !== 'undefined'+ && MediaRecorder.isTypeSupported(PREFERRED_MEDIA_TYPE);+ },+/*** Whether or not we're currently recording locally.*diff --git a/react/features/recording/functions.ts b/react/features/recording/functions.tsindex 5065d623c5..36001d728b 100644--- a/react/features/recording/functions.ts+++ b/react/features/recording/functions.ts@@ -1,10 +1,9 @@import i18next from 'i18next';import { IReduxState, IStore } from '../app/types';-import { isMobileBrowser } from '../base/environment/utils';import { MEET_FEATURES } from '../base/jwt/constants';import { isJwtFeatureEnabled } from '../base/jwt/functions';-import { JitsiRecordingConstants, browser } from '../base/lib-jitsi-meet';+import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';import { getSoundFileSrc } from '../base/media/functions';import { getLocalParticipant, getRemoteParticipants } from '../base/participants/functions';import { registerSound, unregisterSound } from '../base/sounds/actions';@@ -152,8 +151,7 @@ export function getSessionStatusToShow(state: IReduxState, mode: string): string* @returns {boolean} - Whether local recording is supported or not.*/export function supportsLocalRecording() {- return browser.isChromiumBased() && !browser.isElectron() && !isMobileBrowser()- && navigator.product !== 'ReactNative';+ return LocalRecordingManager.isSupported();}/**