Saving desktopCapturer to video file from Electron app

后端 未结 1 1550
南笙
南笙 2020-12-18 15:40

Basing on electron api and this question I\'m trying to save recorded user screen to .webm file in videos folder in root app folder.

Actually it\'s almost working be

相关标签:
1条回答
  • 2020-12-18 16:05

    Your recorder.stop() will run as follows: (from MediaRecorder docs)

    When the stop() method is invoked, the UA queues a task that runs the following steps:

    1. If MediaRecorder.state is "inactive", raise a DOM InvalidState error and terminate these steps. If the MediaRecorder.state is not "inactive", continue on to the next step.
    2. Set the MediaRecorder.state to "inactive" and stop capturing media.
    3. Raise a dataavailable event containing the Blob of data that has been gathered.
    4. Raise a stop event.

    In your case you don't wait up the stop event, so dataavailable will fill blobs only after you started the file saving method.

    You have to restructure stopRecording to ensure recorded data is available. For example:

    function stopRecording () {
      const save = () => {
        ...
      }
      recorder.onstop = save
      recorder.stop()
    }
    
    0 讨论(0)
提交回复
热议问题