This commit is contained in:
sim1222 2022-01-27 23:39:32 +09:00
parent 7249b11f70
commit 9fb25cd860

View File

@ -41,12 +41,17 @@ function select(src: any, label: string | null, multiple: boolean): Promise<Driv
var infilename = files[0].name; var infilename = files[0].name;
var outfilename = infilename.replace(/\.[^/.]+$/, '') + '.mp4'; var outfilename = infilename.replace(/\.[^/.]+$/, '') + '.mp4';
const befFile = new Uint8Array(await readFromBlobOrFile(files[0])); const befFile = new Uint8Array(await readFromBlobOrFile(files[0]));
os.toast('Loading FFmpeg.wasm')
if (!ffmpeg.isLoaded()) { if (!ffmpeg.isLoaded()) {
os.toast('Loading FFmpeg.wasm-core')
await ffmpeg.load(); await ffmpeg.load();
} }
ffmpeg.FS('writeFile', infilename, await fetchFile(befFile)); ffmpeg.FS('writeFile', infilename, await fetchFile(befFile));
os.toast('Converting')
await ffmpeg.run(['-i', `video.avi`, '-c:v', 'copy', '-c:a', 'copy', `video.mp4`]); await ffmpeg.run(['-i', `video.avi`, '-c:v', 'copy', '-c:a', 'copy', `video.mp4`]);
os.toast('Converted')
const aftFile = await ffmpeg.FS('readFile', outfilename); const aftFile = await ffmpeg.FS('readFile', outfilename);
os.toast('Uploading')
os.upload(aftFile, defaultStore.state.uploadFolder).then(res).catch(e => {os.alert({type: 'error', text: e})}); os.upload(aftFile, defaultStore.state.uploadFolder).then(res).catch(e => {os.alert({type: 'error', text: e})});
} }