deepAR.startVideoRecording() does not record anything

Hi everybody,

I’m trying the deepar web sdk and everything works fine for the pictures. But, for the videos, impossible to record any video (return undefined). It seems like the startVideoRecording function merely does not work.
If anybody can help me please… ?
Thanks a lot !

The logic you were using makes it impossible to finish recording because you need to press the record_video button to finish.

Do note that startVideoRecording does not return anything.

Check what you can use from here:

let isRecording = false;
document.getElementById("record_video").onclick = async function () {
  document.getElementById("record_video").innerHTML = "Save Video";
  if (!isRecording) {
    // Start the recording
    isRecording = true;
    await deepAR.startVideoRecording();

    const startTime = performance.now();
    const i = setInterval(function () {
      const timeElapsed = performance.now() - startTime;
      document.getElementById("duration").innerHTML = 'Time elapsed: ' + Math.round(timeElapsed / 1000) + 's';
      if (!isRecording) {
        output.innerHTML = 'Recording finished.'
        clearInterval(i);
      }
    }, 200);
  } else {
    // Stop recording
    isRecording = false;
    const video = await deepAR.finishVideoRecording();

    document.getElementById("record_video").innerHTML = "Record Video";

    // Download video
    const a = document.createElement("a");
    document.body.appendChild(a);
    a.style = "display: none";
    a.href = window.URL.createObjectURL(video);
    a.download = "video.mp4";
    a.click()
    window.URL.revokeObjectURL(a.href);
  }
};```

Hi Igor

Thanks for your reply.

Well I will try your code and will let you know ASAP

Hello Igor,

Yes your code works like a charm !

But there’s no sound. And I don’t understand the solution I found in the forum. It is true that we can’t get audio from recording ?

Thanks for your answer.

As stated in the API reference you need to set the recordAudio parameter when starting the recording: await deepAR.startVideoRecording({recordAudio: true});

Hi Igor,

Well I looked through the documentation and didn’t even see that! But I had developed an alternative solution that works well. However, I will try what the API offers and I will report back. Thank you Igor!

1 Like

Well @igor the solution is perfect! But… there is another problem. Videos are not created when using a mobile device. This SDK can only be used with a PC. As for photos, no problem: it works with all types of devices. Weird !
Concerning the videos, the code is of course absolutely the same regardless of the platform (The code itself is above). I thank in advance whoever can find the explanation for me!

Hello everybody !

Any update about my issue ?

I did some tests with an iPhone and you can make videos apparently without difficulty. The problem only concerns the Android system, where the SDK works for photos, but not for videos… (?).
If anyone has any idea what’s going on, please post! I thank him in advance!