I'm trying to write a script (for a browser extension with tampermonkey) which will use the video players functions to seek to a timestamp and then play the video while capturing the audio from that timestamp.
The video element source is external so when I attempt to set up a stream I get CORS errors eg:
let video = document.getElementById("video-player");
let stream = video.captureStream();
I tried a solution posted elsewhere about getting a readable stream from the video source https://stackoverflow.com/a/57088960/10326441. However I didn't understand how to obtain the capture stream from this, and it still led to the first error shown below. Example errors:
Access to fetch at 'https://***.googleusercontent.com/***' from origin 'https://******.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
Uncaught DOMException: Failed to execute 'captureStream' on 'HTMLMediaElement': Cannot capture from element with cross-origin data
My Question is: is there an easy way I can obtain an audio stream from the video-player? When I click my button it correctly seeks and plays the video, I'm just struggling with obtaining an audio stream from it so I can then convert that to a blob which I can download to disk.