include ffmpeg version in report

and log on startup
pull/2801/head
Mikael Finstad 4 months ago
parent 260302b9f8
commit 2603125fb2
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -265,6 +265,7 @@ export async function init({ customConfigDir }: { customConfigDir: string | unde
const keyBindings = (store.get('keyBindings') as KeyBinding[]).map(({ keys, action }) => ({ keysStr: keys, keys: keys.split('+'), action }));
// assume that if there is one binding with ctrl, then it's the old format where keys were stored as strings like "Ctrl+Shift+S". We want to migrate to the new format where keys are stored as "ControlLeft+ShiftLeft+KeyS"
// todo remove after a while
if (keyBindings.some(({ keys }) => keys.some((k) => k.toLowerCase() === 'ctrl'))) {
await tryBackupConfigFile(1, app.getVersion());

@ -162,6 +162,7 @@ function App() {
const { fileFormat, setFileFormat, detectedFileFormat, setDetectedFileFormat, isCustomFormatSelected } = useFileFormatState();
// State per application launch
const [ffmpegInfo, setFfmpegInfo] = useState<Awaited<ReturnType<typeof runStartupCheck>>>();
const lastOpenedPathRef = useRef<string>();
const [showRightBar, setShowRightBar] = useState(true);
const [lastCommandsVisible, setLastCommandsVisible] = useState(false);
@ -823,8 +824,8 @@ function App() {
const commonSettings = useMemo(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { keyBindings: _keyBindings, ...rest } = allUserSettings.settings;
return rest;
}, [allUserSettings]);
return { ...rest, ffmpegVersion: ffmpegInfo?.program_version.version };
}, [allUserSettings.settings, ffmpegInfo?.program_version.version]);
const openSendReportDialogWithState = useCallback(async (err?: unknown) => {
const state = {
@ -2395,7 +2396,9 @@ function App() {
}, []);
useEffect(() => {
runStartupCheck({ onError: ({ title, message }) => setGenericError({ title, err: message }) });
(async () => {
setFfmpegInfo(await runStartupCheck({ onError: ({ title, message }) => setGenericError({ title, err: message }) }));
})();
}, [customFfPath, setGenericError]);
const appContext = useMemo<AppContextType>(() => ({

@ -5,6 +5,7 @@ import type { FRAMERATE } from 'smpte-timecode';
import Timecode from 'smpte-timecode';
import minBy from 'lodash/minBy';
import invariant from 'tiny-invariant';
import z from 'zod';
import { pcmAudioCodecs, isMov } from './util/streams';
import { isExecaError } from './util';
@ -554,9 +555,22 @@ export function getTimecodeFromStreams(streams: FFprobeStream[]) {
return foundTimecode;
}
const ffprobeVersionSchema = z.object({
program_version: z.object({
version: z.string(),
// not sure if these are always present, so make them optional for now:
copyright: z.string().optional(),
compiler_ident: z.string().optional(),
configuration: z.string().optional(),
}),
});
export async function runFfmpegStartupCheck() {
// will throw if exit code != 0
await runFfmpeg(['-hide_banner', '-f', 'lavfi', '-i', 'nullsrc=s=256x256:d=1', '-f', 'null', '-']);
const { stderr: ffmpegStderr } = await runFfmpeg(['-f', 'lavfi', '-i', 'nullsrc=s=256x256:d=1', '-f', 'null', '-']);
console.log('FFmpeg startup check output:', new TextDecoder().decode(ffmpegStderr));
const { stdout: ffprobeStout } = await runFfprobe(['-v', '0', '-of', 'json', '-show_program_version']);
return ffprobeVersionSchema.parse(JSON.parse(new TextDecoder().decode(ffprobeStout)));
}
// https://superuser.com/questions/543589/information-about-ffmpeg-command-line-options

@ -20,7 +20,7 @@ export async function loadMifiLink() {
export async function runStartupCheck({ onError }: { onError: (error: { title: string, message: string }) => void }) {
try {
await runFfmpegStartupCheck();
return await runFfmpegStartupCheck();
} catch (err) {
if (err instanceof Error && !isMasBuild) {
if ('code' in err && err.code === 'ENOENT') {
@ -28,7 +28,7 @@ export async function runStartupCheck({ onError }: { onError: (error: { title: s
title: i18n.t('Fatal: FFmpeg executable not found'),
message: `${i18n.t('Make sure that the FFmpeg executable exists:')}\n\n${getFfmpegPath()}`,
});
return;
return undefined;
}
if ('code' in err && typeof err.code === 'string' && ['EPERM', 'EACCES', 'ENOENT'].includes(err.code)) {
@ -42,10 +42,11 @@ export async function runStartupCheck({ onError }: { onError: (error: { title: s
i18n.t('Read more: {{url}}', { url: 'https://github.com/mifi/lossless-cut/issues/1114' }),
].join('\n'),
});
return;
return undefined;
}
}
openSendReportDialog({ message: i18n.t('FFmpeg is non-functional'), err });
return undefined;
}
}

Loading…
Cancel
Save