final touch up
This commit is contained in:
parent
a6b38ac020
commit
8788a7cd48
|
@ -12,18 +12,16 @@ class FFmpegService {
|
|||
async init() {
|
||||
try {
|
||||
this.ffmpeg = createFFmpeg({
|
||||
log: true,
|
||||
...(!process.env.NEXT_PUBLIC_SENTRY_ENV && {
|
||||
corePath: '/js/ffmpeg/ffmpeg-core.js',
|
||||
}),
|
||||
});
|
||||
console.log('Loading ffmpeg-core.js');
|
||||
this.isLoading = this.ffmpeg.load();
|
||||
await this.isLoading;
|
||||
this.isLoading = null;
|
||||
console.log('ffmpeg loaded');
|
||||
} catch (e) {
|
||||
throw Error('ffmpeg load failed');
|
||||
logError(e, 'ffmpeg load failed');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +37,6 @@ class FFmpegService {
|
|||
);
|
||||
|
||||
const thumbnail = await response.promise;
|
||||
console.log(URL.createObjectURL(thumbnail));
|
||||
if (!thumbnail) {
|
||||
throw Error(CustomError.THUMBNAIL_GENERATION_FAILED);
|
||||
}
|
||||
|
@ -70,7 +67,6 @@ async function generateThumbnailHelper(ffmpeg: FFmpeg, file: File) {
|
|||
ffmpeg.FS('unlink', file.name);
|
||||
return thumb;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
logError(e, 'ffmpeg thumbnail generation failed');
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,12 @@ export async function generateThumbnail(
|
|||
if (fileType === FILE_TYPE.IMAGE) {
|
||||
canvas = await generateImageThumbnail(file, isHEIC);
|
||||
} else {
|
||||
const thumb = await FFmpegService.generateThumbnail(file);
|
||||
return { thumbnail: thumb, hasStaticThumbnail: false };
|
||||
try {
|
||||
const thumb = await FFmpegService.generateThumbnail(file);
|
||||
return { thumbnail: thumb, hasStaticThumbnail: false };
|
||||
} catch (e) {
|
||||
canvas = await generateVideoThumbnail(file);
|
||||
}
|
||||
}
|
||||
const thumbnailBlob = await thumbnailCanvasToBlob(canvas);
|
||||
thumbnail = await worker.getUint8ArrayView(thumbnailBlob);
|
||||
|
@ -34,8 +38,7 @@ export async function generateThumbnail(
|
|||
throw Error('EMPTY THUMBNAIL');
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
logError(e);
|
||||
logError(e, 'uploading static thumbnail');
|
||||
thumbnail = Uint8Array.from(atob(BLACK_THUMBNAIL_BASE64), (c) =>
|
||||
c.charCodeAt(0)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue