Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Cut a clip: buttons reachable with Tab (Space / Enter press a button focused from the keyboard), the work folder named like a job's so a crash sweep takes it, a localized music picker, volume up to 200 % everywhere, the first audio track when copying too

flexeykinDev1996df462199
diff --git a/src/Filee.App/Assets/i18n/ar.json b/src/Filee.App/Assets/i18n/ar.json
index 99324607..cf087e7d 100644
--- a/src/Filee.App/Assets/i18n/ar.json
+++ b/src/Filee.App/Assets/i18n/ar.json
@@ -216,6 +216,8 @@
"clip.mute_hint": "كتم صوت الجزء المحدد مع بقاء الصورة (Delete على A1 يفعل ذلك أيضًا)",
"clip.music": "موسيقى",
"clip.music_hint": "وضع موسيقى من ملف تحت المقطع (A2): اسحبها لتحريكها واسحب خطها لمستوى الصوت",
+ "clip.music_pick": "موسيقى للمقطع",
+ "clip.music_files": "ملفات الصوت والفيديو",
"clip.no_music": "لا يحتوي هذا الملف على صوت يصلح موسيقى",
"clip.preparing": "جارٍ التحضير…",
"clip.finding_silence": "جارٍ البحث عن الصمت…",
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.json
index 51ee5042..0dbc6510 100644
--- a/src/Filee.App/Assets/i18n/en.json
+++ b/src/Filee.App/Assets/i18n/en.json
@@ -225,6 +225,8 @@
"clip.mute_hint": "Mute the selected piece's sound; its picture plays on (Delete on A1 does it too)",
"clip.music": "Music",
"clip.music_hint": "Put music from a file under the clip (A2): drag it along, drag its line for the volume",
+ "clip.music_pick": "Music for the clip",
+ "clip.music_files": "Sound and video files",
"clip.no_music": "This file has no sound to use as music",
"clip.preparing": "Preparing…",
"clip.finding_silence": "Finding silence…",
diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.json
index 742cc045..68a6f465 100644
--- a/src/Filee.App/Assets/i18n/es.json
+++ b/src/Filee.App/Assets/i18n/es.json
@@ -216,6 +216,8 @@
"clip.mute_hint": "Silenciar el sonido del fragmento elegido; la imagen sigue (Supr en A1 hace lo mismo)",
"clip.music": "Música",
"clip.music_hint": "Poner música de un archivo bajo el clip (A2): arrástrala, arrastra su línea para el volumen",
+ "clip.music_pick": "Música para el clip",
+ "clip.music_files": "Archivos de sonido y vídeo",
"clip.no_music": "Este archivo no tiene sonido para usar como música",
"clip.preparing": "Preparando…",
"clip.finding_silence": "Buscando silencios…",
diff --git a/src/Filee.App/Assets/i18n/fr.json b/src/Filee.App/Assets/i18n/fr.json
index b5666fb7..73ff0764 100644
--- a/src/Filee.App/Assets/i18n/fr.json
+++ b/src/Filee.App/Assets/i18n/fr.json
@@ -225,6 +225,8 @@
"clip.mute_hint": "Couper le son du morceau choisi ; l'image continue (Suppr sur A1 fait de même)",
"clip.music": "Musique",
"clip.music_hint": "Mettre la musique d'un fichier sous l'extrait (A2) : faites-la glisser, tirez sa ligne pour le volume",
+ "clip.music_pick": "Musique pour l'extrait",
+ "clip.music_files": "Fichiers son et vidéo",
"clip.no_music": "Ce fichier n'a pas de son à utiliser comme musique",
"clip.preparing": "Préparation…",
"clip.finding_silence": "Recherche des silences…",
diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.json
index 3fff199a..60203570 100644
--- a/src/Filee.App/Assets/i18n/hi.json
+++ b/src/Filee.App/Assets/i18n/hi.json
@@ -216,6 +216,8 @@
"clip.mute_hint": "चुने गए टुकड़े की आवाज़ बंद करें; चित्र चलता रहे (A1 पर Delete भी यही करता है)",
"clip.music": "संगीत",
"clip.music_hint": "फ़ाइल का संगीत क्लिप के नीचे लगाएँ (A2): खींचकर खिसकाएँ, रेखा खींचकर आवाज़ बदलें",
+ "clip.music_pick": "क्लिप के लिए संगीत",
+ "clip.music_files": "ध्वनि और वीडियो फ़ाइलें",
"clip.no_music": "इस फ़ाइल में संगीत के लिए आवाज़ नहीं है",
"clip.preparing": "तैयारी हो रही है…",
"clip.finding_silence": "चुप्पी ढूँढ रहे हैं…",
diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.json
index 94bc6847..8de8c73f 100644
--- a/src/Filee.App/Assets/i18n/ja.json
+++ b/src/Filee.App/Assets/i18n/ja.json
@@ -216,6 +216,8 @@
"clip.mute_hint": "選んだ区間の音声を消し、映像はそのまま(A1 で Delete も同じ)",
"clip.music": "音楽",
"clip.music_hint": "ファイルの音楽をクリップの下に置く(A2):ドラッグで移動、線をドラッグで音量",
+ "clip.music_pick": "クリップの音楽",
+ "clip.music_files": "音声・動画ファイル",
"clip.no_music": "このファイルには音楽に使える音声がありません",
"clip.preparing": "準備中…",
"clip.finding_silence": "無音を検出中…",
diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.json
index 9cd3e4a7..6e9f9672 100644
--- a/src/Filee.App/Assets/i18n/ko.json
+++ b/src/Filee.App/Assets/i18n/ko.json
@@ -225,6 +225,8 @@
"clip.mute_hint": "선택한 조각의 소리를 끄고 화면은 그대로 둬요 (A1에서 Delete도 같아요)",
"clip.music": "음악",
"clip.music_hint": "파일의 음악을 클립 아래에 깔기 (A2): 끌어서 옮기고, 선을 끌어 음량 조절",
+ "clip.music_pick": "클립에 넣을 음악",
+ "clip.music_files": "소리 및 동영상 파일",
"clip.no_music": "이 파일에는 음악으로 쓸 소리가 없어요",
"clip.preparing": "준비 중…",
"clip.finding_silence": "무음 찾는 중…",
diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.json
index f487414f..f175ecb9 100644
--- a/src/Filee.App/Assets/i18n/pl.json
+++ b/src/Filee.App/Assets/i18n/pl.json
@@ -225,6 +225,8 @@
"clip.mute_hint": "Wycisz dźwięk wybranego fragmentu; obraz gra dalej (Delete na A1 robi to samo)",
"clip.music": "Muzyka",
"clip.music_hint": "Podłóż muzykę z pliku pod klip (A2): przeciągaj ją, przeciągnij linię, by zmienić głośność",
+ "clip.music_pick": "Muzyka do klipu",
+ "clip.music_files": "Pliki dźwięku i wideo",
"clip.no_music": "Ten plik nie ma dźwięku do użycia jako muzyka",
"clip.preparing": "Przygotowanie…",
"clip.finding_silence": "Szukam ciszy…",
diff --git a/src/Filee.App/Assets/i18n/pt-BR.json b/src/Filee.App/Assets/i18n/pt-BR.json
index 33e97455..34cee1b0 100644
--- a/src/Filee.App/Assets/i18n/pt-BR.json
+++ b/src/Filee.App/Assets/i18n/pt-BR.json
@@ -225,6 +225,8 @@
"clip.mute_hint": "Silenciar o som do trecho escolhido; a imagem continua (Delete em A1 faz o mesmo)",
"clip.music": "Música",
"clip.music_hint": "Colocar música de um arquivo sob o clipe (A2): arraste para mover, arraste a linha para o volume",
+ "clip.music_pick": "Música para o clipe",
+ "clip.music_files": "Arquivos de som e vídeo",
"clip.no_music": "Este arquivo não tem som para usar como música",
"clip.preparing": "Preparando…",
"clip.finding_silence": "Procurando silêncio…",
diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.json
index 38e157d2..14c756e8 100644
--- a/src/Filee.App/Assets/i18n/ru.json
+++ b/src/Filee.App/Assets/i18n/ru.json
@@ -225,6 +225,8 @@
"clip.mute_hint": "Выключить звук выбранного куска, картинка остаётся (Delete на дорожке A1 делает то же)",
"clip.music": "Музыка",
"clip.music_hint": "Подложить музыку из файла под клип (дорожка A2): двигайте её мышкой, тяните линию — громкость",
+ "clip.music_pick": "Музыка для клипа",
+ "clip.music_files": "Звук и видео",
"clip.no_music": "В этом файле нет звука для музыки",
"clip.preparing": "Подготовка…",
"clip.finding_silence": "Ищу тишину…",
diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.json
index 6db99b75..1de1ba2e 100644
--- a/src/Filee.App/Assets/i18n/zh-CN.json
+++ b/src/Filee.App/Assets/i18n/zh-CN.json
@@ -225,6 +225,8 @@
"clip.mute_hint": "关闭所选片段的声音,画面照常播放(在 A1 上按 Delete 也一样)",
"clip.music": "音乐",
"clip.music_hint": "把文件中的音乐垫在片段下面(A2):拖动来移动,拖动线条调音量",
+ "clip.music_pick": "片段的音乐",
+ "clip.music_files": "声音和视频文件",
"clip.no_music": "此文件没有可用作音乐的声音",
"clip.preparing": "准备中…",
"clip.finding_silence": "正在查找静音…",
diff --git a/src/Filee.App/Assets/i18n/zh-TW.json b/src/Filee.App/Assets/i18n/zh-TW.json
index 6f70b563..68fd0a59 100644
--- a/src/Filee.App/Assets/i18n/zh-TW.json
+++ b/src/Filee.App/Assets/i18n/zh-TW.json
@@ -225,6 +225,8 @@
"clip.mute_hint": "關閉所選片段的聲音,畫面照常播放(在 A1 上按 Delete 也一樣)",
"clip.music": "音樂",
"clip.music_hint": "把檔案中的音樂墊在片段下面(A2):拖曳來移動,拖曳線條調整音量",
+ "clip.music_pick": "片段的音樂",
+ "clip.music_files": "聲音和影片檔案",
"clip.no_music": "這個檔案沒有可用作音樂的聲音",
"clip.preparing": "準備中…",
"clip.finding_silence": "正在尋找靜音…",
diff --git a/src/Filee.App/ViewModels/ClipWindowViewModel.cs b/src/Filee.App/ViewModels/ClipWindowViewModel.cs
index 4e00de32..52d32226 100644
--- a/src/Filee.App/ViewModels/ClipWindowViewModel.cs
+++ b/src/Filee.App/ViewModels/ClipWindowViewModel.cs
@@ -280,6 +280,11 @@ public sealed partial class ClipWindowViewModel : ObservableObject, IDisposable
public bool HasMusic => Music is not null;
/// <summary>What the window is busy with ("Preparing…" before the clip plays), or empty.</summary>
+ /// <summary>The music picker's title and the name of the files it lists.</summary>
+ public string MusicPickerTitle => _loc["clip.music_pick"];
+
+ public string MusicFilesName => _loc["clip.music_files"];
+
public string BusyText => IsBuffering ? _loc["clip.preparing"]
: IsFindingSilence ? _loc["clip.finding_silence"]
: IsAddingMusic ? _loc["clip.loading_music"]
@@ -483,7 +488,8 @@ public sealed partial class ClipWindowViewModel : ObservableObject, IDisposable
_log = log;
_isFast = !tool.Media.ExactCut;
_hasMultipleFiles = files.Count > 1;
- _workFolder = Path.Combine(Path.GetTempPath(), "Filee", "clip-" + Guid.NewGuid().ToString("N")[..10]);
+ // Named like a job's work folder, so the sweep after a crash (JobQueue.DeleteStaleWorkFolders) takes it too.
+ _workFolder = Path.Combine(Filee.Core.Conversion.JobQueue.DefaultWorkRoot, Guid.NewGuid().ToString("N")[..10]);
loc.LanguageChanged += OnLanguageChanged;
_ = LoadFileAsync(0);
}
diff --git a/src/Filee.App/Views/ClipWindow.axaml b/src/Filee.App/Views/ClipWindow.axaml
index 12d2f20c..d72f5758 100644
--- a/src/Filee.App/Views/ClipWindow.axaml
+++ b/src/Filee.App/Views/ClipWindow.axaml
@@ -95,11 +95,6 @@
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="CornerRadius" Value="999" />
</Style>
- <!-- The window is worked with its own keys (Space plays, Enter saves): its buttons never keep the keyboard focus,
- so Space can't press the one clicked last (maximize, a fade, the magnet). -->
- <Style Selector="Button, ToggleButton">
- <Setter Property="Focusable" Value="False" />
- </Style>
<Style Selector="Button.round, ToggleButton.round">
<Setter Property="Padding" Value="9" />
<Setter Property="Width" Value="34" />
diff --git a/src/Filee.App/Views/ClipWindow.axaml.cs b/src/Filee.App/Views/ClipWindow.axaml.cs
index 3bfb09e5..9408f394 100644
--- a/src/Filee.App/Views/ClipWindow.axaml.cs
+++ b/src/Filee.App/Views/ClipWindow.axaml.cs
@@ -22,16 +22,22 @@ public partial class ClipWindow : Window
private ClipWindowViewModel? _vm;
+ /// <summary>The focus came from the keyboard (Tab, arrows), not from a click.</summary>
+ private bool _focusByKeyboard;
+
public ClipWindow()
{
InitializeComponent();
Motion.Track(this);
DataContextChanged += OnDataContextChanged;
+ AddHandler(GotFocusEvent, (_, e) => _focusByKeyboard = e.NavigationMethod is NavigationMethod.Tab or NavigationMethod.Directional,
+ RoutingStrategies.Bubble, handledEventsToo: true);
AddHandler(KeyDownEvent, OnKeyDownFirst, RoutingStrategies.Tunnel);
- // Space and Enter are the window's own: their key-up must not press a button either.
+ // Space and Enter are the window's own (play, save), so a button that was clicked can't be pressed by them
+ // later; their key-up must not press it either. A button reached with Tab is pressed by them as usual.
AddHandler(KeyUpEvent, (_, e) =>
{
- if (e.Key is Key.Space or Key.Enter)
+ if (e.Key is Key.Space or Key.Enter && !ButtonHasKeyboard())
e.Handled = true;
}, RoutingStrategies.Tunnel);
ResizeGrip.PointerPressed += OnGripPressed;
@@ -49,10 +55,11 @@ public partial class ClipWindow : Window
{
var files = await StorageProvider.OpenFilePickerAsync(new Avalonia.Platform.Storage.FilePickerOpenOptions
{
+ Title = vm.MusicPickerTitle,
AllowMultiple = false,
FileTypeFilter =
[
- new Avalonia.Platform.Storage.FilePickerFileType("Audio")
+ new Avalonia.Platform.Storage.FilePickerFileType(vm.MusicFilesName)
{
Patterns = ["*.mp3", "*.m4a", "*.aac", "*.wav", "*.flac", "*.ogg", "*.opus", "*.wma", "*.mp4", "*.mkv", "*.mov", "*.webm"],
},
@@ -113,11 +120,19 @@ public partial class ClipWindow : Window
// ───────────────────────── Keys ─────────────────────────
- /// <summary>Before any focused control: Enter always saves (not "click the focused button").</summary>
+ /// <summary>A button (or toggle) has the focus, reached with the keyboard: Space and Enter press it.</summary>
+ private bool ButtonHasKeyboard() => _focusByKeyboard && FocusManager?.GetFocusedElement() is Button;
+
+ /// <summary>
+ /// Before any focused control: Space plays and Enter saves, unless a button was reached with Tab (then they press
+ /// it, as everywhere else).
+ /// </summary>
private void OnKeyDownFirst(object? sender, KeyEventArgs e)
{
if (_vm is not { } vm)
return;
+ if (e.Key is Key.Space or Key.Enter && e.KeyModifiers == KeyModifiers.None && ButtonHasKeyboard())
+ return;
var plain = e.KeyModifiers == KeyModifiers.None;
var command = e.KeyModifiers == KeyModifiers.Control || e.KeyModifiers == KeyModifiers.Meta;
var commandShift = e.KeyModifiers == (KeyModifiers.Control | KeyModifiers.Shift) || e.KeyModifiers == (KeyModifiers.Meta | KeyModifiers.Shift);
diff --git a/src/Filee.Core/Presets/ClipEdit.cs b/src/Filee.Core/Presets/ClipEdit.cs
index abfc9162..88225dfb 100644
--- a/src/Filee.Core/Presets/ClipEdit.cs
+++ b/src/Filee.Core/Presets/ClipEdit.cs
@@ -13,8 +13,8 @@ public sealed class ClipPart
/// <summary>Slowest and fastest speed of a part.</summary>
public const double MinSpeed = 0.25, MaxSpeed = 4;
- /// <summary>Loudest volume of a part: four times as loud (+12 dB). 0 is silent.</summary>
- public const double MaxVolume = 4;
+ /// <summary>Loudest volume of a part: twice as loud (+6 dB), as far as the volume slider and line go. 0 is silent.</summary>
+ public const double MaxVolume = 2;
/// <summary>The speeds the clip window offers.</summary>
public static IReadOnlyList<double> Speeds { get; } = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4];
diff --git a/src/Filee.Engines/Media/MediaEncoding.cs b/src/Filee.Engines/Media/MediaEncoding.cs
index 5d422150..98a2db27 100644
--- a/src/Filee.Engines/Media/MediaEncoding.cs
+++ b/src/Filee.Engines/Media/MediaEncoding.cs
@@ -285,8 +285,9 @@ internal static partial class MediaEncoding
/// <summary>
/// A part of a video copied as it is (<c>-c copy</c>): done in a moment and nothing is lost, but a copy can only
/// start at a key frame, so the clip starts at the last one before <see cref="ClipRange.Start"/> (up to a few
- /// seconds early). The first video stream and every audio track are kept (none with
- /// <see cref="MediaOptions.RemoveAudio"/>); the other options only apply to an exact clip, which is encoded.
+ /// seconds early). The first video stream and the first audio track are kept (none with
+ /// <see cref="MediaOptions.RemoveAudio"/>), as in an exact or edited clip and in Filee's other conversions; the
+ /// other options only apply to an exact clip, which is encoded.
/// </summary>
/// <exception cref="InvalidOperationException">The file has no video stream.</exception>
/// <exception cref="NotSupportedException">FFmpeg cannot write <paramref name="target"/>.</exception>
@@ -299,7 +300,7 @@ internal static partial class MediaEncoding
List<string> args = [.. Common, .. ClipInput(clip), "-i", input, "-map", "0:V:0"];
if (audio)
- args.AddRange(["-map", "0:a"]);
+ args.AddRange(["-map", "0:a:0"]);
args.AddRange(["-c", "copy"]);
// Apple plays HEVC in MP4/MOV only under the "hvc1" tag (FFmpeg keeps "hev1" from some sources).
if (video.Codec == "hevc" && target is "mp4" or "m4v" or "mov")
diff --git a/tests/Filee.App.Tests/ClipWindowTests.cs b/tests/Filee.App.Tests/ClipWindowTests.cs
index 946aa4a9..cdc5c45e 100644
--- a/tests/Filee.App.Tests/ClipWindowTests.cs
+++ b/tests/Filee.App.Tests/ClipWindowTests.cs
@@ -793,7 +793,7 @@ public class ClipWindowTests
{
WithClipWindow("en", false, ["match.mp4"], (window, vm, frames, _) =>
{
- // Click maximize (and back), the magnet and a fade: none of them keeps the keyboard.
+ // Click maximize (and back), the magnet and the zoom: Space still plays, it presses none of them.
foreach (var name in new[] { "MaximizeButton", "MaximizeButton", "MagnetToggle", "ZoomToggle" })
{
var button = window.FindControl<Control>(name)!;
@@ -801,7 +801,6 @@ public class ClipWindowTests
window.MouseDown(centre, MouseButton.Left);
window.MouseUp(centre, MouseButton.Left);
Pump();
- Assert.False(button.IsFocused);
}
var state = window.WindowState;
var magnet = vm.IsMagnet;
@@ -814,6 +813,31 @@ public class ClipWindowTests
});
}
+ [AvaloniaFact]
+ public void A_button_reached_with_Tab_is_pressed_by_Space_and_Enter()
+ {
+ WithClipWindow("en", false, ["match.mp4"], (window, vm, frames, _) =>
+ {
+ var magnet = window.FindControl<Avalonia.Controls.Primitives.ToggleButton>("MagnetToggle")!;
+ Assert.True(magnet.Focusable);
+ var before = vm.IsMagnet;
+ magnet.Focus(NavigationMethod.Tab);
+ Pump();
+
+ Press(window, Key.Space);
+ window.KeyRelease(Key.Space, RawInputModifiers.None, PhysicalKey.None, null);
+ Pump();
+ Assert.NotEqual(before, vm.IsMagnet);
+ Assert.Empty(frames.Played);
+
+ Press(window, Key.Enter);
+ window.KeyRelease(Key.Enter, RawInputModifiers.None, PhysicalKey.None, null);
+ Pump();
+ Assert.Equal(before, vm.IsMagnet);
+ Assert.False(vm.IsFinished);
+ });
+ }
+
[AvaloniaFact]
public void The_window_says_it_is_preparing_until_the_clip_starts_playing()
{
diff --git a/tests/Filee.Engines.Tests/ClipTests.cs b/tests/Filee.Engines.Tests/ClipTests.cs
index 14038a28..ea10a844 100644
--- a/tests/Filee.Engines.Tests/ClipTests.cs
+++ b/tests/Filee.Engines.Tests/ClipTests.cs
@@ -41,7 +41,7 @@ public class ClipTests(EngineFixture fx) : IClassFixture<EngineFixture>
Assert.DoesNotContain("-c:v", args);
Assert.DoesNotContain("-vf", args);
// The video and every audio track; the copied timestamps start at 0.
- Assert.Equal(["0:V:0", "0:a"], args.Select((a, i) => (a, i)).Where(x => x.a == "-map").Select(x => args[x.i + 1]));
+ Assert.Equal(["0:V:0", "0:a:0"], args.Select((a, i) => (a, i)).Where(x => x.a == "-map").Select(x => args[x.i + 1]));
Assert.Equal("make_zero", After(args, "-avoid_negative_ts"));
Assert.Equal("mp4", After(args, "-f"));
Assert.Equal("+faststart", After(args, "-movflags"));
@@ -52,7 +52,7 @@ public class ClipTests(EngineFixture fx) : IClassFixture<EngineFixture>
public void A_fast_clip_without_sound_leaves_the_audio_out()
{
var args = MediaEncoding.ClipCopy("in.mkv", "out.mkv", "mkv", new ClipRange(0, 15), new MediaOptions { RemoveAudio = true }, Movie);
- Assert.DoesNotContain("0:a", args);
+ Assert.DoesNotContain("0:a:0", args);
Assert.Contains("-an", args);
Assert.Equal("matroska", After(args, "-f"));