Files
PCAdmissionOfficer/1.html
DESKTOP-RQ919RC\Pc 0e5f3f32cf refactor(ui): 重构箭头图标布局和样式
优化箭头图标的布局方式,将直接定位改为通过容器相对定位
修复箭头图标在不同状态下的对齐问题
调整专业名称的显示样式防止换行
2025-08-11 18:57:33 +08:00

52 lines
1.9 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>H.265 硬解码 (WebCodecs)</title>
</head>
<body>
<script src="https://unpkg.com/@ffmpeg/ffmpeg@0.10.0/dist/ffmpeg.min.js"></script>
<canvas id="canvas" width="1280" height="720"></canvas>
<script>
const { createFFmpeg, fetchFile } = FFmpeg;
const ffmpeg = createFFmpeg({ log: true });
async function transcodeToH265(inputFile) {
// 确保FFmpeg加载
if (!ffmpeg.isLoaded()) {
await ffmpeg.load();
}
// 将输入文件写入FFmpeg的文件系统
ffmpeg.FS("writeFile", "input.mp4", await fetchFile(inputFile));
// 执行转码命令将输入文件转码为H.265编码输出为output.mp4
await ffmpeg.run("-i", "input.mp4", "-c:v", "libx265", "output.mp4");
// 从FFmpeg文件系统中读取输出文件
const data = ffmpeg.FS("readFile", "output.mp4");
// 创建Blob和URL以供下载
const outputUrl = URL.createObjectURL(new Blob([data.buffer], { type: "video/mp4" }));
return outputUrl;
}
// 使用示例:当用户选择文件后
document.getElementById("fileInput").addEventListener("change", async (e) => {
const file = e.target.files[0];
if (!file) return;
const outputUrl = await transcodeToH265(file);
// 创建一个下载链接
const a = document.createElement("a");
a.href = outputUrl;
a.download = "output_h265.mp4";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
});
</script>
</body>
</html>