clipper/backend/media/media_set.go

56 lines
1.5 KiB
Go

package media
import (
"fmt"
"time"
"github.com/google/uuid"
)
const SizeOfInt16 = 2
type Audio struct {
ContentLength int64
Channels int
// ApproxFrames is used during initial processing when a precise frame count
// cannot be determined. Prefer Frames in all other cases.
ApproxFrames int64
Frames int64
SampleRate int
YoutubeItag int
MimeType string
}
type Video struct {
ContentLength int64
Duration time.Duration
// not sure if this are needed any more?
ThumbnailWidth int
ThumbnailHeight int
YoutubeItag int
MimeType string
}
// MediaSet represents the media and metadata associated with a single media
// resource (for example, a YouTube video).
type MediaSet struct {
Audio Audio `json:"audio"`
Video Video `json:"video"`
ID uuid.UUID `json:"id"`
YoutubeID string `json:"youtube_id"`
exists bool
}
// New builds a new MediaSet with the given ID.
func NewMediaSet(youtubeID string) *MediaSet {
return &MediaSet{YoutubeID: youtubeID}
}
// TODO: pass io.Readers/Writers instead of strings.
func (m *MediaSet) RawAudioPath() string { return fmt.Sprintf("cache/%s.raw", m.YoutubeID) }
func (m *MediaSet) EncodedAudioPath() string { return fmt.Sprintf("cache/%s.m4a", m.YoutubeID) }
func (m *MediaSet) VideoPath() string { return fmt.Sprintf("cache/%s.mp4", m.YoutubeID) }
func (m *MediaSet) ThumbnailPath() string { return fmt.Sprintf("cache/%s.jpg", m.YoutubeID) }
func (m *MediaSet) MetadataPath() string { return fmt.Sprintf("cache/%s.json", m.YoutubeID) }