使用WebRTC MediaRecorder录制跨平台(H.264?)视频 [英] Recording cross-platform (H.264?) videos using WebRTC MediaRecorder
问题描述
我在MediaRecorder实现中指定了以下内容:
I have the following specified with my MediaRecorder implementation:
const getMediaRecorderOptions = function () {
var options = { mimeType: "video/webm;codecs=vp8" }; // 9 was lagggy, cpu-intensive
if (!MediaRecorder.isTypeSupported(options.mimeType)) {
logger.recorderLog(options.mimeType + " is not Supported");
options = { mimeType: "video/webm;codecs=vp8" };
if (!MediaRecorder.isTypeSupported(options.mimeType)) {
logger.recorderLog(options.mimeType + " is not Supported");
options = { mimeType: "video/webm" };
if (!MediaRecorder.isTypeSupported(options.mimeType)) {
logger.recorderLog(options.mimeType + " is not Supported");
options = { mimeType: "" };
}
}
}
return options;
}
很明显,这仅适用于 webm ,iOS Safari或MacOS不支持.我试图避免存储空间增加一倍,并避免引入编码复杂性. Chrome上的MediaRecorder有什么方法可以直接从任何平台的 记录到到的跨平台容器格式?
Obviously, this is just for webm which isn't supported on iOS Safari or MacOS. I'm trying to avoid doubling our storage and introducing encoding complexity. Is there any way MediaRecorder on Chrome can record directly to a cross-platform container format, from any platform?
推荐答案
您应该可以录制到webm/h.264
You should be able to record to webm/h.264
var options = {mimeType: 'video/webm;codecs=h264'};
media_recorder = new MediaRecorder(stream, options);
因此,您在WebM容器中拥有正确的跨平台视频格式(H.264).
So you have the right cross platform video format (H.264) in a WebM container.
现在,您可以尝试ffmpeg.js,只需将容器从WebM更改为mp4-应对H.264流-无需转码(-vcodec复制).
Now you could try ffmpeg.js and just change the container from WebM to mp4 - coping the H.264 stream - no transcoding (-vcodec copy).
我在Chrome中录制到了webm/h.264,但是我没有尝试用ffmpeg.js重新包装它.
I recorded to webm/h.264 in Chrome but I didn't try re-wrapping it with ffmpeg.js.
这篇关于使用WebRTC MediaRecorder录制跨平台(H.264?)视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!