wip
This commit is contained in:
parent
487555c42f
commit
67668849d6
@ -9,8 +9,7 @@ import { createFFmpeg, fetchFile } from '@ffmpeg/ffmpeg';
|
|||||||
function select(src: any, label: string | null, multiple: boolean): Promise<DriveFile | DriveFile[]> {
|
function select(src: any, label: string | null, multiple: boolean): Promise<DriveFile | DriveFile[]> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
|
|
||||||
const ffmpeg = createFFmpeg({ log: true });
|
|
||||||
|
|
||||||
const chooseFileFromPc = () => {
|
const chooseFileFromPc = () => {
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.type = 'file';
|
input.type = 'file';
|
||||||
@ -29,6 +28,7 @@ function select(src: any, label: string | null, multiple: boolean): Promise<Driv
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const ffmpeg = createFFmpeg({ log: true });
|
||||||
const ffmpegconv = async ({ target: { files } }) => {
|
const ffmpegconv = async ({ target: { files } }) => {
|
||||||
os.toast('Start const ffmpegconv');
|
os.toast('Start const ffmpegconv');
|
||||||
var infilename = files[0].name;
|
var infilename = files[0].name;
|
||||||
@ -40,13 +40,14 @@ function select(src: any, label: string | null, multiple: boolean): Promise<Driv
|
|||||||
os.toast('Loading FFmpeg.wasm-core')
|
os.toast('Loading FFmpeg.wasm-core')
|
||||||
await ffmpeg.load();
|
await ffmpeg.load();
|
||||||
}
|
}
|
||||||
|
os.toast('Set ffmpeg files')
|
||||||
ffmpeg.FS('writeFile', infilename, await fetchFile(befFile));
|
ffmpeg.FS('writeFile', infilename, await fetchFile(befFile));
|
||||||
os.toast('Converting')
|
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')
|
os.toast('Converted')
|
||||||
const aftFile = await ffmpeg.FS('readFile', outfilename);
|
const aftFile = await ffmpeg.FS('readFile', outfilename);
|
||||||
os.toast('Uploading')
|
os.toast('Uploading')
|
||||||
os.upload(aftFile, defaultStore.state.uploadFolder).then(res).catch(e => { os.alert({ type: 'error', text: e }) });
|
os.upload(aftFile.buffer, defaultStore.state.uploadFolder).then(res).catch(e => { os.alert({ type: 'error', text: e }) });
|
||||||
};
|
};
|
||||||
|
|
||||||
const promises = Array.from(input.files).map(file => os.upload(file, defaultStore.state.uploadFolder));
|
const promises = Array.from(input.files).map(file => os.upload(file, defaultStore.state.uploadFolder));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user