Documentation ¶
Index ¶
- Constants
- Variables
- func CompareSignatureByBuffer(data1 []byte, data2 []byte) (bool, error)
- func CompareSignatureByPath(fname1 string, fname2 string) (bool, error)
- func CompareVideoByBuffer(data1 []byte, data2 []byte) (bool, error)
- func CompareVideoByPath(fname1 string, fname2 string) (bool, error)
- func DefaultProfileName(width int, height int, bitrate int) string
- func FfmpegGetLogLevel() int
- func FfmpegSetLogLevel(level int)
- func GetCodecInfo(fname string) (CodecStatus, MediaFormatInfo, error)
- func GetCodecInfoBytes(data []byte) (CodecStatus, MediaFormatInfo, error)
- func HasZeroVideoFrameBytes(data []byte) (bool, error)
- func InitFFmpeg()
- func InitFFmpegWithLogLevel(level LogLevel)
- func RTMPToHLS(localRTMPUrl string, outM3U8 string, tmpl string, seglen_secs string, ...) error
- func Strerror(errnum int) string
- func Transcode(input string, workDir string, ps []VideoProfile) error
- func Transcode2(input *TranscodeOptionsIn, ps []TranscodeOptions) error
- func VideoProfileResolution(p VideoProfile) (int, int, error)
- func VideoProfileToVariantParams(p VideoProfile) m3u8.VariantParams
- type Acceleration
- type ByName
- type ChromaSubsampling
- type CodecStatus
- type CodingSizeLimit
- type ColorDepthBits
- type ComponentOptions
- type DetectData
- type DetectorClass
- type DetectorProfile
- type DetectorType
- type Format
- type JsonProfile
- type LogLevel
- type MediaFormatInfo
- type MediaInfo
- type PixelFormat
- type Profile
- type SceneClassificationData
- type SceneClassificationProfile
- type Size
- type TranscodeOptions
- type TranscodeOptionsIn
- type TranscodeResults
- type Transcoder
- type VideoCodec
- type VideoProfile
Constants ¶
const ( PixelFormatNone int = C.AV_PIX_FMT_NONE PixelFormatYUV420P int = C.AV_PIX_FMT_YUV420P PixelFormatYUYV422 int = C.AV_PIX_FMT_YUYV422 PixelFormatYUV422P int = C.AV_PIX_FMT_YUV422P PixelFormatYUV444P int = C.AV_PIX_FMT_YUV444P PixelFormatUYVY422 int = C.AV_PIX_FMT_UYVY422 PixelFormatNV12 int = C.AV_PIX_FMT_NV12 PixelFormatNV21 int = C.AV_PIX_FMT_NV21 PixelFormatYUV420P10BE int = C.AV_PIX_FMT_YUV420P10BE PixelFormatYUV420P10LE int = C.AV_PIX_FMT_YUV420P10LE PixelFormatYUV422P10BE int = C.AV_PIX_FMT_YUV422P10BE PixelFormatYUV422P10LE int = C.AV_PIX_FMT_YUV422P10LE PixelFormatYUV444P10BE int = C.AV_PIX_FMT_YUV444P10BE PixelFormatYUV444P10LE int = C.AV_PIX_FMT_YUV444P10LE PixelFormatYUV420P16LE int = C.AV_PIX_FMT_YUV420P16LE PixelFormatYUV420P16BE int = C.AV_PIX_FMT_YUV420P16BE PixelFormatYUV422P16LE int = C.AV_PIX_FMT_YUV422P16LE PixelFormatYUV422P16BE int = C.AV_PIX_FMT_YUV422P16BE PixelFormatYUV444P16LE int = C.AV_PIX_FMT_YUV444P16LE PixelFormatYUV444P16BE int = C.AV_PIX_FMT_YUV444P16BE PixelFormatYUV420P12BE int = C.AV_PIX_FMT_YUV420P12BE PixelFormatYUV420P12LE int = C.AV_PIX_FMT_YUV420P12LE PixelFormatYUV422P12BE int = C.AV_PIX_FMT_YUV422P12BE PixelFormatYUV422P12LE int = C.AV_PIX_FMT_YUV422P12LE PixelFormatYUV444P12BE int = C.AV_PIX_FMT_YUV444P12BE PixelFormatYUV444P12LE int = C.AV_PIX_FMT_YUV444P12LE )
const ( FFLogTrace = C.LPMS_LOG_TRACE FFLogDebug = C.LPMS_LOG_DEBUG FFLogVerbose = C.LPMS_LOG_VERBOSE FFLogInfo = C.LPMS_LOG_INFO FFLogWarning = C.LPMS_LOG_WARNING FFLogError = C.LPMS_LOG_ERROR FFLogFatal = C.LPMS_LOG_FATAL FFLogPanic = C.LPMS_LOG_PANIC FFLogQuiet = C.LPMS_LOG_QUIET )
const ( GOPIntraOnly time.Duration = -1 // Must always be last. Renumber as needed. GOPInvalid = -2 )
For additional "special" GOP values enumerate backwards from here
const (
SceneClassification = iota
)
Variables ¶
var ( DSceneAdultSoccer = SceneClassificationProfile{ SampleRate: 30, ModelPath: "tasmodel.pb", Input: "input_1", Output: "Identity", Classes: []DetectorClass{{ID: 0, Name: "adult"}, {ID: 1, Name: "soccer"}}, } DSceneViolence = SceneClassificationProfile{ SampleRate: 30, ModelPath: "tviomodel.pb", Input: "input_1", Output: "reshape_3/Reshape", Classes: []DetectorClass{{ID: 2, Name: "violence"}}, } )
var ( P720p60fps16x9 = VideoProfile{Name: "P720p60fps16x9", Bitrate: "6000k", Framerate: 60, AspectRatio: "16:9", Resolution: "1280x720"} P720p30fps16x9 = VideoProfile{Name: "P720p30fps16x9", Bitrate: "4000k", Framerate: 30, AspectRatio: "16:9", Resolution: "1280x720"} P720p25fps16x9 = VideoProfile{Name: "P720p25fps16x9", Bitrate: "3500k", Framerate: 25, AspectRatio: "16:9", Resolution: "1280x720"} P720p30fps4x3 = VideoProfile{Name: "P720p30fps4x3", Bitrate: "3500k", Framerate: 30, AspectRatio: "4:3", Resolution: "960x720"} P576p30fps16x9 = VideoProfile{Name: "P576p30fps16x9", Bitrate: "1500k", Framerate: 30, AspectRatio: "16:9", Resolution: "1024x576"} P576p25fps16x9 = VideoProfile{Name: "P576p25fps16x9", Bitrate: "1500k", Framerate: 25, AspectRatio: "16:9", Resolution: "1024x576"} P360p30fps16x9 = VideoProfile{Name: "P360p30fps16x9", Bitrate: "1200k", Framerate: 30, AspectRatio: "16:9", Resolution: "640x360"} P360p25fps16x9 = VideoProfile{Name: "P360p25fps16x9", Bitrate: "1000k", Framerate: 25, AspectRatio: "16:9", Resolution: "640x360"} P360p30fps4x3 = VideoProfile{Name: "P360p30fps4x3", Bitrate: "1000k", Framerate: 30, AspectRatio: "4:3", Resolution: "480x360"} P240p30fps16x9 = VideoProfile{Name: "P240p30fps16x9", Bitrate: "600k", Framerate: 30, AspectRatio: "16:9", Resolution: "426x240"} P240p25fps16x9 = VideoProfile{Name: "P240p25fps16x9", Bitrate: "600k", Framerate: 25, AspectRatio: "16:9", Resolution: "426x240"} P240p30fps4x3 = VideoProfile{Name: "P240p30fps4x3", Bitrate: "600k", Framerate: 30, AspectRatio: "4:3", Resolution: "320x240"} P144p30fps16x9 = VideoProfile{Name: "P144p30fps16x9", Bitrate: "400k", Framerate: 30, AspectRatio: "16:9", Resolution: "256x144"} P144p25fps16x9 = VideoProfile{Name: "P144p25fps16x9", Bitrate: "400k", Framerate: 25, AspectRatio: "16:9", Resolution: "256x144"} )
Some sample video profiles
var AccelerationNameLookup = map[Acceleration]string{ Software: "SW", Nvidia: "Nvidia", Amd: "Amd", Netint: "Netint", }
var DetectorClassIDLookup = map[string]int{
"adult": 0,
"soccer": 1,
"violence": 2,
}
var EncoderProfileLookup = map[string]Profile{ "": ProfileNone, "none": ProfileNone, "h264baseline": ProfileH264Baseline, "h264main": ProfileH264Main, "h264high": ProfileH264High, "h264constrainedhigh": ProfileH264ConstrainedHigh, }
var ErrCodecName = fmt.Errorf("unknown codec name")
var ErrDNNInitialize = errors.New("DetectorInitializationError")
var ErrEmptyData = errors.New("EmptyData")
var ErrProfName = fmt.Errorf("unknown VideoProfile profile name")
var ErrSignCompare = errors.New("InvalidSignData")
var ErrTranscoderClipConfig = errors.New("TranscoderInvalidClipConfig")
var ErrTranscoderDev = errors.New("TranscoderIncompatibleDevices")
var ErrTranscoderFmt = errors.New("TranscoderUnrecognizedFormat")
var ErrTranscoderGOP = errors.New("TranscoderInvalidGOP")
var ErrTranscoderHw = errors.New("TranscoderInvalidHardware")
var ErrTranscoderInp = errors.New("TranscoderInvalidInput")
var ErrTranscoderPixelformat = errors.New("TranscoderInvalidPixelformat")
var ErrTranscoderPrf = errors.New("TranscoderUnrecognizedProfile")
var ErrTranscoderRes = errors.New("TranscoderInvalidResolution")
var ErrTranscoderStp = errors.New("TranscoderStopped")
var ErrTranscoderVid = errors.New("TranscoderInvalidVideo")
var ErrVideoCompare = errors.New("InvalidVideoData")
var ErrorMap = error_map()
var ExtensionFormats = map[string]Format{ ".ts": FormatMPEGTS, ".mp4": FormatMP4, }
var FfEncoderLookup = map[Acceleration]map[VideoCodec]string{ Software: { H264: "libx264", H265: "libx265", VP8: "libvpx", VP9: "libvpx-vp9", }, Nvidia: { H264: "h264_nvenc", H265: "hevc_nvenc", }, Netint: { H264: "h264_ni_enc", H265: "h265_ni_enc", }, }
var FfmpegNameToVideoCodec = map[string]VideoCodec{ "h264": H264, "hevc": H265, "vp8": VP8, "vp9": VP9, }
var FormatExtensions = map[Format]string{ FormatNone: ".ts", FormatMPEGTS: ".ts", FormatMP4: ".mp4", }
var LogTranscodeErrors = true
Switch to turn off logging transcoding errors, when doing test transcoding
var NonRetryableErrs = non_retryable_errs()
var ProfileParameters = map[Profile]string{ ProfileNone: "", ProfileH264Baseline: "baseline", ProfileH264Main: "main", ProfileH264High: "high422", ProfileH264ConstrainedHigh: "high422", }
var SceneClassificationProfileLookup = map[string]SceneClassificationProfile{ "adult": DSceneAdultSoccer, "soccer": DSceneAdultSoccer, "violence": DSceneViolence, }
var VideoCodecName = map[VideoCodec]string{ H264: "H.264", H265: "HEVC", VP8: "VP8", VP9: "VP9", }
var VideoProfileLookup = map[string]VideoProfile{ "P720p60fps16x9": P720p60fps16x9, "P720p30fps16x9": P720p30fps16x9, "P720p25fps16x9": P720p25fps16x9, "P720p30fps4x3": P720p30fps4x3, "P576p30fps16x9": P576p30fps16x9, "P576p25fps16x9": P576p25fps16x9, "P360p30fps16x9": P360p30fps16x9, "P360p25fps16x9": P360p25fps16x9, "P360p30fps4x3": P360p30fps4x3, "P240p30fps16x9": P240p30fps16x9, "P240p25fps16x9": P240p25fps16x9, "P240p30fps4x3": P240p30fps4x3, "P144p30fps16x9": P144p30fps16x9, }
Functions ¶
func CompareSignatureByBuffer ¶
compare two signature buffers whether those matches or not
func CompareSignatureByPath ¶
compare two signature files whether those matches or not
func CompareVideoByBuffer ¶
compare two video buffers whether those matches or not
func CompareVideoByPath ¶
compare two vidoe files whether those matches or not
func FfmpegGetLogLevel ¶
func FfmpegGetLogLevel() int
func FfmpegSetLogLevel ¶
func FfmpegSetLogLevel(level int)
func GetCodecInfo ¶
func GetCodecInfo(fname string) (CodecStatus, MediaFormatInfo, error)
func GetCodecInfoBytes ¶
func GetCodecInfoBytes(data []byte) (CodecStatus, MediaFormatInfo, error)
GetCodecInfo opens the segment and attempts to get video and audio codec names. Additionally, first return value indicates whether the segment has zero video frames
func HasZeroVideoFrameBytes ¶
HasZeroVideoFrameBytes opens video and returns true if it has video stream with 0-frame
func InitFFmpeg ¶
func InitFFmpeg()
func InitFFmpegWithLogLevel ¶
func InitFFmpegWithLogLevel(level LogLevel)
func Strerror ¶
Strerror returns a descriptive string of the given return code.
C-Function: av_strerror
func Transcode2 ¶
func Transcode2(input *TranscodeOptionsIn, ps []TranscodeOptions) error
func VideoProfileResolution ¶
func VideoProfileResolution(p VideoProfile) (int, int, error)
func VideoProfileToVariantParams ¶
func VideoProfileToVariantParams(p VideoProfile) m3u8.VariantParams
Types ¶
type ByName ¶
type ByName []VideoProfile
type ChromaSubsampling ¶
type ChromaSubsampling int
const ( ChromaSubsampling420 ChromaSubsampling = iota ChromaSubsampling422 ChromaSubsampling444 )
type CodecStatus ¶
type CodecStatus int
const ( CodecStatusInternalError CodecStatus = -1 CodecStatusOk CodecStatus = 0 CodecStatusNeedsBypass CodecStatus = 1 CodecStatusMissing CodecStatus = 2 )
type CodingSizeLimit ¶
func (*CodingSizeLimit) Clamp ¶
func (l *CodingSizeLimit) Clamp(p *VideoProfile, format MediaFormatInfo) error
type ColorDepthBits ¶
type ColorDepthBits int
hold bit number minus 8; ColorDepthBits + 8 == bit number
const ( ColorDepth8Bit ColorDepthBits = 0 ColorDepth10Bit ColorDepthBits = 2 ColorDepth12Bit ColorDepthBits = 4 ColorDepth16Bit ColorDepthBits = 8 )
type ComponentOptions ¶
type DetectData ¶
type DetectData interface {
Type() DetectorType
}
type DetectorClass ¶
type DetectorProfile ¶
type DetectorProfile interface {
Type() DetectorType
}
type DetectorType ¶
type DetectorType int
type JsonProfile ¶
type JsonProfile struct { Name string `json:"name"` Width int `json:"width"` Height int `json:"height"` Bitrate int `json:"bitrate"` FPS uint `json:"fps"` FPSDen uint `json:"fpsDen"` Profile string `json:"profile"` GOP string `json:"gop"` Encoder string `json:"encoder"` ColorDepth ColorDepthBits `json:"colorDepth"` ChromaFormat ChromaSubsampling `json:"chromaFormat"` }
type LogLevel ¶
type LogLevel C.enum_LPMSLogLevel
type MediaFormatInfo ¶
type MediaFormatInfo struct {
Acodec, Vcodec string
PixFormat PixelFormat
Width, Height int
}
func (*MediaFormatInfo) ScaledHeight ¶
func (f *MediaFormatInfo) ScaledHeight(width int) int
func (*MediaFormatInfo) ScaledWidth ¶
func (f *MediaFormatInfo) ScaledWidth(height int) int
type MediaInfo ¶
type MediaInfo struct { Frames int Pixels int64 DetectData DetectData }
type PixelFormat ¶
type PixelFormat struct {
RawValue int
}
func (PixelFormat) Properties ¶
func (pixelFormat PixelFormat) Properties() (ChromaSubsampling, ColorDepthBits, error)
type SceneClassificationData ¶
func (SceneClassificationData) Type ¶
func (scd SceneClassificationData) Type() DetectorType
type SceneClassificationProfile ¶
type SceneClassificationProfile struct { SampleRate uint ModelPath string Input string Output string Classes []DetectorClass }
func (*SceneClassificationProfile) Type ¶
func (p *SceneClassificationProfile) Type() DetectorType
type Size ¶
type Size struct {
W, H int
}
func (*Size) Valid ¶
func (s *Size) Valid(l *CodingSizeLimit) bool
type TranscodeOptions ¶
type TranscodeOptions struct { Oname string Profile VideoProfile Detector DetectorProfile Accel Acceleration Device string CalcSign bool From time.Duration To time.Duration Muxer ComponentOptions VideoEncoder ComponentOptions AudioEncoder ComponentOptions }
type TranscodeOptionsIn ¶
type TranscodeOptionsIn struct { Fname string Accel Acceleration Device string Transmuxing bool }
type TranscodeResults ¶
func Transcode3 ¶
func Transcode3(input *TranscodeOptionsIn, ps []TranscodeOptions) (*TranscodeResults, error)
type Transcoder ¶
type Transcoder struct {
// contains filtered or unexported fields
}
func NewTranscoder ¶
func NewTranscoder() *Transcoder
func NewTranscoderWithDetector ¶
func NewTranscoderWithDetector(detector DetectorProfile, deviceid string) (*Transcoder, error)
func (*Transcoder) Discontinuity ¶
func (t *Transcoder) Discontinuity()
func (*Transcoder) StopTranscoder ¶
func (t *Transcoder) StopTranscoder()
func (*Transcoder) Transcode ¶
func (t *Transcoder) Transcode(input *TranscodeOptionsIn, ps []TranscodeOptions) (*TranscodeResults, error)
type VideoCodec ¶
type VideoCodec int
const ( H264 VideoCodec = iota H265 VP8 VP9 )
func CodecNameToValue ¶
func CodecNameToValue(encoder string) (VideoCodec, error)
type VideoProfile ¶
type VideoProfile struct { Name string Bitrate string Framerate uint FramerateDen uint Resolution string AspectRatio string Format Format Profile Profile GOP time.Duration Encoder VideoCodec ColorDepth ColorDepthBits ChromaFormat ChromaSubsampling }
Standard Profiles: 1080p60fps: 9000kbps 1080p30fps: 6000kbps 720p60fps: 6000kbps 720p30fps: 4000kbps 480p30fps: 2000kbps 360p30fps: 1000kbps 240p30fps: 700kbps 144p30fps: 400kbps
func ParseProfiles ¶
func ParseProfiles(injson []byte) ([]VideoProfile, error)
func ParseProfilesFromJsonProfileArray ¶
func ParseProfilesFromJsonProfileArray(profiles []JsonProfile) ([]VideoProfile, error)