Пример #1
0
func encodeWorker(pathCh <-chan string) {
	for path := range pathCh {
		sid := strings.Split(path, "/")[2] // todo - make batter

		_, err := DbConn.Exec("UPDATE file SET encode_start_ts=UNIX_TIMESTAMP() WHERE sid=?", sid)
		if err != nil {
			log.Error(err)
			// todo whole cleanup
			continue
		}

		pathSpl := strings.Split(path, "/")
		filePath := "./" + strings.Join(pathSpl[0:len(pathSpl)-1], "/") + "/"
		fileName := pathSpl[len(pathSpl)-1]
		log.Debugln(path, filePath, fileName)

		mt := mediatools.NewMediaInfo(log)
		err = mt.EncodeVideoFile(filePath, fileName)
		if err != nil {
			log.Error(err)
		}

		encodeEnded(sid, err)
	}
}
Пример #2
0
func PossibleToEncode(sid string) (bool, mediatools.MediaFileInfo, map[string]mediatools.VideoResolution, error) {
	mt := mediatools.NewMediaInfo(log)

	userFolder := StorageIncomplete + sid

	ok, minfob, resolutions, err := mt.CheckMedia(userFolder + "/1")
	if err != nil {
		log.Error(err)
		cleanUploadFolderCh <- userFolder
		return false, minfob, resolutions, err
	}

	return ok, minfob, resolutions, nil
}