fixed dropdown bar visibility
This commit is contained in:
@ -9,10 +9,15 @@ export default function ExportDialog() {
|
||||
|
||||
const hasCuts = cutRanges.length > 0;
|
||||
|
||||
// Detect if input is audio-only by its extension
|
||||
const audioExtensions = new Set(['.wav', '.mp3', '.flac', '.m4a', '.ogg', '.aac', '.wma']);
|
||||
const inputExt = videoPath ? '.' + videoPath.split('.').pop()?.toLowerCase() : '';
|
||||
const isAudioOnly = videoPath ? audioExtensions.has(inputExt) : false;
|
||||
|
||||
const [options, setOptions] = useState<Omit<ExportOptions, 'outputPath'> & { normalizeAudio: boolean; normalizeTarget: number }>({
|
||||
mode: 'fast',
|
||||
mode: isAudioOnly ? 'reencode' : 'fast',
|
||||
resolution: '1080p',
|
||||
format: 'mp4',
|
||||
format: isAudioOnly ? 'wav' : 'mp4',
|
||||
enhanceAudio: false,
|
||||
captions: 'none',
|
||||
normalizeAudio: false,
|
||||
@ -20,16 +25,24 @@ export default function ExportDialog() {
|
||||
});
|
||||
const [exportError, setExportError] = useState<string | null>(null);
|
||||
|
||||
const HANDLE_EXPORT_filters = useCallback(() => {
|
||||
const ext = options.format;
|
||||
const nameMap: Record<string, string> = {
|
||||
mp4: 'MP4',
|
||||
mov: 'MOV',
|
||||
webm: 'WebM',
|
||||
wav: 'WAV Audio',
|
||||
};
|
||||
return [{ name: nameMap[ext] || 'File', extensions: [ext] }];
|
||||
}, [options.format]);
|
||||
|
||||
const handleExport = useCallback(async () => {
|
||||
if (!videoPath) return;
|
||||
|
||||
const defaultExt = options.format === 'wav' ? 'wav' : 'mp4';
|
||||
const outputPath = await window.electronAPI?.saveFile({
|
||||
defaultPath: videoPath.replace(/\.[^.]+$/, '_edited.mp4'),
|
||||
filters: [
|
||||
{ name: 'MP4', extensions: ['mp4'] },
|
||||
{ name: 'MOV', extensions: ['mov'] },
|
||||
{ name: 'WebM', extensions: ['webm'] },
|
||||
],
|
||||
defaultPath: videoPath.replace(/\.[^.]+$/, `_edited.${defaultExt}`),
|
||||
filters: HANDLE_EXPORT_filters(),
|
||||
});
|
||||
if (!outputPath) return;
|
||||
|
||||
@ -96,7 +109,7 @@ export default function ExportDialog() {
|
||||
setExportError(err instanceof Error ? err.message : 'Export failed');
|
||||
setExporting(false);
|
||||
}
|
||||
}, [videoPath, options, backendUrl, setExporting, getKeepSegments, cutRanges, muteRanges, gainRanges, speedRanges, globalGainDb, words]);
|
||||
}, [videoPath, options, backendUrl, setExporting, getKeepSegments, cutRanges, muteRanges, gainRanges, speedRanges, globalGainDb, words, HANDLE_EXPORT_filters]);
|
||||
|
||||
return (
|
||||
<div className="p-4 space-y-5">
|
||||
@ -146,6 +159,7 @@ export default function ExportDialog() {
|
||||
{ value: 'mp4', label: 'MP4 (H.264)' },
|
||||
{ value: 'mov', label: 'MOV (QuickTime)' },
|
||||
{ value: 'webm', label: 'WebM (VP9)' },
|
||||
...(isAudioOnly ? [{ value: 'wav' as const, label: 'WAV (Uncompressed)' }] : []),
|
||||
]}
|
||||
/>
|
||||
|
||||
@ -171,7 +185,7 @@ export default function ExportDialog() {
|
||||
<select
|
||||
value={options.normalizeTarget}
|
||||
onChange={(e) => setOptions((o) => ({ ...o, normalizeTarget: Number(e.target.value) }))}
|
||||
className="flex-1 px-2 py-1.5 text-xs bg-editor-surface border border-editor-border rounded focus:outline-none focus:border-editor-accent"
|
||||
className="flex-1 px-2 py-1.5 text-xs bg-editor-surface border border-editor-border rounded focus:outline-none focus:border-editor-accent [color-scheme:dark]"
|
||||
>
|
||||
<option value={-14}>YouTube (-14 LUFS)</option>
|
||||
<option value={-16}>Spotify (-16 LUFS)</option>
|
||||
@ -295,7 +309,7 @@ function SelectField({
|
||||
<select
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="w-full px-3 py-2 bg-editor-surface border border-editor-border rounded-lg text-xs text-editor-text focus:outline-none focus:border-editor-accent"
|
||||
className="w-full px-3 py-2 bg-editor-surface border border-editor-border rounded-lg text-xs text-editor-text focus:outline-none focus:border-editor-accent [color-scheme:dark]"
|
||||
>
|
||||
{options.map((opt) => (
|
||||
<option key={opt.value} value={opt.value}>
|
||||
|
||||
Reference in New Issue
Block a user