Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix video element playing black screen instead of video

My video element's src is a blob URL of a video recording (mediaRecorder API). Instead of playing the video, when I hit play it displays a black screen. When I print the video element to the console and right click the source and click "open in new tab", the video plays in a new tab.

This is a chrome extension and I am recording a video (usually 3-5 seconds long) and then trying to playback that same video in a video element.

<video id='recording' width='100%' height='100%' src={this.state.blobURL} type='video/webm' controls></video>
// creating new blob (binary large obj) defining it as an webm file
          let blob = new Blob(buffer, {type:'video/webm'});
          chrome.extension.getBackgroundPage().console.log('this is the blob', blob)

          // convert blob into object URL (can be used as video src)
          let videoURL = URL.createObjectURL(blob)
          t.setState({ blobURL: videoURL, video: blob })

No errors at all, just plays black-screen, please help if you can :)

like image 613
Peter Louis Avatar asked Oct 26 '25 18:10

Peter Louis


1 Answers

Ok so the answer to this is keeping the MIME type consistent throughout. I was not instantiating the stream that was grabbing the video with a MIME type. Once I did, and set the blob to the same, the video played just fine! I used the "video/webm" MIME type

like image 145
Peter Louis Avatar answered Oct 28 '25 09:10

Peter Louis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!