From 6a564aabb2eb3f2ef46e0f237caec8d7bf4ffa77 Mon Sep 17 00:00:00 2001 From: Esa Kataja Date: Mon, 18 May 2026 08:34:55 +0300 Subject: [PATCH] fix: detect mp4 and other common containers in watcher The watcher only globbed *.mkv, silently ignoring every other source container. Expand the glob to a list of common input extensions (mkv, mp4, m4v, mov, avi, ts, m2ts, mts, mpg, mpeg, vob, webm, wmv, flv). Downstream is unaffected: workdir naming uses filepath.Ext, the encoder always emits .mkv output, and the metadata regexes are not end-anchored. --- internal/watcher/watcher.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index af358cf..8f5b2ea 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -13,12 +13,21 @@ import ( // failureBackoff is how long we skip a file after processFn returned an error // for it, provided the file has not been touched since (mtime unchanged). Chosen // to be much larger than the polling interval so a permanently-broken input -// (e.g. video-only mkv producing "no audio streams found") does not spam the +// (e.g. a video-only file producing "no audio streams found") does not spam the // log every tick, but short enough that an operator who fixes the underlying // problem by replacing the file sees it picked up promptly on the next stable // scan. const failureBackoff = 5 * time.Minute +// inputExtensions lists the source container extensions the watcher will pick +// up. Globbed case-sensitively (matching prior .mkv behavior). +var inputExtensions = []string{ + "mkv", "mp4", "m4v", "mov", "avi", + "ts", "m2ts", "mts", + "mpg", "mpeg", "vob", + "webm", "wmv", "flv", +} + // fileStat is the (mtime, size) pair used to decide whether a file has settled // between two consecutive ticks. type fileStat struct { @@ -78,10 +87,14 @@ func (w *Watcher) Start(ctx context.Context, processFn func(context.Context, str } func (w *Watcher) scanAndProcess(ctx context.Context, processFn func(context.Context, string) error) { - files, err := filepath.Glob(filepath.Join(w.inputDir, "*.mkv")) - if err != nil { - fmt.Printf("Error scanning input directory: %v\n", err) - return + var files []string + for _, ext := range inputExtensions { + matches, err := filepath.Glob(filepath.Join(w.inputDir, "*."+ext)) + if err != nil { + fmt.Printf("Error scanning input directory: %v\n", err) + return + } + files = append(files, matches...) } now := time.Now()