media

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultCopyright = "©2022 Beihang University & Uni-Ledger Co. Ltd."
View Source
const DefaultUseThread = 8
View Source
const MaxUseThread = 20

Variables

View Source
var FontFilePath = []string{"/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf", "/Library/Fonts/Arial Unicode.ttf"}

Functions

func ConvertFormat

func ConvertFormat(srcInfo, descInfo MediaInfo) error

func Encode

func Encode(w io.Writer, i image.Image, subsampleRatio PixelFormat) error

func GetDuration

func GetDuration(fpath string) (dur time.Duration, err error)

func GetFps

func GetFps(fpath string) (fps float64, err error)

func ImageFromNV12Parallel

func ImageFromNV12Parallel(w int, h int, data []byte, threadMax int) image.Image

func ImageFromYUYV2Parallel

func ImageFromYUYV2Parallel(w int, h int, data []byte, threadMax int) image.Image

func ImageGen

func ImageGen(width, height int, str string) image.Image

func ImageToNV12Parallel

func ImageToNV12Parallel(img image.Image, threadMax int) []byte

func ImageToYUYVParallel

func ImageToYUYVParallel(img image.Image, threadMax int) []byte

Types

type FfprobeResult

type FfprobeResult struct {
	Streams []struct {
		Index              int    `json:"index"`
		CodecName          string `json:"codec_name"`
		CodecLongName      string `json:"codec_long_name"`
		Profile            string `json:"profile"`
		CodecType          string `json:"codec_type"`
		CodecTagString     string `json:"codec_tag_string"`
		CodecTag           string `json:"codec_tag"`
		Width              int    `json:"width"`
		Height             int    `json:"height"`
		CodedWidth         int    `json:"coded_width"`
		CodedHeight        int    `json:"coded_height"`
		ClosedCaptions     int    `json:"closed_captions"`
		FilmGrain          int    `json:"film_grain"`
		HasBFrames         int    `json:"has_b_frames"`
		SampleAspectRatio  string `json:"sample_aspect_ratio"`
		DisplayAspectRatio string `json:"display_aspect_ratio"`
		PixFmt             string `json:"pix_fmt"`
		Level              int    `json:"level"`
		ColorRange         string `json:"color_range"`
		ColorSpace         string `json:"color_space"`
		ColorTransfer      string `json:"color_transfer"`
		ColorPrimaries     string `json:"color_primaries"`
		ChromaLocation     string `json:"chroma_location"`
		FieldOrder         string `json:"field_order"`
		Refs               int    `json:"refs"`
		IsAvc              string `json:"is_avc"`
		NalLengthSize      string `json:"nal_length_size"`
		Id                 string `json:"id"`
		RFrameRate         string `json:"r_frame_rate"`
		AvgFrameRate       string `json:"avg_frame_rate"`
		TimeBase           string `json:"time_base"`
		StartPts           int    `json:"start_pts"`
		StartTime          string `json:"start_time"`
		DurationTs         int    `json:"duration_ts"`
		Duration           string `json:"duration"`
		BitRate            string `json:"bit_rate"`
		BitsPerRawSample   string `json:"bits_per_raw_sample"`
		NbFrames           string `json:"nb_frames"`
		ExtradataSize      int    `json:"extradata_size"`
		Disposition        struct {
			Default         int `json:"default"`
			Dub             int `json:"dub"`
			Original        int `json:"original"`
			Comment         int `json:"comment"`
			Lyrics          int `json:"lyrics"`
			Karaoke         int `json:"karaoke"`
			Forced          int `json:"forced"`
			HearingImpaired int `json:"hearing_impaired"`
			VisualImpaired  int `json:"visual_impaired"`
			CleanEffects    int `json:"clean_effects"`
			AttachedPic     int `json:"attached_pic"`
			TimedThumbnails int `json:"timed_thumbnails"`
			Captions        int `json:"captions"`
			Descriptions    int `json:"descriptions"`
			Metadata        int `json:"metadata"`
			Dependent       int `json:"dependent"`
			StillImage      int `json:"still_image"`
		} `json:"disposition"`
		Tags struct {
			Language    string `json:"language"`
			HandlerName string `json:"handler_name"`
			VendorId    string `json:"vendor_id"`
		} `json:"tags"`
	} `json:"streams"`
	Format struct {
		Filename string `json:"filename"`
		Duration string `json:"duration"`
		Size     string `json:"size"`
		BitRate  string `json:"bit_rate"`
	} `json:"format"`
}

func FfprobeMedia

func FfprobeMedia(fpath string) (rst FfprobeResult, err error)

type FrameProcessor

type FrameProcessor struct {
	// contains filtered or unexported fields
}

func (*FrameProcessor) CalcLines

func (f *FrameProcessor) CalcLines(lineStart, lineCount int)

func (*FrameProcessor) GenerateIndexMapNV12

func (f *FrameProcessor) GenerateIndexMapNV12(width, height int)

func (*FrameProcessor) GetImage

func (f *FrameProcessor) GetImage() *image.RGBA

func (*FrameProcessor) GetImageParallel

func (f *FrameProcessor) GetImageParallel() *image.RGBA

func (*FrameProcessor) GetYUYV

func (f *FrameProcessor) GetYUYV() (w, h int, data []byte)

func (*FrameProcessor) SaveBMP

func (f *FrameProcessor) SaveBMP(filename string) error

func (*FrameProcessor) SetDataNV12

func (f *FrameProcessor) SetDataNV12(w, h int, data []byte)

func (*FrameProcessor) SetDataYUYV

func (f *FrameProcessor) SetDataYUYV(w, h int, data []byte)

type MediaInfo

type MediaInfo struct {
	Filepath  string
	MediaType PixelFormat
	FPS       int
	Width     int
	Height    int
	Bitrate   string
}

type PixelFormat

type PixelFormat int
const (
	AUTO    PixelFormat = iota
	NV12    PixelFormat = iota
	YUYV422 PixelFormat = iota
	MP4V    PixelFormat = iota
	IMGS    PixelFormat = iota
	JPEG    PixelFormat = iota
	BMP     PixelFormat = iota
	PNG     PixelFormat = iota
)

type YUV

type YUV struct {
	Y, UV       []uint8
	YStride     int
	CStride     int
	PixelFormat PixelFormat
	Rect        image.Rectangle
}

func NewYUV

func NewYUV(r image.Rectangle, subsampleRatio PixelFormat) *YUV

NewYCbCr returns a new YCbCr image with the given bounds and subsample ratio.

func (*YUV) At

func (p *YUV) At(x, y int) color.Color

func (*YUV) Bounds

func (p *YUV) Bounds() image.Rectangle

func (*YUV) COffset

func (p *YUV) COffset(x, y int) int

COffset returns the index of the first element of Cb or Cr that corresponds to the pixel at (x, y).

func (*YUV) ColorModel

func (p *YUV) ColorModel() color.Model

func (*YUV) Opaque

func (p *YUV) Opaque() bool

func (*YUV) SubImage

func (p *YUV) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

func (*YUV) YOffset

func (p *YUV) YOffset(x, y int) int

YOffset returns the index of the first element of Y that corresponds to the pixel at (x, y).

func (*YUV) YUVAt

func (p *YUV) YUVAt(x, y int) color.YCbCr

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL