1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-23 02:42:37 +01:00
This commit is contained in:
Mikael Finstad 2022-02-23 19:01:14 +08:00
parent dfffd04b94
commit 7136e3677c
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

View File

@ -1404,10 +1404,11 @@ const App = memo(() => {
} }
try { try {
const { fileFormat: ff, formatData: fd, chapters: ch, streams } = await readFileMeta(fp); const fileMeta = await readFileMeta(fp);
// console.log('file meta read', ff); // console.log('file meta read', fileMeta);
if (!ff) throw new Error('Unable to determine file format'); const { streams } = fileMeta;
if (!fileMeta.fileFormat) throw new Error('Unable to determine file format');
const timecode = autoLoadTimecode ? getTimecodeFromStreams(streams) : undefined; const timecode = autoLoadTimecode ? getTimecodeFromStreams(streams) : undefined;
@ -1441,7 +1442,7 @@ const App = memo(() => {
toast.fire({ icon: 'info', text: i18n.t('The audio track is not supported. You can convert to a supported format from the menu') }); toast.fire({ icon: 'info', text: i18n.t('The audio track is not supported. You can convert to a supported format from the menu') });
} }
const validDuration = isDurationValid(parseFloat(fd.duration)); const validDuration = isDurationValid(parseFloat(fileMeta.formatData.duration));
const hasLoadedExistingHtml5FriendlyFile = await checkAndSetExistingHtml5FriendlyFile(); const hasLoadedExistingHtml5FriendlyFile = await checkAndSetExistingHtml5FriendlyFile();
// 'fastest' works with almost all video files // 'fastest' works with almost all video files
@ -1460,7 +1461,7 @@ const App = memo(() => {
} else if (await exists(openedFileEdlPathOld)) { } else if (await exists(openedFileEdlPathOld)) {
await loadEdlFile({ path: openedFileEdlPathOld, type: 'csv' }); await loadEdlFile({ path: openedFileEdlPathOld, type: 'csv' });
} else { } else {
const edl = await tryMapChaptersToEdl(ch); const edl = await tryMapChaptersToEdl(fileMeta.chapters);
if (edl.length > 0 && enableAskForImportChapters && (await askForImportChapters())) { if (edl.length > 0 && enableAskForImportChapters && (await askForImportChapters())) {
console.log('Convert chapters to segments', edl); console.log('Convert chapters to segments', edl);
loadCutSegments(edl); loadCutSegments(edl);
@ -1481,10 +1482,10 @@ const App = memo(() => {
setMainAudioStream(audioStream); setMainAudioStream(audioStream);
setCopyStreamIdsForPath(fp, () => copyStreamIdsForPathNew); setCopyStreamIdsForPath(fp, () => copyStreamIdsForPathNew);
setFileNameTitle(fp); setFileNameTitle(fp);
setFileFormat(outFormatLocked || ff); setFileFormat(outFormatLocked || fileMeta.fileFormat);
setDetectedFileFormat(ff); setDetectedFileFormat(fileMeta.fileFormat);
setFileFormatData(fd); setFileFormatData(fileMeta.formatData);
setChapters(ch); setChapters(fileMeta.chapters);
// This needs to be last, because it triggers <video> to load the video // This needs to be last, because it triggers <video> to load the video
// If not, onVideoError might be triggered before setWorking() has been cleared. // If not, onVideoError might be triggered before setWorking() has been cleared.