Skip to content

MediaRecorder - can't use audio mime types #3317

@FredericoCoelhoNunes

Description

@FredericoCoelhoNunes

What page(s) did you find the problem on?

No page in particular, I just feel like the documentation is extremely confusing on how to record audio only streams. See example below.

Specific page section or heading?

N/A

What is the problem?

I expected to be able to record audio blobs following a call to navigator.mediaDevices.getUserMedia({audio: true, video: false}) but it seems like only video mime types are available.

What did you expect to see?

Expected to be able to, for example, record audio/mp4 blobs.

Did you test this? If so, how?

The following block of code throws the error: Uncaught (in promise) DOMException: MediaRecorder constructor: Video cannot be recorded with audio/mp4 as it is an audio type
This is not a helpful error message at all because I am not trying to record any video.

navigator.mediaDevices.getUserMedia({audio: true}).then((stream) => {
    
    var mediaRecorder = new MediaRecorder(stream, {mimeType: 'audio/mp4'});

    mediaRecorder.ondataavailable = function(event) {
        var blob = event.data;
        if (blob && blob.size > 0) {
            sendBlobToServer(blob);
        }
    };

    mediaRecorder.start(5000);
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Content:MediaMedia docseffort: mediumThis task is a medium effort.help wantedIf you know something about this topic, we would love your help!p2Minor issue with low priority, can be fixed later.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions