mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 03:33:14 +01:00
log ffprobe detected formats
This commit is contained in:
parent
8eef3cbc16
commit
91fbc0fa95
@ -53,7 +53,7 @@ import { darkModeTransition } from './colors';
|
|||||||
import { getSegColor } from './util/colors';
|
import { getSegColor } from './util/colors';
|
||||||
import {
|
import {
|
||||||
getStreamFps, isCuttingStart, isCuttingEnd,
|
getStreamFps, isCuttingStart, isCuttingEnd,
|
||||||
readFileMeta, getSmarterOutFormat,
|
readFileMeta, getDefaultOutFormat,
|
||||||
extractStreams, setCustomFfPath as ffmpegSetCustomFfPath,
|
extractStreams, setCustomFfPath as ffmpegSetCustomFfPath,
|
||||||
isIphoneHevc, isProblematicAvc1, tryMapChaptersToEdl,
|
isIphoneHevc, isProblematicAvc1, tryMapChaptersToEdl,
|
||||||
getDuration, getTimecodeFromStreams, createChaptersFromSegments,
|
getDuration, getTimecodeFromStreams, createChaptersFromSegments,
|
||||||
@ -1304,7 +1304,7 @@ function App() {
|
|||||||
const fileMeta = await readFileMeta(fp);
|
const fileMeta = await readFileMeta(fp);
|
||||||
// console.log('file meta read', fileMeta);
|
// console.log('file meta read', fileMeta);
|
||||||
|
|
||||||
const fileFormatNew = await getSmarterOutFormat({ filePath: fp, fileMeta });
|
const fileFormatNew = await getDefaultOutFormat({ filePath: fp, fileMeta });
|
||||||
|
|
||||||
if (!fileFormatNew) throw new Error('Unable to determine file format');
|
if (!fileFormatNew) throw new Error('Unable to determine file format');
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import invariant from 'tiny-invariant';
|
|||||||
import Checkbox from './Checkbox';
|
import Checkbox from './Checkbox';
|
||||||
|
|
||||||
import { ReactSwal } from '../swal';
|
import { ReactSwal } from '../swal';
|
||||||
import { readFileMeta, getSmarterOutFormat } from '../ffmpeg';
|
import { readFileMeta, getDefaultOutFormat } from '../ffmpeg';
|
||||||
import useFileFormatState from '../hooks/useFileFormatState';
|
import useFileFormatState from '../hooks/useFileFormatState';
|
||||||
import OutputFormatSelect from './OutputFormatSelect';
|
import OutputFormatSelect from './OutputFormatSelect';
|
||||||
import useUserSettings from '../hooks/useUserSettings';
|
import useUserSettings from '../hooks/useUserSettings';
|
||||||
@ -66,7 +66,7 @@ function ConcatDialog({ isShown, onHide, paths, onConcat, alwaysConcatMultipleFi
|
|||||||
setOutFileName(undefined);
|
setOutFileName(undefined);
|
||||||
invariant(firstPath != null);
|
invariant(firstPath != null);
|
||||||
const fileMetaNew = await readFileMeta(firstPath);
|
const fileMetaNew = await readFileMeta(firstPath);
|
||||||
const fileFormatNew = await getSmarterOutFormat({ filePath: firstPath, fileMeta: fileMetaNew });
|
const fileFormatNew = await getDefaultOutFormat({ filePath: firstPath, fileMeta: fileMetaNew });
|
||||||
if (aborted) return;
|
if (aborted) return;
|
||||||
setFileMeta(fileMetaNew);
|
setFileMeta(fileMetaNew);
|
||||||
setFileFormat(fileFormatNew);
|
setFileFormat(fileFormatNew);
|
||||||
|
@ -260,10 +260,12 @@ function mapDefaultFormat({ streams, requestedFormat }: { streams: FFprobeStream
|
|||||||
async function determineOutputFormat(ffprobeFormatsStr: string | undefined, filePath: string) {
|
async function determineOutputFormat(ffprobeFormatsStr: string | undefined, filePath: string) {
|
||||||
const ffprobeFormats = (ffprobeFormatsStr || '').split(',').map((str) => str.trim()).filter(Boolean);
|
const ffprobeFormats = (ffprobeFormatsStr || '').split(',').map((str) => str.trim()).filter(Boolean);
|
||||||
if (ffprobeFormats.length === 0) {
|
if (ffprobeFormats.length === 0) {
|
||||||
console.warn('ffprobe returned unknown formats', ffprobeFormatsStr);
|
console.warn('FFprobe returned unknown formats', ffprobeFormatsStr);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('FFprobe detected format(s)', ffprobeFormatsStr);
|
||||||
|
|
||||||
const [firstFfprobeFormat] = ffprobeFormats;
|
const [firstFfprobeFormat] = ffprobeFormats;
|
||||||
if (ffprobeFormats.length === 1) return firstFfprobeFormat;
|
if (ffprobeFormats.length === 1) return firstFfprobeFormat;
|
||||||
|
|
||||||
@ -326,9 +328,8 @@ async function determineOutputFormat(ffprobeFormatsStr: string | undefined, file
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSmarterOutFormat({ filePath, fileMeta: { format, streams } }: { filePath: string, fileMeta: { format: FFprobeFormat, streams: FFprobeStream[] } }) {
|
export async function getDefaultOutFormat({ filePath, fileMeta: { format, streams } }: { filePath: string, fileMeta: { format: Pick<FFprobeFormat, 'format_name'>, streams: FFprobeStream[] } }) {
|
||||||
const formatsStr = format.format_name;
|
const assumedFormat = await determineOutputFormat(format.format_name, filePath);
|
||||||
const assumedFormat = await determineOutputFormat(formatsStr, filePath);
|
|
||||||
|
|
||||||
return mapDefaultFormat({ streams, requestedFormat: assumedFormat });
|
return mapDefaultFormat({ streams, requestedFormat: assumedFormat });
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user