Skip to content

Let's use AI to Earn!

feat: Support directly obtaining the first frame and information such as width, height, and video duration of the video when uploading materials

gaoSir83d6ed167669
diff --git a/src/app/[lng]/material/album/[id]/page.tsx b/src/app/[lng]/material/album/[id]/page.tsx
index 8394fd4c..68a28a16 100644
--- a/src/app/[lng]/material/album/[id]/page.tsx
+++ b/src/app/[lng]/material/album/[id]/page.tsx
@@ -121,16 +121,6 @@ export default function AlbumPage() {
try {
const url = await uploadToOss(file);
- let thumbUrl: string;
- if (file.type.startsWith('video/')) {
- const res = await VideoGrabFrame(URL.createObjectURL(file), 0);
- const blob = res.cover.file;
- const fileName = file.name.replace(/\.[^/.]+$/, "") + "_cover.png";
- const coverFile = new File([blob], fileName, {
- type: blob.type || "image/png",
- });
- thumbUrl = await uploadToOss(coverFile);
- }
await createMedia({
groupId: albumId,
@@ -138,7 +128,6 @@ export default function AlbumPage() {
url,
title: file.name,
desc: '',
- thumbUrl
});
message.success('上传成功');
diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
index 0f143daf..7659388e 100644
--- a/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
@@ -11,6 +11,7 @@ import { Dropdown, message, Progress, Upload } from "antd";
import {
formatImg,
formatVideo,
+ VideoGrabFrame,
} from "@/components/PublishDialog/PublishDialog.util";
import {
IImgFile,
@@ -183,16 +184,17 @@ const PubParmasTextareaUpload = memo(
imagefile["ossUrl"] = item.url;
onImgUpdateFinish([imagefile]);
} else {
- const coverOss = getOssUrl(item.thumbUrl || "");
+ console.log(item);
+ const videoInfo = await VideoGrabFrame(ossUrl, 0);
const video: any = {
ossUrl: ossUrl,
videoUrl: ossUrl,
- cover: {
- ossUrl: coverOss,
- imgUrl: coverOss,
- },
+ width: videoInfo.width,
+ height: videoInfo.height,
+ duration: videoInfo.duration,
+ size: item.metadata.size,
+ cover: videoInfo.cover,
};
- console.log(video);
onVideoUpdateFinish(video);
}
} catch (e) {
diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
index dad7fcc9..64a30fb2 100644
--- a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
@@ -309,7 +309,6 @@ const PubParmasTextarea = memo(
videoUrl={(previewData as IVideoFile)?.videoUrl}
onCancel={() => setPreviewData(undefined)}
/>
-
<ImageEditorModal
onOk={(editedImg) => {
setImageFileList((prevState) => {
@@ -466,7 +465,7 @@ const PubParmasTextarea = memo(
</ReactSortable>
{/* 裁剪 */}
- {videoFile && videoFile.file && (
+ {videoFile && (
<Button
style={{ marginTop: "10px" }}
onClick={() => setVideoCoverSetingModal(true)}
diff --git a/src/utils/oss.ts b/src/utils/oss.ts
index 9990a701..47ee5107 100644
--- a/src/utils/oss.ts
+++ b/src/utils/oss.ts
@@ -1,9 +1,6 @@
-// 获取OSS域名
-import { OSS_URL } from "@/constant";
-
// 获取完整的OSS URL
export const getOssUrl = (path: string) => {
if (!path) return "";
if (path.startsWith("http") || path.startsWith("https")) return path;
- return `${OSS_URL}${path}`;
+ return `${process.env.NEXT_PUBLIC_OSS_URL_PROXY}${path}`;
};