pull/2038/head
Mikael Finstad 2024-05-15 15:07:54 +02:00
rodzic 8a01a928a1
commit 8e361077a8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 25AB36E3E81CBC26
2 zmienionych plików z 13 dodań i 7 usunięć

Wyświetl plik

@ -28,6 +28,15 @@ export class RefuseOverwriteError extends Error {
}
}
export function fixRemoteBuffer(buffer: Buffer) {
// if we don't do this when creating a Blob, we get:
// "Failed to construct 'Blob': The provided ArrayBufferView value must not be resizable."
// maybe when moving away from @electron/remote, it's not needed anymore?
const buffer2 = Buffer.allocUnsafe(buffer.length);
buffer.copy(buffer2);
return buffer2;
}
export function logStdoutStderr({ stdout, stderr }: { stdout: Buffer, stderr: Buffer }) {
if (stdout.length > 0) {
console.log('%cSTDOUT:', 'color: green; font-weight: bold');
@ -492,7 +501,7 @@ async function renderThumbnail(filePath: string, timestamp: number) {
const { stdout } = await runFfmpeg(args);
const blob = new Blob([stdout], { type: 'image/jpeg' });
const blob = new Blob([fixRemoteBuffer(stdout)], { type: 'image/jpeg' });
return URL.createObjectURL(blob);
}
@ -507,7 +516,7 @@ export async function extractSubtitleTrack(filePath: string, streamId: number) {
const { stdout } = await runFfmpeg(args);
const blob = new Blob([stdout], { type: 'text/vtt' });
const blob = new Blob([fixRemoteBuffer(stdout)], { type: 'text/vtt' });
return URL.createObjectURL(blob);
}

Wyświetl plik

@ -3,7 +3,7 @@ import sortBy from 'lodash/sortBy';
import { useThrottle } from '@uidotdev/usehooks';
import { waveformColorDark, waveformColorLight } from '../colors';
import { renderWaveformPng } from '../ffmpeg';
import { fixRemoteBuffer, renderWaveformPng } from '../ffmpeg';
import { RenderableWaveform } from '../types';
import { FFprobeStream } from '../../../../ffprobe';
@ -73,12 +73,9 @@ export default ({ darkMode, filePath, relevantTime, duration, waveformEnabled, a
return w;
}
// if we don't do this, we get Failed to construct 'Blob': The provided ArrayBufferView value must not be resizable.
const buffer2 = Buffer.allocUnsafe(buffer.length);
buffer.copy(buffer2);
return {
...w,
url: URL.createObjectURL(new Blob([buffer2], { type: 'image/png' })),
url: URL.createObjectURL(new Blob([fixRemoteBuffer(buffer)], { type: 'image/png' })),
};
}));
} catch (err) {