admin管理员组文章数量:1422554
I am having trouble with recording canvas as video in mp4 file format. I managed to record the canvas as webm format using RecordRTC. When I tried to give mimetype: video/mp4 it gives an error unable to record as mimetype: video/mp4.
var canvas = document.getElementById('canvas');
var canvasStream = canvas.captureStream();
var finalStream = new MediaStream();
audioStream.getAudioTracks().forEach(function(track) {
finalStream.addTrack(track);
});
canvasStream.getVideoTracks().forEach(function(track) {
finalStream.addTrack(track);
});
var recorder = RecordRTC(finalStream, {
type: 'video',
mimeType: 'video/mp4'
});
recorder.startRecording();
The above code works for webM format. I see no way to record HTML5 canvas to video in mp4 format. I just need to convert it to mp4 from webm. It takes a lot of time. Is there any way to directly record canvas as mp4 without going through the process of first making webm and then converting it to mp4?
Thanks.
I am having trouble with recording canvas as video in mp4 file format. I managed to record the canvas as webm format using RecordRTC. When I tried to give mimetype: video/mp4 it gives an error unable to record as mimetype: video/mp4.
var canvas = document.getElementById('canvas');
var canvasStream = canvas.captureStream();
var finalStream = new MediaStream();
audioStream.getAudioTracks().forEach(function(track) {
finalStream.addTrack(track);
});
canvasStream.getVideoTracks().forEach(function(track) {
finalStream.addTrack(track);
});
var recorder = RecordRTC(finalStream, {
type: 'video',
mimeType: 'video/mp4'
});
recorder.startRecording();
The above code works for webM format. I see no way to record HTML5 canvas to video in mp4 format. I just need to convert it to mp4 from webm. It takes a lot of time. Is there any way to directly record canvas as mp4 without going through the process of first making webm and then converting it to mp4?
Thanks.
Share Improve this question asked Oct 15, 2017 at 6:16 amaidhassan niaziamaidhassan niazi 611 silver badge9 bronze badges 1- 1 Chrome supports recording of h264 codec in webm, might fasten the conversion to mp4 container. But FF only supports vp8... – Kaiido Commented Oct 15, 2017 at 15:13
1 Answer
Reset to default 2Check this article out. In it, they convert canvas animations to mp4, by using socket.io to save canvas frame images to the server and then by using ffmpeg to convert to mp4. Using this method, it is possible to go from capturing frames to mp4 without first creating a webM video. Hope it helps.
Web Archive snapshot
本文标签: javascriptRecording HTML5 canvas animation in mp4 formatStack Overflow
版权声明:本文标题:javascript - Recording HTML5 canvas animation in mp4 format - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745370691a2655717.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论