|
@@ -117,16 +117,22 @@ const UploadFile: React.FC<Props> = ({ visible, onClose, folderId, userId, onCha
|
|
|
height = imgData.height
|
|
|
} else if (queryForm.materialType === "video") {
|
|
|
const videoInfo: { width: number, height: number, videoLength: number }[] = await videoMessage([file])
|
|
|
- const readChunk = async (chunkSize: number, offset: number) => new Uint8Array(await file.slice(offset, offset + chunkSize).arrayBuffer());
|
|
|
- // @ts-ignore
|
|
|
- const mediaInfo = await MediaInfo.mediaInfoFactory({ format: 'object' })
|
|
|
- const result = await mediaInfo.analyzeData(file.size, readChunk)
|
|
|
- if (result?.media?.track) {
|
|
|
- const { Height, Width, Duration } = result?.media?.track.find((item: { [x: string]: string }) => item['@type'] === 'Video')
|
|
|
- width = Width
|
|
|
- height = Height
|
|
|
- videoDuration = Duration
|
|
|
- } else {
|
|
|
+ try {
|
|
|
+ const readChunk = async (chunkSize: number, offset: number) => new Uint8Array(await file.slice(offset, offset + chunkSize).arrayBuffer());
|
|
|
+ // @ts-ignore
|
|
|
+ const mediaInfo = await MediaInfo.mediaInfoFactory({ format: 'object' })
|
|
|
+ const result = await mediaInfo.analyzeData(file.size, readChunk)
|
|
|
+ if (result?.media?.track) {
|
|
|
+ const { Height, Width, Duration } = result?.media?.track.find((item: { [x: string]: string }) => item['@type'] === 'Video')
|
|
|
+ width = Width
|
|
|
+ height = Height
|
|
|
+ videoDuration = Duration
|
|
|
+ } else {
|
|
|
+ width = videoInfo[0].width
|
|
|
+ height = videoInfo[0].height
|
|
|
+ videoDuration = videoInfo[0].videoLength
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
width = videoInfo[0].width
|
|
|
height = videoInfo[0].height
|
|
|
videoDuration = videoInfo[0].videoLength
|