Skip to content

The swiss army knife of lossless video/audio editing

Add a video preview size setting (object-fit)

Claude284a0cc1f68f
diff --git a/locales/en/translation.json b/locales/en/translation.json
index 656f6e66..644817e6 100644
--- a/locales/en/translation.json
+++ b/locales/en/translation.json
@@ -347,8 +347,11 @@
"Files merged with warning(s)_other": "Files merged with warnings",
"Files merged!": "Files merged!",
"Fill gaps between segments": "Fill gaps between segments",
+ "Fill window (crop)": "Fill window (crop)",
"Filter tracks": "Filter tracks",
"Final Cut Pro FCPX / FCPXML": "Final Cut Pro FCPX / FCPXML",
+ "Fit to window": "Fit to window",
+ "Fit to window, but don't enlarge": "Fit to window, but don't enlarge",
"Fix incorrect duration": "Fix incorrect duration",
"Fixing file duration": "Fixing file duration",
"Focus segment at cursor": "Focus segment at cursor",
@@ -524,6 +527,7 @@
"None": "None",
"Normal cut": "Normal cut",
"Not all formats support all track types, and LosslessCut is unable to properly cut some track types, so you may have to sacrifice some tracks by disabling them in order to get correct result.": "Not all formats support all track types, and LosslessCut is unable to properly cut some track types, so you may have to sacrifice some tracks by disabling them in order to get correct result.",
+ "Not applied in FFmpeg-assisted playback": "Not applied in FFmpeg-assisted playback",
"Note that also other settings from the normal export dialog apply to this merge function. For more information about all options, see the export dialog.": "Note that also other settings from the normal export dialog apply to this merge function. For more information about all options, see the export dialog.",
"Note that depending on input parameters, up to {{estimatedMaxNumFiles}} files may be produced!": "Note that depending on input parameters, up to {{estimatedMaxNumFiles}} files may be produced!",
"Note that this is not supported in all video players.": "Note that this is not supported in all video players.",
@@ -547,6 +551,7 @@
"OpenTimelineIO": "OpenTimelineIO",
"Options": "Options",
"Options affecting exported files": "Options affecting exported files",
+ "Original size": "Original size",
"Other": "Other",
"Other operations": "Other operations",
"Output actions": "Output actions",
@@ -760,6 +765,7 @@
"Store in working directory": "Store in working directory",
"Store next to media file": "Store next to media file",
"Store project file (.llc) in the working directory or next to loaded media file?": "Store project file (.llc) in the working directory or next to loaded media file",
+ "Stretch to window": "Stretch to window",
"subtitle": "subtitle",
"Subtitle": "Subtitle",
"Subtitles (SRT)": "Subtitles (SRT)",
@@ -859,6 +865,7 @@
"Variables": "Variables",
"video": "video",
"Video FPS": "Video FPS",
+ "Video preview size": "Video preview size",
"Video track": "Video track",
"Video tracks": "Video tracks",
"View": "View",
diff --git a/src/common/types.ts b/src/common/types.ts
index bdef8db8..c2921984 100644
--- a/src/common/types.ts
+++ b/src/common/types.ts
@@ -116,6 +116,7 @@ export const configSchema = z.object({
}),
allowMultipleInstances: z.boolean(),
theme: z.enum(['dark', 'light', 'system']),
+ videoFit: z.enum(['contain', 'scale-down', 'cover', 'fill', 'none']),
preferStrongColors: z.boolean(),
outputFileNameMinZeroPadding: z.number(),
cutFromAdjustmentFrames: z.number(),
diff --git a/src/main/configStore.ts b/src/main/configStore.ts
index fef0bc73..15d5e492 100644
--- a/src/main/configStore.ts
+++ b/src/main/configStore.ts
@@ -161,6 +161,7 @@ const defaults: Config = {
},
allowMultipleInstances: false,
theme: 'dark',
+ videoFit: 'contain',
preferStrongColors: false,
outputFileNameMinZeroPadding: 1,
cutFromAdjustmentFrames: 0,
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index 901dfb83..d779bb25 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -192,7 +192,7 @@ function App() {
const [selectedBatchFiles, setSelectedBatchFiles] = useState<string[]>([]);
const allUserSettings = useUserSettingsRoot();
- const { captureFormat, keyframeCut, preserveMetadata, preserveMetadataOnMerge, preserveMovData, preserveChapters, movFastStart, avoidNegativeTs, autoMerge, timecodeFormat, invertCutSegments, autoExportExtraStreams, askBeforeClose, enableImportChapters, enableAskForFileOpenAction, playbackVolume, autoSaveProjectFile, wheelSensitivity, waveformHeight, invertTimelineScroll, language, ffmpegExperimental, hideNotifications, hideOsNotifications, autoLoadTimecode, autoDeleteMergedSegments, exportConfirmEnabled, segmentsToChapters, simpleMode, cutFileTemplate, cutMergedFileTemplate, mergedFileTemplate, keyboardSeekAccFactor, keyboardNormalSeekSpeed, keyboardSeekSpeed2, keyboardSeekSpeed3, treatInputFileModifiedTimeAsStart, treatOutputFileModifiedTimeAsStart, outFormatLocked, safeOutputFileName, enableAutoHtml5ify, segmentsToChaptersOnly, keyBindings, enableSmartCut, customFfPath, storeProjectInWorkingDir, enableOverwriteOutput, mouseWheelZoomModifierKey, mouseWheelFrameSeekModifierKey, mouseWheelKeyframeSeekModifierKey, captureFrameMethod, captureFrameQuality, captureFrameFileNameFormat, enableNativeHevc, cleanupChoices, preferStrongColors, outputFileNameMinZeroPadding, cutFromAdjustmentFrames, cutToAdjustmentFrames, waveformMode: waveformModePreference, thumbnailsEnabled, keyframesEnabled, reducedMotion, ffmpegHwaccel } = allUserSettings.settings;
+ const { captureFormat, keyframeCut, preserveMetadata, preserveMetadataOnMerge, preserveMovData, preserveChapters, movFastStart, avoidNegativeTs, autoMerge, timecodeFormat, invertCutSegments, autoExportExtraStreams, askBeforeClose, enableImportChapters, enableAskForFileOpenAction, playbackVolume, autoSaveProjectFile, wheelSensitivity, waveformHeight, invertTimelineScroll, language, ffmpegExperimental, hideNotifications, hideOsNotifications, autoLoadTimecode, autoDeleteMergedSegments, exportConfirmEnabled, segmentsToChapters, simpleMode, cutFileTemplate, cutMergedFileTemplate, mergedFileTemplate, keyboardSeekAccFactor, keyboardNormalSeekSpeed, keyboardSeekSpeed2, keyboardSeekSpeed3, treatInputFileModifiedTimeAsStart, treatOutputFileModifiedTimeAsStart, outFormatLocked, safeOutputFileName, enableAutoHtml5ify, segmentsToChaptersOnly, keyBindings, enableSmartCut, customFfPath, storeProjectInWorkingDir, enableOverwriteOutput, mouseWheelZoomModifierKey, mouseWheelFrameSeekModifierKey, mouseWheelKeyframeSeekModifierKey, captureFrameMethod, captureFrameQuality, captureFrameFileNameFormat, enableNativeHevc, cleanupChoices, preferStrongColors, outputFileNameMinZeroPadding, cutFromAdjustmentFrames, cutToAdjustmentFrames, waveformMode: waveformModePreference, thumbnailsEnabled, keyframesEnabled, reducedMotion, ffmpegHwaccel, videoFit } = allUserSettings.settings;
const { setCaptureFormat, setCustomOutDir, setKeyframeCut, setPlaybackVolume, setExportConfirmEnabled, setSimpleMode, setOutFormatLocked, setSafeOutputFileName, setKeyBindings, resetKeyBindings, setStoreProjectInWorkingDir, setCleanupChoices, darkMode, toggleDarkMode, setWaveformMode, setThumbnailsEnabled, setKeyframesEnabled, prefersReducedMotion, customOutDir } = allUserSettings;
const [showAdvancedSettings, setShowAdvancedSettings] = useState(!simpleMode);
@@ -202,6 +202,7 @@ function App() {
const { showGenericDialog, genericDialog, closeGenericDialog, confirmDialog, openExportFinishedDialog, openCutFinishedDialog, openConcatFinishedDialog, openCleanupFilesDialog, openShiftSegmentsDialog, openDecimateDialog } = useDialog();
// Note that each action may be multiple key bindings and this will only be the first binding for each action
+ const mainVideoStyle = useMemo(() => ({ ...videoStyle, objectFit: videoFit }), [videoFit]);
const keyBindingByAction = useMemo(() => Object.fromEntries(keyBindings.map((binding) => [binding.action, binding])), [keyBindings]);
const { working, setWorking, workingRef, abortWorking } = useLoading();
@@ -2579,7 +2580,7 @@ function App() {
tabIndex={-1}
muted={playbackVolume === 0 || compatPlayerEnabled}
ref={videoRef}
- style={videoStyle}
+ style={mainVideoStyle}
onPlay={onStartPlaying}
onPause={onStopPlaying}
onAbort={onVideoAbort}
diff --git a/src/renderer/src/components/Settings.tsx b/src/renderer/src/components/Settings.tsx
index a5422c62..e4571ad3 100644
--- a/src/renderer/src/components/Settings.tsx
+++ b/src/renderer/src/components/Settings.tsx
@@ -75,7 +75,7 @@ function Settings({
}) {
const { t } = useTranslation();
- const { customOutDir, keyframeCut, toggleKeyframeCut, timecodeFormat, setTimecodeFormat, invertCutSegments, setInvertCutSegments, askBeforeClose, setAskBeforeClose, enableImportChapters, setEnableImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction, autoSaveProjectFile, setAutoSaveProjectFile, invertTimelineScroll, setInvertTimelineScroll, language, setLanguage, hideNotifications, setHideNotifications, hideOsNotifications, setHideOsNotifications, autoLoadTimecode, setAutoLoadTimecode, enableAutoHtml5ify, setEnableAutoHtml5ify, customFfPath, setCustomFfPath, storeProjectInWorkingDir, mouseWheelZoomModifierKey, setMouseWheelZoomModifierKey, mouseWheelFrameSeekModifierKey, setMouseWheelFrameSeekModifierKey, mouseWheelKeyframeSeekModifierKey, setMouseWheelKeyframeSeekModifierKey, segmentMouseModifierKey, setSegmentMouseModifierKey, captureFrameMethod, setCaptureFrameMethod, captureFrameQuality, setCaptureFrameQuality, captureFrameFileNameFormat, setCaptureFrameFileNameFormat, enableNativeHevc, setEnableNativeHevc, enableUpdateCheck, setEnableUpdateCheck, allowMultipleInstances, setAllowMultipleInstances, preferStrongColors, setPreferStrongColors, theme, setTheme, treatInputFileModifiedTimeAsStart, setTreatInputFileModifiedTimeAsStart, treatOutputFileModifiedTimeAsStart, setTreatOutputFileModifiedTimeAsStart, exportConfirmEnabled, toggleExportConfirmEnabled, storeWindowBounds, setStoreWindowBounds, reducedMotion, setReducedMotion, ffmpegHwaccel, setFfmpegHwaccel } = useUserSettings();
+ const { customOutDir, keyframeCut, toggleKeyframeCut, timecodeFormat, setTimecodeFormat, invertCutSegments, setInvertCutSegments, askBeforeClose, setAskBeforeClose, enableImportChapters, setEnableImportChapters, enableAskForFileOpenAction, setEnableAskForFileOpenAction, autoSaveProjectFile, setAutoSaveProjectFile, invertTimelineScroll, setInvertTimelineScroll, language, setLanguage, hideNotifications, setHideNotifications, hideOsNotifications, setHideOsNotifications, autoLoadTimecode, setAutoLoadTimecode, enableAutoHtml5ify, setEnableAutoHtml5ify, customFfPath, setCustomFfPath, storeProjectInWorkingDir, mouseWheelZoomModifierKey, setMouseWheelZoomModifierKey, mouseWheelFrameSeekModifierKey, setMouseWheelFrameSeekModifierKey, mouseWheelKeyframeSeekModifierKey, setMouseWheelKeyframeSeekModifierKey, segmentMouseModifierKey, setSegmentMouseModifierKey, captureFrameMethod, setCaptureFrameMethod, captureFrameQuality, setCaptureFrameQuality, captureFrameFileNameFormat, setCaptureFrameFileNameFormat, enableNativeHevc, setEnableNativeHevc, enableUpdateCheck, setEnableUpdateCheck, allowMultipleInstances, setAllowMultipleInstances, preferStrongColors, setPreferStrongColors, theme, setTheme, videoFit, setVideoFit, treatInputFileModifiedTimeAsStart, setTreatInputFileModifiedTimeAsStart, treatOutputFileModifiedTimeAsStart, setTreatOutputFileModifiedTimeAsStart, exportConfirmEnabled, toggleExportConfirmEnabled, storeWindowBounds, setStoreWindowBounds, reducedMotion, setReducedMotion, ffmpegHwaccel, setFfmpegHwaccel } = useUserSettings();
const onLangChange = useCallback<ChangeEventHandler<HTMLSelectElement>>((e) => {
const { value } = e.target;
@@ -480,6 +480,22 @@ function Settings({
</td>
</Row>
+ {showAdvancedSettings && (
+ <Row>
+ <KeyCell>
+ {t('Video preview size')}
+ <div style={detailsStyle}>{t('Not applied in FFmpeg-assisted playback')}</div>
+ </KeyCell>
+ <td>
+ <Select value={videoFit} onChange={(e) => setVideoFit(e.target.value as Config['videoFit'])}>
+ {Object.entries({ contain: t('Fit to window'), 'scale-down': t('Fit to window, but don\'t enlarge'), cover: t('Fill window (crop)'), fill: t('Stretch to window'), none: t('Original size') } satisfies Record<Config['videoFit'], string>).map(([key, value]) => (
+ <option key={key} value={key}>{value}</option>
+ ))}
+ </Select>
+ </td>
+ </Row>
+ )}
+
<Row>
<KeyCell>{t('Prefer strong colors')}</KeyCell>
<td>
diff --git a/src/renderer/src/hooks/useUserSettingsRoot.ts b/src/renderer/src/hooks/useUserSettingsRoot.ts
index 16886eb6..be794b9e 100644
--- a/src/renderer/src/hooks/useUserSettingsRoot.ts
+++ b/src/renderer/src/hooks/useUserSettingsRoot.ts
@@ -183,6 +183,8 @@ export default function useUserSettingsRoot() {
useEffect(() => safeSetConfig({ allowMultipleInstances }), [allowMultipleInstances]);
const [theme, setTheme] = useState(safeGetConfigInitial('theme'));
useEffect(() => safeSetConfig({ theme }), [theme]);
+ const [videoFit, setVideoFit] = useState(safeGetConfigInitial('videoFit'));
+ useEffect(() => safeSetConfig({ videoFit }), [videoFit]);
const [preferStrongColors, setPreferStrongColors] = useState(safeGetConfigInitial('preferStrongColors'));
useEffect(() => safeSetConfig({ preferStrongColors }), [preferStrongColors]);
const [outputFileNameMinZeroPadding, setOutputFileNameMinZeroPadding] = useState(safeGetConfigInitial('outputFileNameMinZeroPadding'));
@@ -317,6 +319,7 @@ export default function useUserSettingsRoot() {
cleanupChoices,
allowMultipleInstances,
theme,
+ videoFit,
preferStrongColors,
outputFileNameMinZeroPadding,
cutFromAdjustmentFrames,
@@ -400,6 +403,7 @@ export default function useUserSettingsRoot() {
setAllowMultipleInstances,
darkMode,
setTheme,
+ setVideoFit,
toggleDarkMode,
setPreferStrongColors,
setOutputFileNameMinZeroPadding,