问题
I am trying to learn how to record media in the browser and I may be over-complicating things. There is an abundant supply of straight-forward examples but I got bogged down at the part when the recordings are pushed to a Blob
object with an arbitrarily selected media type without checking whether that format is supported. Therefore I assume there is a list or people just keep building on past experiences.
For example, from Mido22/MediaRecorder-sample:
mediaOptions = {
video: {
tag: 'video',
type: 'video/webm',
ext: '.mp4',
gUM: {video: true, audio: true}
},
audio: {
tag: 'audio',
type: 'audio/ogg',
ext: '.ogg',
gUM: {audio: true}
}
};
media = mv.checked ? mediaOptions.video : mediaOptions.audio;
//...
function makeLink(){
let blob = new Blob(chunks, {type: media.type })
//...
or from MDN's Using the Media Stream Recording API:
var blob = new Blob(chunks, { 'type' : 'audio/ogg; codecs=opus' });
The specs and their various documentations are mostly generic descriptions which is completely understandable as user agents need to implement them.
The first answer to this question is pretty much what I had in mind but I was wondering whether there is an easier accessible and up-to-date list somewhere?
UPDATE: I pretty much feel like as if I just crawled out from under a rock because as soon as I posted this I realized the 2 most obvious ways...
- Query the media format on http://caniuse.com/
- MDN's Supported Media Formats
After @Kaiido's pointers:
- Media Recorder API's isTypeSupported
- getSupportedTypes()
来源:https://stackoverflow.com/questions/42048368/where-is-a-comprehensive-list-of-supported-media-types-when-recording-with-the-m