raise data to a higher level

This commit is contained in:
oscar-davids
2020-05-14 11:33:17 +08:00
parent ff60283d83
commit ae60ad498d
5 changed files with 21 additions and 8 deletions

View File

@@ -307,7 +307,7 @@ func transcode(hlsStream stream.HLSVideoStream, flagclass int, tinterval float64
//getfile := ".tmp/" + seg.Name
getfile := workDir + seg.Name
//Transcode stream
tData, err := t.Transcode(getfile)
tData, _, err := t.Transcode(getfile)
if err != nil {
glog.Errorf("Error transcoding: %v", err)
} else {

View File

@@ -72,6 +72,7 @@ type TranscodeResults struct {
Decoded MediaInfo
Encoded []MediaInfo
DetectProb float32
Contents string
}
//for multiple model
@@ -129,7 +130,7 @@ func RTMPToHLS(localRTMPUrl string, outM3U8 string, tmpl string, seglen_secs str
}
//call subscriber
func Transcode(input string, workDir string, pid int, gid int, ps []VideoProfile) error {
func Transcode(input string, workDir string, pid int, gid int, ps []VideoProfile) (string, error) {
sdev := fmt.Sprintf("%d", gid)
opts := make([]TranscodeOptions, len(ps))
for i, param := range ps {
@@ -149,7 +150,12 @@ func Transcode(input string, workDir string, pid int, gid int, ps []VideoProfile
Device: sdev,
ParallelID: pid,
}
return Transcode2(inopts, opts)
return TranscodeAndDetection(inopts, opts)
}
func TranscodeAndDetection(input *TranscodeOptionsIn, ps []TranscodeOptions) (string, error) {
res, err := Transcode3(input, ps)
return res.Contents, err
}
func newAVOpts(opts map[string]string) *C.AVDictionary {
@@ -572,7 +578,7 @@ func (t *Transcoder) Transcode(input *TranscodeOptionsIn, psin []TranscodeOption
Pixels: int64(decoded.pixels),
}
return &TranscodeResults{Encoded: tr, Decoded: dec, DetectProb: fconfidence}, nil
return &TranscodeResults{Encoded: tr, Decoded: dec, DetectProb: fconfidence, Contents: srtmetadata}, nil
}
func NewTranscoder() *Transcoder {

1
go.mod
View File

@@ -5,4 +5,5 @@ go 1.12
require (
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/livepeer/joy4 v0.1.2-0.20191121080656-b2fea45cbded
github.com/stretchr/testify v1.5.1
)

5
go.sum
View File

@@ -9,3 +9,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@@ -32,12 +32,13 @@ func (t *FFMpegSegmentTranscoder) SetParallelID(pid int) {
func (t *FFMpegSegmentTranscoder) SetGpuID(gid int) {
t.gpuid = gid
}
func (t *FFMpegSegmentTranscoder) Transcode(fname string) ([][]byte, error) {
func (t *FFMpegSegmentTranscoder) Transcode(fname string) ([][]byte, string ,error) {
//Invoke ffmpeg
err := ffmpeg.Transcode(fname, t.workDir, t.parallelid, t.gpuid, t.tProfiles)
contents := ""
contents, err := ffmpeg.Transcode(fname, t.workDir, t.parallelid, t.gpuid, t.tProfiles)
if err != nil {
glog.Errorf("Error transcoding: %v", err)
return nil, err
return nil, contents, err
}
dout := make([][]byte, len(t.tProfiles), len(t.tProfiles))
@@ -55,5 +56,5 @@ func (t *FFMpegSegmentTranscoder) Transcode(fname string) ([][]byte, error) {
os.Remove(ofile)
}
return dout, nil
return dout, contents, nil
}