The swiss army knife of lossless video/audio editing
Add "apply to all tracks of this type" to the track metadata editor
Clauded4c7438d6eeb
diff --git a/locales/en/translation.json b/locales/en/translation.jsonindex 7cabe6ca..2c346b82 100644--- a/locales/en/translation.json+++ b/locales/en/translation.json@@ -55,6 +55,7 @@"Apple devices (QuickTime, Safari, iOS) require the \"{{tag}}\" codec tag to play HEVC in MP4/MOV.": "Apple devices (QuickTime, Safari, iOS) require the \"{{tag}}\" codec tag to play HEVC in MP4/MOV.","Apply change": "Apply change","Apply filter": "Apply filter",+ "Apply to all other tracks of this type": "Apply to all other tracks of this type","Are you sure you want to close the current file?": "Are you sure you want to close the current file?","Are you sure you want to close the loaded batch of files?": "Are you sure you want to close the loaded batch of files?","Are you sure you want to quit?": "Are you sure you want to quit?",diff --git a/src/renderer/src/StreamsSelector.tsx b/src/renderer/src/StreamsSelector.tsxindex 7de14932..620954e6 100644--- a/src/renderer/src/StreamsSelector.tsx+++ b/src/renderer/src/StreamsSelector.tsx@@ -307,8 +307,8 @@ const EditStreamDialog = memo(({ editingStream: { streamId: editingStreamId, patconst streamParams = useMemo(() => getStreamParams({ paramsByFile, filePath: editingFile, streamId: editingStreamId }), [editingFile, editingStreamId, paramsByFile]);- const onMetadataChange = useCallback((keyValues: Record<string, string>) => {- updateStreamParams(editingFile, editingStreamId, (params) => {+ const setStreamMetadata = useCallback((streamId: number, keyValues: Record<string, string>) => {+ updateStreamParams(editingFile, streamId, (params) => {// eslint-disable-next-line no-param-reassignif (params.metadata == null) params.metadata = {};const { metadata } = params;@@ -316,7 +316,15 @@ const EditStreamDialog = memo(({ editingStream: { streamId: editingStreamId, patmetadata[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]);++ 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) => {@@ -366,7 +374,7 @@ const EditStreamDialog = memo(({ editingStream: { streamId: editingStreamId, pat<div style={{ marginTop: '.5em' }}><Tabs.Content value="metadata"><MovMetadataNotice outFormat={outFormat} metadata={streamParams?.metadata} nativeKeys={streamMetadataKeys} />- <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 --git a/src/renderer/src/components/TagEditor.tsx b/src/renderer/src/components/TagEditor.tsxindex 69afe3a2..e7b3ff05 100644--- a/src/renderer/src/components/TagEditor.tsx+++ b/src/renderer/src/components/TagEditor.tsx@@ -3,7 +3,7 @@ import { memo, useRef, useState, useMemo, useCallback, useEffect } from 'react';import { useTranslation } from 'react-i18next';import invariant from 'tiny-invariant';import { motion } from 'motion/react';-import { FaCheck, FaClipboard, FaClipboardList, FaEdit, FaInfo, FaPlus, FaTrash, FaUndo } from 'react-icons/fa';+import { FaCheck, FaClipboard, FaClipboardList, FaClone, FaEdit, FaInfo, FaPlus, FaTrash, FaUndo } from 'react-icons/fa';import { IconButton, Tooltip, Button, TextArea } from '@radix-ui/themes';import type { SegmentTags } from '../types';@@ -29,7 +29,7 @@ export type TagInfo = Record<string, {validate?: (value: string) => string | 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,@@ -40,6 +40,8 @@ function TagEditor({ existingTags = emptyObject, customTags = emptyObject, edititagInfo?: TagInfo,keySuggestions?: readonly string[],canDeleteExisting?: boolean,+ onApplyToAll?: ((tag: string, value: string) => void) | undefined,+ applyToAllTitle?: string,}) {const { t } = useTranslation();const editRef = useRef<HTMLInputElement & HTMLTextAreaElement>(null);@@ -216,6 +218,10 @@ function TagEditor({ existingTags = emptyObject, customTags = emptyObject, editi<IconButton size="1" color="red" variant="ghost" title={t('Reset')} onClick={onResetClick}><FaUndo /></IconButton>)}+ {onApplyToAll && !editingThis && (+ <IconButton disabled={editingOther} size="1" variant="ghost" color="gray" title={applyToAllTitle} onClick={() => onApplyToAll(tag, value ?? '')}><FaClone /></IconButton>+ )}+{canDeleteExisting && !isDeletedExisting && !editingThis && existingTags[tag] != null && (<IconButton disabled={editingOther} size="1" color="red" variant="ghost" title={t('Delete')} onClick={() => onDeleteExistingClick(tag)}><FaTrash /></IconButton>)}