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
|
// 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
|
// 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
|
// 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
|
// 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
|
// problem by replacing the file sees it picked up promptly on the next stable
|
||||||
// scan.
|
// scan.
|
||||||
const failureBackoff = 5 * time.Minute
|
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
|
// fileStat is the (mtime, size) pair used to decide whether a file has settled
|
||||||
// between two consecutive ticks.
|
// between two consecutive ticks.
|
||||||
type fileStat struct {
|
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) {
|
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
|
||||||
if err != nil {
|
for _, ext := range inputExtensions {
|
||||||
fmt.Printf("Error scanning input directory: %v\n", err)
|
matches, err := filepath.Glob(filepath.Join(w.inputDir, "*."+ext))
|
||||||
return
|
if err != nil {
|
||||||
|
fmt.Printf("Error scanning input directory: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
files = append(files, matches...)
|
||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|||||||
Reference in New Issue
Block a user