ffmpeg/detector: Add support for content detection

Co-authored-by: Jai Luthra <me@jailuthra.in>
This commit is contained in:
Oscar
2021-06-23 08:33:28 -04:00
committed by GitHub
parent 301900dd25
commit 4e4a3a87d2
11 changed files with 420 additions and 13 deletions
+12 -2
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strings"
"time"
"github.com/livepeer/lpms/ffmpeg"
)
@@ -48,7 +49,9 @@ func main() {
o := ffmpeg.TranscodeOptions{
Oname: fmt.Sprintf("out_%s_%d_out.mkv", lbl, i),
Profile: profs[i],
Accel: accel,
// Uncomment the following to test scene classifier
// Detector: &ffmpeg.DSceneAdultSoccer,
Accel: accel,
}
opts = append(opts, o)
}
@@ -66,6 +69,7 @@ func main() {
ffmpeg.InitFFmpeg()
t := time.Now()
fmt.Printf("Setting fname %s encoding %d renditions with %v\n", fname, len(options), lbl)
res, err := ffmpeg.Transcode3(&ffmpeg.TranscodeOptionsIn{
Fname: fname,
@@ -75,8 +79,14 @@ func main() {
if err != nil {
panic(err)
}
end := time.Now()
fmt.Printf("profile=input frames=%v pixels=%v\n", res.Decoded.Frames, res.Decoded.Pixels)
for i, r := range res.Encoded {
fmt.Printf("profile=%v frames=%v pixels=%v\n", profiles[i].Name, r.Frames, r.Pixels)
if r.DetectData != nil {
fmt.Printf("profile=%v frames=%v pixels=%v detectdata=%v\n", profiles[i].Name, r.Frames, r.Pixels, r.DetectData)
} else {
fmt.Printf("profile=%v frames=%v pixels=%v\n", profiles[i].Name, r.Frames, r.Pixels)
}
}
fmt.Printf("Transcoding time %0.4v\n", end.Sub(t).Seconds())
}