From 91fbc0fa9507f32d4df5679eec7958668df9a085 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Tue, 27 Aug 2024 21:13:55 +0200 Subject: [PATCH] log ffprobe detected formats --- src/renderer/src/App.tsx | 4 ++-- src/renderer/src/components/ConcatDialog.tsx | 4 ++-- src/renderer/src/ffmpeg.ts | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index a5a247b0..dc0bfeb0 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -53,7 +53,7 @@ import { darkModeTransition } from './colors'; import { getSegColor } from './util/colors'; import { getStreamFps, isCuttingStart, isCuttingEnd, - readFileMeta, getSmarterOutFormat, + readFileMeta, getDefaultOutFormat, extractStreams, setCustomFfPath as ffmpegSetCustomFfPath, isIphoneHevc, isProblematicAvc1, tryMapChaptersToEdl, getDuration, getTimecodeFromStreams, createChaptersFromSegments, @@ -1304,7 +1304,7 @@ function App() { const fileMeta = await readFileMeta(fp); // 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'); diff --git a/src/renderer/src/components/ConcatDialog.tsx b/src/renderer/src/components/ConcatDialog.tsx index ce831e5f..6fea86f7 100644 --- a/src/renderer/src/components/ConcatDialog.tsx +++ b/src/renderer/src/components/ConcatDialog.tsx @@ -8,7 +8,7 @@ import invariant from 'tiny-invariant'; import Checkbox from './Checkbox'; import { ReactSwal } from '../swal'; -import { readFileMeta, getSmarterOutFormat } from '../ffmpeg'; +import { readFileMeta, getDefaultOutFormat } from '../ffmpeg'; import useFileFormatState from '../hooks/useFileFormatState'; import OutputFormatSelect from './OutputFormatSelect'; import useUserSettings from '../hooks/useUserSettings'; @@ -66,7 +66,7 @@ function ConcatDialog({ isShown, onHide, paths, onConcat, alwaysConcatMultipleFi setOutFileName(undefined); invariant(firstPath != null); const fileMetaNew = await readFileMeta(firstPath); - const fileFormatNew = await getSmarterOutFormat({ filePath: firstPath, fileMeta: fileMetaNew }); + const fileFormatNew = await getDefaultOutFormat({ filePath: firstPath, fileMeta: fileMetaNew }); if (aborted) return; setFileMeta(fileMetaNew); setFileFormat(fileFormatNew); diff --git a/src/renderer/src/ffmpeg.ts b/src/renderer/src/ffmpeg.ts index bbe079b8..96140c38 100644 --- a/src/renderer/src/ffmpeg.ts +++ b/src/renderer/src/ffmpeg.ts @@ -260,10 +260,12 @@ function mapDefaultFormat({ streams, requestedFormat }: { streams: FFprobeStream async function determineOutputFormat(ffprobeFormatsStr: string | undefined, filePath: string) { const ffprobeFormats = (ffprobeFormatsStr || '').split(',').map((str) => str.trim()).filter(Boolean); if (ffprobeFormats.length === 0) { - console.warn('ffprobe returned unknown formats', ffprobeFormatsStr); + console.warn('FFprobe returned unknown formats', ffprobeFormatsStr); return undefined; } + console.log('FFprobe detected format(s)', ffprobeFormatsStr); + const [firstFfprobeFormat] = ffprobeFormats; 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[] } }) { - const formatsStr = format.format_name; - const assumedFormat = await determineOutputFormat(formatsStr, filePath); +export async function getDefaultOutFormat({ filePath, fileMeta: { format, streams } }: { filePath: string, fileMeta: { format: Pick, streams: FFprobeStream[] } }) { + const assumedFormat = await determineOutputFormat(format.format_name, filePath); return mapDefaultFormat({ streams, requestedFormat: assumedFormat }); }