Beispiel #1
0
func ks3_mp4_merge(c *s3.S3, idx_file IndexFileT, idx_cfg IndexConfigT) bool {

	if len(idx_cfg.files) == 0 || len(idx_cfg.vdoid) == 0 {
		return true
	}

	files := ""
	for i := 1; i < len(idx_cfg.files); i++ {
		enckey := fmt.Sprintf("%s:record/%s/%s/%s/%s", idx_cfg.bucket, idx_file.app, idx_file.name, idx_file.time, idx_cfg.files[i])
		encstr := base64.StdEncoding.EncodeToString([]byte(enckey))
		if len(files) > 0 {
			files = fmt.Sprintf("%s&file=%s", files, encstr)
		} else {
			files = fmt.Sprintf("file=%s", encstr)
		}
	}

	bucket := idx_cfg.bucket
	srckey := fmt.Sprintf("record/%s/%s/%s/%s", idx_file.app, idx_file.name, idx_file.time, idx_cfg.files[0])
	dstkey := fmt.Sprintf("%s.mp4", idx_cfg.vdoid)
	command := fmt.Sprintf("tag=avconcat&f=mp4&mode=2&%s|tag=saveas&bucket=%s&object=%s", files, bucket, base64.StdEncoding.EncodeToString([]byte(dstkey)))
	contenttype := "application/ocet-stream"
	notifyurl := "http://10.4.23.113/test"

	log.Info(fmt.Sprintf("[merge flvs to mp4] bucket: %s srckey: %s dstkey: %s command: %s\n", bucket, srckey, dstkey, command))

	_, err := c.PutAdp(
		&s3.PutAdpInput{
			Bucket:      &bucket,
			Key:         &srckey,
			ContentType: &contenttype,
			Command:     &command,
			NotifyUrl:   &notifyurl,
		},
	)

	if err != nil {
		return false
	}

	return true
}