Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Record Video Elements #184

Open
alfian444 opened this issue Apr 16, 2024 · 1 comment
Open

Cannot Record Video Elements #184

alfian444 opened this issue Apr 16, 2024 · 1 comment

Comments

@alfian444
Copy link

I want to record streaming video but when I check using new MediaRecorder the data size obtained is 0 like the following code

var videoElement=document.getElementById('frame');
player= mpegts.createPlayer({
                            isLive: true,
                            type: format,
                            url: url_stream,
                        },{});
player.attachMediaElement(videoElement);
player.load(function(){
videoElement.play();
  });
player.play();
videoElement.play();

$("#record").click(function(){
let recordedChunks = [];
 var mediaRecorder = new MediaRecorder(videoElement, { mimeType: 'video/webm' });
 mediaRecorder.ondataavailable = function (event) {
            console.log('recordedChunks',event)
            recordedChunks.push(event.data);
            
        };
mediaRecorder.onstop = function () {
            const blob = new Blob(recordedChunks, { type: 'video/webm' });
            const videoUrl = URL.createObjectURL(blob);

            const downloadLink = document.createElement('a');
            downloadLink.href = videoUrl;
            downloadLink.download ='record.webm';
            downloadLink.click();

            URL.revokeObjectURL(videoUrl);
        };
        mediaRecorder.start();
})
$("#stop").click(function(){
   mediaRecorder.stop();
})
@alfian444
Copy link
Author

I found the problem, I can't do MediaRecord maybe because the audio codec I have is "opus" mimeType: 'video/x-matroska;codecs=avc1,opus'
Can I desable the audio?

i tried to add hasAudio:false in MediaDataSource but the stream won't play

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant