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.
This commit is contained in:
@@ -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,11 +87,15 @@ 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"))
|
||||
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()
|
||||
nextSeen := make(map[string]fileStat, len(files))
|
||||
|
||||
Reference in New Issue
Block a user