Documentation ¶
Index ¶
- Constants
- Variables
- func Download(configDirectory string) error
- func GetFrameFromRegex(str string) int
- func GetPaths(configDirectory string) (string, string)
- func GetTimeFromRegex(str string) float64
- func IsValidAudio(audio AudioCodec, ValidCodecs []AudioCodec) bool
- func IsValidAudioForContainer(audio AudioCodec, format Container) bool
- func IsValidCodec(codecName string) bool
- func IsValidCombo(codecName string, format Container) bool
- func IsValidForContainer(format Container, validContainers []Container) bool
- func KillRunningEncoders(path string)
- type AudioCodec
- type Container
- type Encoder
- func (e *Encoder) CopyVideo(probeResult VideoFile, options TranscodeOptions)
- func (e *Encoder) SceneMarkerImage(probeResult VideoFile, options SceneMarkerOptions) error
- func (e *Encoder) SceneMarkerVideo(probeResult VideoFile, options SceneMarkerOptions) error
- func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePreviewChunkOptions, preset string)
- func (e *Encoder) ScenePreviewVideoChunkCombine(probeResult VideoFile, concatFilePath string, outputPath string)
- func (e *Encoder) ScenePreviewVideoToImage(probeResult VideoFile, width int, videoPreviewPath string, outputPath string) error
- func (e *Encoder) Screenshot(probeResult VideoFile, options ScreenshotOptions) error
- func (e *Encoder) StreamMkvTranscodeAudio(probeResult VideoFile, startTime string, ...) (io.ReadCloser, *os.Process, error)
- func (e *Encoder) StreamTranscode(probeResult VideoFile, startTime string, ...) (io.ReadCloser, *os.Process, error)
- func (e *Encoder) StreamTranscodeVideo(probeResult VideoFile, startTime string, ...) (io.ReadCloser, *os.Process, error)
- func (e *Encoder) Transcode(probeResult VideoFile, options TranscodeOptions)
- func (e *Encoder) TranscodeAudio(probeResult VideoFile, options TranscodeOptions)
- func (e *Encoder) TranscodeVideo(probeResult VideoFile, options TranscodeOptions)
- type FFProbeJSON
- type FFProbeStream
- type SceneMarkerOptions
- type ScenePreviewChunkOptions
- type ScreenshotOptions
- type TranscodeOptions
- type VideoFile
Constants ¶
const ( Mp4 Container = "mp4" M4v Container = "m4v" Mov Container = "mov" Wmv Container = "wmv" Webm Container = "webm" Matroska Container = "matroska" Avi Container = "avi" Flv Container = "flv" Mpegts Container = "mpegts" Aac AudioCodec = "aac" Mp3 AudioCodec = "mp3" Opus AudioCodec = "opus" Vorbis AudioCodec = "vorbis" MissingUnsupported AudioCodec = "" Mp4Ffmpeg string = "mov,mp4,m4a,3gp,3g2,mj2" // browsers support all of them M4vFfmpeg string = "mov,mp4,m4a,3gp,3g2,mj2" // so we don't care that ffmpeg MovFfmpeg string = "mov,mp4,m4a,3gp,3g2,mj2" // can't differentiate between them WmvFfmpeg string = "asf" WebmFfmpeg string = "matroska,webm" MatroskaFfmpeg string = "matroska,webm" AviFfmpeg string = "avi" FlvFfmpeg string = "flv" MpegtsFfmpeg string = "mpegts" H264 string = "h264" H265 string = "h265" // found in rare cases from a faulty encoder Hevc string = "hevc" Vp8 string = "vp8" Vp9 string = "vp9" MimeWebm string = "video/webm" MimeMkv string = "video/x-matroska" )
Variables ¶
var ContainerToFfprobe = map[Container]string{ Mp4: Mp4Ffmpeg, M4v: M4vFfmpeg, Mov: MovFfmpeg, Wmv: WmvFfmpeg, Webm: WebmFfmpeg, Matroska: MatroskaFfmpeg, Avi: AviFfmpeg, Flv: FlvFfmpeg, Mpegts: MpegtsFfmpeg, }
maps user readable container strings to ffprobe's format_name on some formats ffprobe can't differentiate
var FfprobeToContainer = map[string]Container{ Mp4Ffmpeg: Mp4, WmvFfmpeg: Wmv, AviFfmpeg: Avi, FlvFfmpeg: Flv, MpegtsFfmpeg: Mpegts, MatroskaFfmpeg: Matroska, }
var FrameRegex = regexp.MustCompile(`frame=\s*([0-9]+)`)
var TimeRegex = regexp.MustCompile(`time=\s*(\d+):(\d+):(\d+.\d+)`)
Functions ¶
func GetFrameFromRegex ¶
func GetTimeFromRegex ¶
func IsValidAudio ¶ added in v0.2.0
func IsValidAudio(audio AudioCodec, ValidCodecs []AudioCodec) bool
func IsValidAudioForContainer ¶ added in v0.2.0
func IsValidAudioForContainer(audio AudioCodec, format Container) bool
func IsValidCodec ¶
func IsValidCombo ¶ added in v0.2.0
extend stream validation check to take into account container
func IsValidForContainer ¶ added in v0.2.0
func KillRunningEncoders ¶
func KillRunningEncoders(path string)
Types ¶
type AudioCodec ¶ added in v0.2.0
type AudioCodec string
type Container ¶ added in v0.2.0
type Container string
func MagicContainer ¶ added in v0.2.0
returns container as string ("" on error or no match) implements only mkv or webm as ffprobe can't distinguish between them and not all browsers support mkv
func MatchContainer ¶ added in v0.2.0
type Encoder ¶
type Encoder struct {
Path string
}
func NewEncoder ¶
func (*Encoder) CopyVideo ¶ added in v0.2.0
func (e *Encoder) CopyVideo(probeResult VideoFile, options TranscodeOptions)
copy the video stream as is, drop audio
func (*Encoder) SceneMarkerImage ¶
func (e *Encoder) SceneMarkerImage(probeResult VideoFile, options SceneMarkerOptions) error
func (*Encoder) SceneMarkerVideo ¶
func (e *Encoder) SceneMarkerVideo(probeResult VideoFile, options SceneMarkerOptions) error
func (*Encoder) ScenePreviewVideoChunk ¶
func (e *Encoder) ScenePreviewVideoChunk(probeResult VideoFile, options ScenePreviewChunkOptions, preset string)
func (*Encoder) ScenePreviewVideoChunkCombine ¶
func (*Encoder) ScenePreviewVideoToImage ¶
func (*Encoder) Screenshot ¶
func (e *Encoder) Screenshot(probeResult VideoFile, options ScreenshotOptions) error
func (*Encoder) StreamMkvTranscodeAudio ¶ added in v0.2.0
func (e *Encoder) StreamMkvTranscodeAudio(probeResult VideoFile, startTime string, maxTranscodeSize models.StreamingResolutionEnum) (io.ReadCloser, *os.Process, error)
it is very common in MKVs to have just the audio codec unsupported copy the video stream, transcode the audio and serve as Matroska
func (*Encoder) StreamTranscode ¶
func (e *Encoder) StreamTranscode(probeResult VideoFile, startTime string, maxTranscodeSize models.StreamingResolutionEnum) (io.ReadCloser, *os.Process, error)
func (*Encoder) StreamTranscodeVideo ¶ added in v0.2.0
func (e *Encoder) StreamTranscodeVideo(probeResult VideoFile, startTime string, maxTranscodeSize models.StreamingResolutionEnum) (io.ReadCloser, *os.Process, error)
transcode the video, remove the audio in some videos where the audio codec is not supported by ffmpeg ffmpeg fails if you try to transcode the audio
func (*Encoder) Transcode ¶
func (e *Encoder) Transcode(probeResult VideoFile, options TranscodeOptions)
func (*Encoder) TranscodeAudio ¶ added in v0.2.0
func (e *Encoder) TranscodeAudio(probeResult VideoFile, options TranscodeOptions)
copy the video stream as is, transcode audio
func (*Encoder) TranscodeVideo ¶ added in v0.2.0
func (e *Encoder) TranscodeVideo(probeResult VideoFile, options TranscodeOptions)
transcode the video, remove the audio in some videos where the audio codec is not supported by ffmpeg ffmpeg fails if you try to transcode the audio
type FFProbeJSON ¶
type FFProbeJSON struct { Format struct { BitRate string `json:"bit_rate"` Duration string `json:"duration"` Filename string `json:"filename"` FormatLongName string `json:"format_long_name"` FormatName string `json:"format_name"` NbPrograms int `json:"nb_programs"` NbStreams int `json:"nb_streams"` ProbeScore int `json:"probe_score"` Size string `json:"size"` StartTime string `json:"start_time"` Tags struct { CompatibleBrands string `json:"compatible_brands"` CreationTime models.JSONTime `json:"creation_time"` Encoder string `json:"encoder"` MajorBrand string `json:"major_brand"` MinorVersion string `json:"minor_version"` Title string `json:"title"` Comment string `json:"comment"` } `json:"tags"` } `json:"format"` Streams []FFProbeStream `json:"streams"` Error struct { Code int `json:"code"` String string `json:"string"` } `json:"error"` }
type FFProbeStream ¶
type FFProbeStream struct { AvgFrameRate string `json:"avg_frame_rate"` BitRate string `json:"bit_rate"` BitsPerRawSample string `json:"bits_per_raw_sample,omitempty"` ChromaLocation string `json:"chroma_location,omitempty"` CodecLongName string `json:"codec_long_name"` CodecName string `json:"codec_name"` CodecTag string `json:"codec_tag"` CodecTagString string `json:"codec_tag_string"` CodecTimeBase string `json:"codec_time_base"` CodecType string `json:"codec_type"` CodedHeight int `json:"coded_height,omitempty"` CodedWidth int `json:"coded_width,omitempty"` DisplayAspectRatio string `json:"display_aspect_ratio,omitempty"` Disposition struct { AttachedPic int `json:"attached_pic"` CleanEffects int `json:"clean_effects"` Comment int `json:"comment"` Default int `json:"default"` Dub int `json:"dub"` Forced int `json:"forced"` HearingImpaired int `json:"hearing_impaired"` Karaoke int `json:"karaoke"` Lyrics int `json:"lyrics"` Original int `json:"original"` TimedThumbnails int `json:"timed_thumbnails"` VisualImpaired int `json:"visual_impaired"` } `json:"disposition"` Duration string `json:"duration"` DurationTs int `json:"duration_ts"` HasBFrames int `json:"has_b_frames,omitempty"` Height int `json:"height,omitempty"` Index int `json:"index"` IsAvc string `json:"is_avc,omitempty"` Level int `json:"level,omitempty"` NalLengthSize string `json:"nal_length_size,omitempty"` NbFrames string `json:"nb_frames"` PixFmt string `json:"pix_fmt,omitempty"` Profile string `json:"profile"` RFrameRate string `json:"r_frame_rate"` Refs int `json:"refs,omitempty"` SampleAspectRatio string `json:"sample_aspect_ratio,omitempty"` StartPts int `json:"start_pts"` StartTime string `json:"start_time"` Tags struct { CreationTime models.JSONTime `json:"creation_time"` HandlerName string `json:"handler_name"` Language string `json:"language"` Rotate string `json:"rotate"` } `json:"tags"` TimeBase string `json:"time_base"` Width int `json:"width,omitempty"` BitsPerSample int `json:"bits_per_sample,omitempty"` ChannelLayout string `json:"channel_layout,omitempty"` Channels int `json:"channels,omitempty"` MaxBitRate string `json:"max_bit_rate,omitempty"` SampleFmt string `json:"sample_fmt,omitempty"` SampleRate string `json:"sample_rate,omitempty"` }
type SceneMarkerOptions ¶
type ScreenshotOptions ¶
type TranscodeOptions ¶
type TranscodeOptions struct { OutputPath string MaxTranscodeSize models.StreamingResolutionEnum }
type VideoFile ¶
type VideoFile struct { JSON FFProbeJSON AudioStream *FFProbeStream VideoStream *FFProbeStream Path string Title string Comment string Container string Duration float64 StartTime float64 Bitrate int64 Size int64 CreationTime time.Time VideoCodec string VideoBitrate int64 Width int Height int FrameRate float64 Rotation int64 AudioCodec string }
func NewVideoFile ¶
Execute exec command and bind result to struct.
func (*VideoFile) GetAudioStream ¶
func (v *VideoFile) GetAudioStream() *FFProbeStream
func (*VideoFile) GetVideoStream ¶
func (v *VideoFile) GetVideoStream() *FFProbeStream
func (*VideoFile) SetTitleFromPath ¶
func (v *VideoFile) SetTitleFromPath()