Web MediaRecorder - 无限持续时间和损坏的编解码器

mso*_*zak 6 javascript firefox google-chrome html5-video web-mediarecorder

我想使用网络记录用户网络摄像头流MediaRecorder并生成一个文件,其中包含:

  • 正确设置持续时间(浏览器可以看到和使用,例如 html5 视频播放器在视频处于preload状态时显示正确的持续时间)
  • 正确设置音频和视频轨道的编解码器

在这里您可以看到一个完整的示例(Chrome:54.0.2840.71,Firefox:49.0.2 -> 请使用相对较新的浏览器,因为演示中使用的 API 是最近的):https ://jsfiddle.net/2vr7vL2p/12/除了:

  • 在 chrome 中,持续时间返回Infinity(在 Firefox 中它工作正常)
  • 在Firefox和Chrome浏览器生成的文件已经打破编解码器(例如VLC媒体播放器的回报:VLC does not support the audio or video format "undf". Unfortunately there is no way for you to fix this.

如何解决这些问题?