55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package credits
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"fmt"
|
||
|
|
"os"
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestDebugDump(t *testing.T) {
|
||
|
|
path := os.Getenv("MEMBY_DEBUG_CLIP")
|
||
|
|
if path == "" {
|
||
|
|
t.Skip("no clip")
|
||
|
|
}
|
||
|
|
s := &Sampler{Timeout: 2 * time.Minute}
|
||
|
|
coarse, err := s.Sample(context.Background(), path, 0, 91380*time.Millisecond, coarseInterval)
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
t.Logf("coarse frames=%d", len(coarse))
|
||
|
|
for i, f := range coarse {
|
||
|
|
t.Logf(" [%2d] pos=%6d mean=%.3f dark=%.3f edge=%.4f var=%.4f diff=%.4f score=%.3f",
|
||
|
|
i, f.PositionMs, f.Mean, f.DarkFraction, f.EdgeDensity, f.Variance, f.Diff, creditScore(f))
|
||
|
|
}
|
||
|
|
idx, sep, ok := findTransition(coarse, coarseInterval)
|
||
|
|
t.Logf("coarse transition idx=%d pos=%v sep=%.3f ok=%v", idx, func() int64 {
|
||
|
|
if ok {
|
||
|
|
return coarse[idx].PositionMs
|
||
|
|
}
|
||
|
|
return -1
|
||
|
|
}(), sep, ok)
|
||
|
|
|
||
|
|
if !ok {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
start := time.Duration(coarse[idx].PositionMs) * time.Millisecond
|
||
|
|
from := start - fineSpan
|
||
|
|
if from < 0 {
|
||
|
|
from = 0
|
||
|
|
}
|
||
|
|
to := start + fineSpan
|
||
|
|
fine, err := s.Sample(context.Background(), path, from, to, fineInterval)
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
fmt.Println("fine from", from, "to", to, "frames", len(fine))
|
||
|
|
fidx, fsep, fok := findTransition(fine, fineInterval)
|
||
|
|
if fok {
|
||
|
|
t.Logf("fine transition idx=%d pos=%d sep=%.3f", fidx, fine[fidx].PositionMs, fsep)
|
||
|
|
} else {
|
||
|
|
t.Logf("fine transition: NONE (fine pass did not refine)")
|
||
|
|
}
|
||
|
|
}
|