优化视频解析

This commit is contained in:
none
2023-03-08 10:50:48 +08:00
parent dbfce61c40
commit 9aeb272519
3 changed files with 64 additions and 19 deletions

View File

@@ -12,7 +12,7 @@ import {
} from "antd";
import Dragger from "antd/es/upload/Dragger";
import { useRef, useState } from "react";
import { generateUUID } from "../../utils";
import { generateUUID, parseVideo } from "../../utils";
import { minioUploadId } from "../../api/upload";
import { UploadChunk } from "../../js/minio-upload-chunk";
import { storeResource } from "../../api/resource";
@@ -52,12 +52,13 @@ export const UploadVideoButton = (props: PropsInterface) => {
multiple: true,
beforeUpload: async (file: File) => {
if (file.type === "video/mp4") {
//添加到本地待上传
let videoInfo = await parseVideo(file);
// 添加到本地待上传
let data = await getMinioUploadId();
let run = new UploadChunk(file, data["upload_id"], data["filename"]);
let item: FileItem = {
id: generateUUID(),
duration: 0,
duration: videoInfo.duration,
name: file.name,
size: file.size,
progress: 0,
@@ -128,20 +129,6 @@ export const UploadVideoButton = (props: PropsInterface) => {
</Button>
<div className="none">
{fileList.length > 0 &&
fileList.map((item) => (
<video
key={item.id}
src={URL.createObjectURL(item.file)}
onCanPlayThrough={(e: any) => {
item.duration = parseInt(e.target.duration);
item.loading = false;
}}
></video>
))}
</div>
{showModal && (
<Modal
width={800}