HTML5调用摄像头录制视频

这篇博客介绍了如何利用HTML5的WebRTC API来调用摄像头并录制视频,特别指出该方法不适用于不支持WebRTC的IE浏览器,并提到了fileSaver.js库在保存录制视频时的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

HTML5调用摄像头录制视频

  1. 不支持ie,ie下不支持webrtc,无法使用navigator.getUserMedia调用摄像头

<!DOCTYPE html>
<html>

<head>
    <title>video recoder</title>
    <script src="fileSaver.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<style>
    body{
        background-color:#EFEDEF;
    }
</style>
<body>
    <article style="border:1px solid white;width:400px;height:400px;margin:0 auto;background-color:white;">

        <section class="experiment" style="width:320px; height:240px;border:1px solid green; margin:50px auto;">
            <div id="videos-container" style="width:320px; height:240px;">
            </div>
        </section>
        <section class="experiment" style="text-align:center;border:none; margin-top:20px;">
            <button id="openCamera">打开摄像头</button>
            <button id="start-recording" disabled>开始录制</button>
            <button id="save-recording" disabled>保存</button>
            <!--<a href="javascript:void(0)" onclick="send()">发送</a>-->
        </section>
 </article>
<script>
            var mediaStream;
            var recorderFile;
            var stopRecordCallback;
            var openBtn = document.getElementById("openCamera");
            var startBtn = document.getElementById("start-recording");
            var saveBtn = document.getElementById("save-recording");
            openBtn.onclick = function() {
    
                this.disabled = true;
                startBtn.disabled=false;
                openCamera();
            };

            startBtn.onclick = function() {
    
                this.disabled = 
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值