Skip to content

The swiss army knife of lossless video/audio editing

Merge branch 'claude/metadata-editor-codec-defaults-yhhekx' into claude/metadata-apply-to-all-tracks

Claude1e8f1b05edac
diff --cc locales/en/translation.json
index 2c346b82,03684688..b455c91e
--- a/locales/en/translation.json
+++ b/locales/en/translation.json
@@@ -431,7 -430,7 +431,7 @@@
"Keep or discard thumbnail tracks": "Keep or discard thumbnail tracks",
"Keep or discard video tracks": "Keep or discard video tracks",
"Keep selected segments": "Keep selected segments",
-- "Keep?": "Keep",
++ "Keep?": "Keep?",
"Keeping {{numStreamsToCopy}} tracks": "Keeping {{numStreamsToCopy}} tracks",
"Key frames will show on the timeline. You need to zoom in to view them": "Key frames will show on the timeline. You need to zoom in to view them.",
"Keyboard & mouse shortcuts": "Keyboard & mouse shortcuts",
diff --cc src/renderer/src/StreamsSelector.tsx
index 620954e6,7c79a6f8..e0e59a70
--- a/src/renderer/src/StreamsSelector.tsx
+++ b/src/renderer/src/StreamsSelector.tsx
@@@ -316,15 -316,7 +316,20 @@@ const EditStreamDialog = memo(({ editin
metadata[tag] = tag === 'language' ? value.toLowerCase() : value;
});
});
- }, [editingFile, editingStreamId, updateStreamParams]);
+ }, [editingFile, updateStreamParams]);
+
+ const onMetadataChange = useCallback((keyValues: Record<string, string>) => setStreamMetadata(editingStreamId, keyValues), [editingStreamId, setStreamMetadata]);
+
- const otherStreamsOfSameType = useMemo(() => streams.filter((s) => s.codec_type === editingStream?.codec_type && s.index !== editingStreamId), [editingStream?.codec_type, editingStreamId, streams]);
++ // cover art counts as its own type
++ const otherStreamsOfSameType = useMemo(() => {
++ if (editingStream == null) return [];
++ const isCoverArt = (stream: FFprobeStream) => getStreamEffectiveDisposition(paramsByFile, editingFile, stream) === attachedPicDisposition;
++ return streams.filter((s) => s.index !== editingStreamId && s.codec_type === editingStream.codec_type && isCoverArt(s) === isCoverArt(editingStream));
++ }, [editingFile, editingStream, editingStreamId, paramsByFile, streams]);
+
+ const onApplyToAll = useCallback((tag: string, value: string) => {
+ otherStreamsOfSameType.forEach((s) => setStreamMetadata(s.index, { [tag]: value }));
+ }, [otherStreamsOfSameType, setStreamMetadata]);
const onMetadataReset = useCallback((key: string) => {
updateStreamParams(editingFile, editingStreamId, (params) => {
@@@ -373,8 -365,8 +378,8 @@@
<div style={{ marginTop: '.5em' }}>
<Tabs.Content value="metadata">
- <MovMetadataNotice outFormat={outFormat} metadata={streamParams?.metadata} nativeKeys={streamMetadataKeys} />
+ <MovMetadataNotice outFormat={outFormat} metadata={streamParams?.metadata} isStream />
- <TagEditor existingTags={existingMetadata} customTags={streamParams?.metadata} editingTag={editingKey} setEditingTag={setEditingKey} onTagsChange={onMetadataChange} onTagReset={onMetadataReset} addTagTitle={t('Add metadata')} tagInfo={tagInfo} keySuggestions={streamMetadataKeys} canDeleteExisting />
+ <TagEditor existingTags={existingMetadata} customTags={streamParams?.metadata} editingTag={editingKey} setEditingTag={setEditingKey} onTagsChange={onMetadataChange} onTagReset={onMetadataReset} addTagTitle={t('Add metadata')} tagInfo={tagInfo} keySuggestions={streamMetadataKeys} canDeleteExisting onApplyToAll={otherStreamsOfSameType.length > 0 ? onApplyToAll : undefined} applyToAllTitle={t('Apply to all other tracks of this type')} />
</Tabs.Content>
{editingStream != null && (
diff --cc src/renderer/src/components/TagEditor.tsx
index e7b3ff05,e9c32c53..279c8f90
--- a/src/renderer/src/components/TagEditor.tsx
+++ b/src/renderer/src/components/TagEditor.tsx
@@@ -29,7 -29,15 +29,15 @@@ export type TagInfo = Record<string,
validate?: (value: string) => string | undefined,
}>;
+ // For the containing dialog's `onEscapeKeyDown`: Esc discards the unsaved edit instead of closing the dialog.
+ // Handled at the dialog level so that it also works when the input doesn't have focus (or is not mounted, e.g. another tab)
+ export const cancelTagEditOnEscape = (editingTag: string | undefined, setEditingTag: (v: string | undefined) => void) => (e: KeyboardEvent) => {
+ if (editingTag == null) return;
+ e.preventDefault();
+ setEditingTag(undefined);
+ };
+
-function TagEditor({ existingTags = emptyObject, customTags = emptyObject, editingTag, setEditingTag, onTagsChange, onTagReset, addTagTitle, tagInfo, keySuggestions, canDeleteExisting }: {
+function TagEditor({ existingTags = emptyObject, customTags = emptyObject, editingTag, setEditingTag, onTagsChange, onTagReset, addTagTitle, tagInfo, keySuggestions, canDeleteExisting, onApplyToAll, applyToAllTitle }: {
existingTags?: SegmentTags,
customTags?: SegmentTags | undefined,
editingTag: string | undefined,