Documentation
¶
Index ¶
- Constants
- Variables
- func Abs(x int32) int32
- func ConvertSubtitle(format string, stream io.ReadCloser, outFmt string, out io.WriteCloser) error
- func GetEnvOr(env string, def string) string
- func GetMimeCodec(stream *ffprobe.Stream) *string
- func Map[T, U any](ts []T, f func(T, int) U) []U
- func MapStream[T any](streams []*ffprobe.Stream, kind ffprobe.StreamType, ...) []T
- func NewStream(file *FileStream, keyframes *Keyframe, handle StreamHandle, ret *Stream)
- func NullIfUnd(str string) *string
- func OrNull(str string) *string
- func ParseFloat(str string) float32
- func ParseInt64(str string) int64
- func ParseUint(str string) uint32
- type Audio
- type AudioStream
- type CMap
- type Chapter
- type ChapterType
- type ClientInfo
- type FileStream
- func (fs *FileStream) Destroy()
- func (fs *FileStream) GetAudioIndex(audio uint32, client string) (string, error)
- func (fs *FileStream) GetAudioSegment(audio uint32, segment int32) (string, error)
- func (fs *FileStream) GetMaster(client string) string
- func (fs *FileStream) GetVideoIndex(idx uint32, quality Quality, client string) (string, error)
- func (fs *FileStream) GetVideoSegment(idx uint32, quality Quality, segment int32) (string, error)
- func (fs *FileStream) Kill()
- type Flags
- type Head
- type HwAccelT
- type Keyframe
- type KeyframeInfo
- type KeyframeKey
- type MediaInfo
- type MetadataService
- func (s *MetadataService) Close() error
- func (s *MetadataService) ExtractSubs(ctx context.Context, info *MediaInfo) (any, error)
- func (s *MetadataService) ExtractThumbs(ctx context.Context, path string, sha string) (interface{}, error)
- func (s *MetadataService) GetAttachment(ctx context.Context, sha string, name string) (io.ReadCloser, error)
- func (s *MetadataService) GetKeyframes(info *MediaInfo, isVideo bool, idx uint32) (*Keyframe, error)
- func (s *MetadataService) GetMetadata(ctx context.Context, path string, sha string) (*MediaInfo, error)
- func (s *MetadataService) GetSubtitle(ctx context.Context, path string, sha string, name string) (io.ReadCloser, error)
- func (s *MetadataService) GetThumbSprite(ctx context.Context, path string, sha string) (io.ReadCloser, error)
- func (s *MetadataService) GetThumbVtt(ctx context.Context, path string, sha string) (io.ReadCloser, error)
- type Quality
- type Result
- type RunLock
- type Segment
- type SettingsT
- type Stream
- type StreamHandle
- type Subtitle
- type Task
- type Thumbnail
- type Tracker
- func (t *Tracker) DestroyStreamIfOld(sha string)
- func (t *Tracker) KillAudioIfDead(sha string, path string, audio uint32) bool
- func (t *Tracker) KillOrphanedHeads(sha string, video *VideoKey, audio *uint32)
- func (t *Tracker) KillStreamIfDead(sha string, path string) bool
- func (t *Tracker) KillVideoIfDead(sha string, path string, video VideoKey) bool
- type Transcoder
- func (t *Transcoder) GetAudioIndex(ctx context.Context, path string, audio uint32, client string, sha string) (string, error)
- func (t *Transcoder) GetAudioSegment(ctx context.Context, path string, audio uint32, segment int32, client string, ...) (string, error)
- func (t *Transcoder) GetMaster(ctx context.Context, path string, client string, sha string) (string, error)
- func (t *Transcoder) GetVideoIndex(ctx context.Context, path string, video uint32, quality Quality, client string, ...) (string, error)
- func (t *Transcoder) GetVideoSegment(ctx context.Context, path string, video uint32, quality Quality, segment int32, ...) (string, error)
- func (t *Transcoder) NewAudioStream(file *FileStream, idx uint32) (*AudioStream, error)
- func (t *Transcoder) NewVideoStream(file *FileStream, idx uint32, quality Quality) (*VideoStream, error)
- type Versions
- type Video
- type VideoKey
- type VideoStream
Constants ¶
View Source
const DummyKeyframeDuration = float64(4)
View Source
const ExtractVersion = 1
View Source
const InfoVersion = 3
View Source
const (
KeyframeVersion = 1
)
View Source
const ThumbsVersion = 1
Variables ¶
View Source
var DeletedHead = Head{ // contains filtered or unexported fields }
Purposfully removing Original from this list (since it require special treatments anyways)
View Source
var Settings = SettingsT{ Outpath: path.Join(GetEnvOr("GOCODER_CACHE_ROOT", "/cache"), "kyoo_cache"), SafePath: GetEnvOr("GOCODER_SAFE_PATH", "/video"), JwksUrl: os.Getenv("JWKS_URL"), HwAccel: DetectHardwareAccel(), }
View Source
var SubtitleExtensions = map[string]string{
"subrip": "srt",
"ass": "ass",
"vtt": "vtt",
"hdmv_pgs_subtitle": "sup",
}
Functions ¶
func ConvertSubtitle ¶
func ConvertSubtitle( format string, stream io.ReadCloser, outFmt string, out io.WriteCloser, ) error
func GetMimeCodec ¶
convert mediainfo to RFC 6381, waiting for either of those tickets to be resolved:
https://sourceforge.net/p/mediainfo/feature-requests/499 https://trac.ffmpeg.org/ticket/6617
this code is addapted from https://github.com/jellyfin/jellyfin/blob/master/Jellyfin.Api/Helpers/HlsCodecStringHelpers.cs and https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD%3a/libavformat/hlsenc.c#l344
func NewStream ¶
func NewStream(file *FileStream, keyframes *Keyframe, handle StreamHandle, ret *Stream)
func ParseFloat ¶
func ParseInt64 ¶
Types ¶
type Audio ¶
type Audio struct {
Sha string `json:"-" db:"sha"`
/// The index of this track on the media.
Index uint32 `json:"index" db:"idx"`
/// The title of the stream.
Title *string `json:"title" db:"title"`
/// The language of this stream (as a IETF-BCP-47 language code)
Language *string `json:"language" db:"language"`
/// The human readable codec name.
Codec string `json:"codec" db:"codec"`
/// The codec of this stream (defined as the RFC 6381).
MimeCodec *string `json:"mimeCodec" db:"mime_codec"`
/// The average bitrate of the audio in bytes/s
Bitrate uint32 `json:"bitrate" db:"bitrate"`
/// Is this stream the default one of it's type?
IsDefault bool `json:"isDefault" db:"is_default"`
/// Keyframes of this video
Keyframes *Keyframe `json:"-"`
}
type AudioStream ¶
type AudioStream struct {
Stream
// contains filtered or unexported fields
}
type CMap ¶
type CMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewCMap ¶
func NewCMap[K comparable, V any]() CMap[K, V]
func (*CMap[K, V]) GetAndRemove ¶
func (*CMap[K, V]) GetOrCreate ¶
type Chapter ¶
type Chapter struct {
Sha string `json:"-" db:"sha"`
/// The start time of the chapter (in second from the start of the episode).
StartTime float32 `json:"startTime" db:"start_time"`
/// The end time of the chapter (in second from the start of the episode).
EndTime float32 `json:"endTime" db:"end_time"`
/// The name of this chapter. This should be a human-readable name that could be presented to the user.
Name string `json:"name" db:"name"`
/// The type value is used to mark special chapters (openning/credits...)
Type ChapterType `json:"type" db:"type"`
}
type ChapterType ¶
type ChapterType string
const ( Content ChapterType = "content" Recap ChapterType = "recap" Intro ChapterType = "intro" Credits ChapterType = "credits" Preview ChapterType = "preview" )
type ClientInfo ¶
type ClientInfo struct {
// contains filtered or unexported fields
}
type FileStream ¶
func (*FileStream) Destroy ¶
func (fs *FileStream) Destroy()
func (*FileStream) GetAudioIndex ¶
func (fs *FileStream) GetAudioIndex(audio uint32, client string) (string, error)
func (*FileStream) GetAudioSegment ¶
func (fs *FileStream) GetAudioSegment(audio uint32, segment int32) (string, error)
func (*FileStream) GetMaster ¶
func (fs *FileStream) GetMaster(client string) string
func (*FileStream) GetVideoIndex ¶
func (*FileStream) GetVideoSegment ¶
func (*FileStream) Kill ¶
func (fs *FileStream) Kill()
type HwAccelT ¶
type HwAccelT struct {
Name string
DecodeFlags []string
EncodeFlags []string
NoResizeFilter string
ScaleFilter string
}
func DetectHardwareAccel ¶
func DetectHardwareAccel() HwAccelT
type Keyframe ¶
func (*Keyframe) AddListener ¶
type KeyframeInfo ¶
type KeyframeInfo struct {
// contains filtered or unexported fields
}
type KeyframeKey ¶
type MediaInfo ¶
type MediaInfo struct {
// The sha1 of the video file.
Sha string `json:"sha" db:"sha"`
/// The internal path of the video file.
Path string `json:"path" db:"path"`
/// The extension currently used to store this video file
Extension string `json:"extension" db:"extension"`
/// The whole mimetype (defined as the RFC 6381). ex: `video/mp4; codecs=\"avc1.640028, mp4a.40.2\"`
MimeCodec *string `json:"mimeCodec" db:"mime_codec"`
/// The file size of the video file.
Size int64 `json:"size" db:"size"`
/// The length of the media in seconds.
Duration float64 `json:"duration" db:"duration"`
/// The container of the video file of this episode.
Container *string `json:"container" db:"container"`
/// Version of the metadata. This can be used to invalidate older metadata from db if the extraction code has changed.
Versions Versions `json:"versions" db:"versions"`
/// The list of videos if there are multiples.
Videos []Video `json:"videos" db:"-"`
/// The list of audio tracks.
Audios []Audio `json:"audios" db:"-"`
/// The list of subtitles tracks.
Subtitles []Subtitle `json:"subtitles" db:"-"`
/// The list of fonts that can be used to display subtitles.
Fonts []string `json:"fonts" db:"fonts"`
/// The list of chapters. See Chapter for more information.
Chapters []Chapter `json:"chapters" db:"-"`
// contains filtered or unexported fields
}
func (*MediaInfo) SearchExternalSubtitles ¶
type MetadataService ¶
func NewMetadataService ¶
func NewMetadataService() (*MetadataService, error)
func (*MetadataService) Close ¶
func (s *MetadataService) Close() error
func (*MetadataService) ExtractSubs ¶
func (*MetadataService) ExtractThumbs ¶
func (*MetadataService) GetAttachment ¶
func (s *MetadataService) GetAttachment(ctx context.Context, sha string, name string) (io.ReadCloser, error)
func (*MetadataService) GetKeyframes ¶
func (*MetadataService) GetMetadata ¶
func (*MetadataService) GetSubtitle ¶
func (s *MetadataService) GetSubtitle( ctx context.Context, path string, sha string, name string, ) (io.ReadCloser, error)
func (*MetadataService) GetThumbSprite ¶
func (s *MetadataService) GetThumbSprite(ctx context.Context, path string, sha string) (io.ReadCloser, error)
func (*MetadataService) GetThumbVtt ¶
func (s *MetadataService) GetThumbVtt(ctx context.Context, path string, sha string) (io.ReadCloser, error)
type Quality ¶
type Quality string
func QualityFromString ¶
func (Quality) AverageBitrate ¶
I'm not entierly sure about the values for bitrates. Double checking would be nice.
func (Quality) MaxBitrate ¶
type RunLock ¶
type RunLock[K comparable, V any] struct { // contains filtered or unexported fields }
func NewRunLock ¶
func NewRunLock[K comparable, V any]() RunLock[K, V]
type StreamHandle ¶
type StreamHandle interface {
// contains filtered or unexported methods
}
type Subtitle ¶
type Subtitle struct {
Sha string `json:"-" db:"sha"`
/// The index of this track on the media.
Index *uint32 `json:"index" db:"idx"`
/// The title of the stream.
Title *string `json:"title" db:"title"`
/// The language of this stream (as a IETF-BCP-47 language code)
Language *string `json:"language" db:"language"`
/// The codec of this stream.
Codec string `json:"codec" db:"codec"`
/// The extension for the codec.
Extension *string `json:"extension" db:"extension"`
/// Is this stream the default one of it's type?
IsDefault bool `json:"isDefault" db:"is_default"`
/// Is this stream tagged as forced?
IsForced bool `json:"isForced" db:"is_forced"`
/// Is this stream tagged as hearing impaired?
IsHearingImpaired bool `json:"isHearingImpaired" db:"is_hearing_impaired"`
/// Is this an external subtitle (as in stored in a different file)
IsExternal bool `json:"isExternal" db:"-"`
/// Where the subtitle is stored (null if stored inside the video)
Path *string `json:"path" db:"-"`
/// The link to access this subtitle.
Link *string `json:"link" db:"-"`
}
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
func NewTracker ¶
func NewTracker(t *Transcoder) *Tracker
func (*Tracker) DestroyStreamIfOld ¶
func (*Tracker) KillAudioIfDead ¶
func (*Tracker) KillOrphanedHeads ¶
type Transcoder ¶
type Transcoder struct {
// contains filtered or unexported fields
}
func NewTranscoder ¶
func NewTranscoder(metadata *MetadataService) (*Transcoder, error)
func (*Transcoder) GetAudioIndex ¶
func (*Transcoder) GetAudioSegment ¶
func (*Transcoder) GetVideoIndex ¶
func (*Transcoder) GetVideoSegment ¶
func (*Transcoder) NewAudioStream ¶
func (t *Transcoder) NewAudioStream(file *FileStream, idx uint32) (*AudioStream, error)
func (*Transcoder) NewVideoStream ¶
func (t *Transcoder) NewVideoStream(file *FileStream, idx uint32, quality Quality) (*VideoStream, error)
type Video ¶
type Video struct {
Sha string `json:"-" db:"sha"`
/// The index of this track on the media.
Index uint32 `json:"index" db:"idx"`
/// The title of the stream.
Title *string `json:"title" db:"title"`
/// The language of this stream (as a ISO-639-2 language code)
Language *string `json:"language" db:"language"`
/// The human readable codec name.
Codec string `json:"codec" db:"codec"`
/// The codec of this stream (defined as the RFC 6381).
MimeCodec *string `json:"mimeCodec" db:"mime_codec"`
/// The width of the video stream
Width uint32 `json:"width" db:"width"`
/// The height of the video stream
Height uint32 `json:"height" db:"height"`
/// The average bitrate of the video in bytes/s
Bitrate uint32 `json:"bitrate" db:"bitrate"`
/// Is this stream the default one of it's type?
IsDefault bool `json:"isDefault" db:"is_default"`
/// Keyframes of this video
Keyframes *Keyframe `json:"-"`
}
type VideoStream ¶
type VideoStream struct {
Stream
// contains filtered or unexported fields
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.