浏览器中使用WebCodecs web api实现离线摄像头屏幕麦克风录像剪辑导出mp4视频代码
代码语言:html
所属分类:多媒体
代码描述:浏览器中使用WebCodecs web api实现离线摄像头屏幕麦克风录像剪辑导出mp4视频代码,适合教学录屏,授课的视频录制,离线就能实现,打开网页就能录制,还能在线剪辑保留需要的片段导出mp4视频到本地。
代码标签: 浏览器 使用 WebCodecs web api 离线 摄像头 屏幕 麦克风 录像 剪辑 导出 m
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!doctype html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <title>静默录制 + 可视化剪辑 → 导出 MP4(H264)</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> body{font-family:system-ui,Arial,Helvetica;background:#f5f5f5;margin:0;padding:2rem;display:flex;flex-direction:column;align-items:center} h1{margin:0 0 1rem;font-size:1.4rem} #preview{width:640px;height:360px;border-radius:8px;background:#000} #timeline{position:relative;width:640px;height:80px;background:#222;border-radius:4px;margin-top:8px;cursor:ew-resize;-webkit-user-select:none;user-select:none} .thumb{float:left;height:100%;background-size:cover;background-position:center} .range{position:absolute;top:0;height:100%;background:rgba(0,180,255,.35);border-left:2px solid #0bf;border-right:2px solid #0bf;box-sizing:border-box} .row{margin-top:1rem;display:flex;gap:.8rem;align-items:center} button{padding:.6rem 1.2rem;font-size:1rem;border:none;border-radius:4px;cursor:pointer} #startBtn{background:#28a745;color:#fff} #stopBtn{background:#dc3545;color:#fff} #exportBtn{background:#007bff;color:#fff;display:none} #status{margin-left:.8rem;font-size:.9rem;color:#444} #progWrap{width:640px;height:10px;background:#ddd;border-radius:5px;margin-top:.8rem;display:none;overflow:hidden} #progressBar{height:100%;width:0;background:#28a745;transition:width .2s} </style> </head> <body> <h1>静默录制 + 可视化剪辑 → 导出 MP4(H264)</h1> <video id="preview" controls muted style="display:none"></video> <div id="timeline"> <div class="range" id="range"></div> </div> <div class="row"> <button id="startBtn">开始录制</button> <button id="stopBtn" disabled>停止录制</button> <button id="exportBtn">导出 MP4</button> <span id="status">就绪</span> </div> <div id="progWrap"><div id="progressBar"></div></div> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0