gmf

package module
Version: v0.0.0-...-e278e6e Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: MIT Imports: 12 Imported by: 27

README

Go FFmpeg Bindings

Installation

Prerequisites

Current master branch supports all major Go versions, starting from 1.6.

Build/install FFmpeg

build lastest version of ffmpeg, obtained from https://github.com/FFmpeg/FFmpeg
There is one required option, which is disabled by default, you should turn on: --enable-shared

E.g.:

./configure --prefix=/usr/local/ffmpeg --enable-shared
make
make install

Add pkgconfig path:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/ffmpeg/lib/pkgconfig/

Ensure, that PKG_CONFIG_PATH contains path to ffmpeg's pkgconfig folder.

# check it by running
pkg-config --libs libavformat

It should print valid path to the avformat library.

Now, just run

go get github.com/3d0c/gmf
Other methods

This package uses pkg-config way to obtain flags, includes and libraries path, so if you have ffmpeg installed, just ensure, that your installation has them (pkgconfig/ folder with proper pc files).

Docker containers

Thanks to @ergoz you can try a docker container riftbit/ffalpine

Thanks to @denismakogon there is one more project, worth to mention https://github.com/denismakogon/ffmpeg-debian

Usage

Please see examples.

Support and Contribution

If something doesn't work, just fix it. Do not hesitate to pull request.

Credits

I borrowed the name from project, abandoned on code.google.com/p/gmf. Original code is available here in intitial commit from 03 Apr 2013.

Documentation

Overview

Format.

Example
package main

import (
	"errors"
	"fmt"
	"log"

	"github.com/3d0c/gmf"
)

func main() {
	outputfilename := "examples/sample-encoding1.mpg"
	dstWidth, dstHeight := 640, 480

	codec, err := gmf.FindEncoder(gmf.AV_CODEC_ID_MPEG1VIDEO)
	if err != nil {
		log.Fatal(err)
	}

	videoEncCtx := gmf.NewCodecCtx(codec)
	if videoEncCtx == nil {
		log.Fatal(errors.New("failed to create a new codec context"))
	}
	defer videoEncCtx.Free()

	outputCtx, err := gmf.NewOutputCtx(outputfilename)
	if err != nil {
		log.Fatal(errors.New("failed to create a new output context"))
	}
	defer outputCtx.Free()

	videoEncCtx.
		SetBitRate(400000).
		SetWidth(dstWidth).
		SetHeight(dstHeight).
		SetTimeBase(gmf.AVR{Num: 1, Den: 25}).
		SetPixFmt(gmf.AV_PIX_FMT_YUV420P).
		SetProfile(gmf.FF_PROFILE_MPEG4_SIMPLE).
		SetMbDecision(gmf.FF_MB_DECISION_RD)

	if outputCtx.IsGlobalHeader() {
		videoEncCtx.SetFlag(gmf.CODEC_FLAG_GLOBAL_HEADER)
	}

	videoStream := outputCtx.NewStream(codec)
	if videoStream == nil {
		log.Fatal(errors.New(fmt.Sprintf("Unable to create stream for videoEnc [%s]\n", codec.LongName())))
	}
	defer videoStream.Free()

	if err = videoEncCtx.Open(nil); err != nil {
		log.Fatal(err)
	}
	videoStream.DumpContexCodec(videoEncCtx)
	// videoStream.SetCodecCtx(videoEncCtx)

	outputCtx.SetStartTime(0)

	if err = outputCtx.WriteHeader(); err != nil {
		log.Fatal(err)
	}
	outputCtx.Dump()
	i := int64(0)
	n := 0

	for frame := range gmf.GenSyntVideoNewFrame(videoEncCtx.Width(), videoEncCtx.Height(), videoEncCtx.PixFmt()) {
		frame.SetPts(i)

		if p, err := frame.Encode(videoEncCtx); p != nil {
			if p.Pts() != gmf.AV_NOPTS_VALUE {
				p.SetPts(gmf.RescaleQ(p.Pts(), videoEncCtx.TimeBase(), videoStream.TimeBase()))
			}

			if p.Dts() != gmf.AV_NOPTS_VALUE {
				p.SetDts(gmf.RescaleQ(p.Dts(), videoEncCtx.TimeBase(), videoStream.TimeBase()))
			}

			if err := outputCtx.WritePacket(p); err != nil {
				log.Fatal(err)
			}

			n++

			log.Printf("Write frame=%d size=%v pts=%v dts=%v\n", frame.Pts(), p.Size(), p.Pts(), p.Dts())

			p.Free()
		} else if err != nil {
			log.Fatal(err)
		}

		frame.Free()
		i++
	}
	fmt.Println("frames written to examples/sample-encoding1.mpg")
}
Output:

frames written to examples/sample-encoding1.mpg

Index

Examples

Constants

View Source
const (
	AVIO_FLAG_READ       = 1
	AVIO_FLAG_WRITE      = 2
	AVIO_FLAG_READ_WRITE = (AVIO_FLAG_READ | AVIO_FLAG_WRITE)
)
View Source
const (
	AVCOL_RANGE_UNSPECIFIED = iota
	AVCOL_RANGE_MPEG        ///< the normal 219*2^(n-8) "MPEG" YUV ranges
	AVCOL_RANGE_JPEG        ///< the normal     2^n-1   "JPEG" YUV ranges
	AVCOL_RANGE_NB          ///< Not part of ABI
)
View Source
const (
	AV_BUFFERSINK_FLAG_PEEK       = 1
	AV_BUFFERSINK_FLAG_NO_REQUEST = 2
	AV_BUFFERSRC_FLAG_PUSH        = 4
)
View Source
const (
	AV_LOG_QUIET   int = C.AV_LOG_QUIET
	AV_LOG_PANIC   int = C.AV_LOG_PANIC
	AV_LOG_FATAL   int = C.AV_LOG_FATAL
	AV_LOG_ERROR   int = C.AV_LOG_ERROR
	AV_LOG_WARNING int = C.AV_LOG_WARNING
	AV_LOG_INFO    int = C.AV_LOG_INFO
	AV_LOG_VERBOSE int = C.AV_LOG_VERBOSE
	AV_LOG_DEBUG   int = C.AV_LOG_DEBUG

	FF_MOV_FLAG_FASTSTART = (1 << 7)

	AVFMT_FLAG_GENPTS int = C.AVFMT_FLAG_GENPTS
	AVFMTCTX_NOHEADER int = C.AVFMTCTX_NOHEADER
)
View Source
const (
	PLAYLIST_TYPE_NONE int = iota
	PLAYLIST_TYPE_EVENT
	PLAYLIST_TYPE_VOD
	PLAYLIST_TYPE_NB
)
View Source
const (
	AV_PICTURE_TYPE_NONE = iota // Undefined
	AV_PICTURE_TYPE_I           // Intra
	AV_PICTURE_TYPE_P           // Predicted
	AV_PICTURE_TYPE_B           // Bi-dir predicted
	AV_PICTURE_TYPE_S           // S(GMC)-VOP MPEG-4
	AV_PICTURE_TYPE_SI          // Switching Intra
	AV_PICTURE_TYPE_SP          // Switching Predicted
	AV_PICTURE_TYPE_BI          // BI type
)
View Source
const (
	AVERROR_EOF = -541478725
)
View Source
const (
	AV_PKT_FLAG_KEY = C.AV_PKT_FLAG_KEY // The packet contains a keyframe
)

Variables

View Source
var (
	AVMEDIA_TYPE_AUDIO int32 = C.AVMEDIA_TYPE_AUDIO
	AVMEDIA_TYPE_VIDEO int32 = C.AVMEDIA_TYPE_VIDEO

	AV_PIX_FMT_BGR24    int32 = C.AV_PIX_FMT_BGR24
	AV_PIX_FMT_BGR32    int32 = C.AV_PIX_FMT_BGR32
	AV_PIX_FMT_GRAY8    int32 = C.AV_PIX_FMT_GRAY8
	AV_PIX_FMT_RGB24    int32 = C.AV_PIX_FMT_RGB24
	AV_PIX_FMT_RGB32    int32 = C.AV_PIX_FMT_RGB32
	AV_PIX_FMT_RGBA     int32 = C.AV_PIX_FMT_RGBA
	AV_PIX_FMT_BGRA     int32 = C.AV_PIX_FMT_BGRA
	AV_PIX_FMT_YUV410P  int32 = C.AV_PIX_FMT_YUV410P
	AV_PIX_FMT_YUV411P  int32 = C.AV_PIX_FMT_YUV411P
	AV_PIX_FMT_YUV420P  int32 = C.AV_PIX_FMT_YUV420P
	AV_PIX_FMT_YUV422P  int32 = C.AV_PIX_FMT_YUV422P
	AV_PIX_FMT_YUV444P  int32 = C.AV_PIX_FMT_YUV444P
	AV_PIX_FMT_YUVJ420P int32 = C.AV_PIX_FMT_YUVJ420P
	AV_PIX_FMT_YUVJ444P int32 = C.AV_PIX_FMT_YUVJ444P
	AV_PIX_FMT_YUVJ422P int32 = C.AV_PIX_FMT_YUVJ422P
	AV_PIX_FMT_YUYV422  int32 = C.AV_PIX_FMT_YUYV422
	AV_PIX_FMT_NONE     int32 = C.AV_PIX_FMT_NONE

	FF_PROFILE_AAC_MAIN      int = C.FF_PROFILE_AAC_MAIN
	FF_PROFILE_AAC_LOW       int = C.FF_PROFILE_AAC_LOW
	FF_PROFILE_AAC_SSR       int = C.FF_PROFILE_AAC_SSR
	FF_PROFILE_AAC_LTP       int = C.FF_PROFILE_AAC_LTP
	FF_PROFILE_AAC_HE        int = C.FF_PROFILE_AAC_HE
	FF_PROFILE_AAC_HE_V2     int = C.FF_PROFILE_AAC_HE_V2
	FF_PROFILE_AAC_LD        int = C.FF_PROFILE_AAC_LD
	FF_PROFILE_AAC_ELD       int = C.FF_PROFILE_AAC_ELD
	FF_PROFILE_MPEG2_AAC_LOW int = C.FF_PROFILE_MPEG2_AAC_LOW
	FF_PROFILE_MPEG2_AAC_HE  int = C.FF_PROFILE_MPEG2_AAC_HE

	FF_PROFILE_DTS         int = C.FF_PROFILE_DTS
	FF_PROFILE_DTS_ES      int = C.FF_PROFILE_DTS_ES
	FF_PROFILE_DTS_96_24   int = C.FF_PROFILE_DTS_96_24
	FF_PROFILE_DTS_HD_HRA  int = C.FF_PROFILE_DTS_HD_HRA
	FF_PROFILE_DTS_HD_MA   int = C.FF_PROFILE_DTS_HD_MA
	FF_PROFILE_DTS_EXPRESS int = C.FF_PROFILE_DTS_EXPRESS

	FF_PROFILE_MPEG2_422          int = C.FF_PROFILE_MPEG2_422
	FF_PROFILE_MPEG2_HIGH         int = C.FF_PROFILE_MPEG2_HIGH
	FF_PROFILE_MPEG2_SS           int = C.FF_PROFILE_MPEG2_SS
	FF_PROFILE_MPEG2_SNR_SCALABLE int = C.FF_PROFILE_MPEG2_SNR_SCALABLE
	FF_PROFILE_MPEG2_MAIN         int = C.FF_PROFILE_MPEG2_MAIN
	FF_PROFILE_MPEG2_SIMPLE       int = C.FF_PROFILE_MPEG2_SIMPLE

	FF_PROFILE_H264_BASELINE            int = C.FF_PROFILE_H264_BASELINE
	FF_PROFILE_H264_MAIN                int = C.FF_PROFILE_H264_MAIN
	FF_PROFILE_H264_EXTENDED            int = C.FF_PROFILE_H264_EXTENDED
	FF_PROFILE_H264_HIGH                int = C.FF_PROFILE_H264_HIGH
	FF_PROFILE_H264_HIGH_10             int = C.FF_PROFILE_H264_HIGH_10
	FF_PROFILE_H264_HIGH_422            int = C.FF_PROFILE_H264_HIGH_422
	FF_PROFILE_H264_HIGH_444            int = C.FF_PROFILE_H264_HIGH_444
	FF_PROFILE_H264_HIGH_444_PREDICTIVE int = C.FF_PROFILE_H264_HIGH_444_PREDICTIVE
	FF_PROFILE_H264_CAVLC_444           int = C.FF_PROFILE_H264_CAVLC_444

	FF_PROFILE_VC1_SIMPLE   int = C.FF_PROFILE_VC1_SIMPLE
	FF_PROFILE_VC1_MAIN     int = C.FF_PROFILE_VC1_MAIN
	FF_PROFILE_VC1_COMPLEX  int = C.FF_PROFILE_VC1_COMPLEX
	FF_PROFILE_VC1_ADVANCED int = C.FF_PROFILE_VC1_ADVANCED

	FF_PROFILE_MPEG4_SIMPLE                    int = C.FF_PROFILE_MPEG4_SIMPLE
	FF_PROFILE_MPEG4_SIMPLE_SCALABLE           int = C.FF_PROFILE_MPEG4_SIMPLE_SCALABLE
	FF_PROFILE_MPEG4_CORE                      int = C.FF_PROFILE_MPEG4_CORE
	FF_PROFILE_MPEG4_MAIN                      int = C.FF_PROFILE_MPEG4_MAIN
	FF_PROFILE_MPEG4_N_BIT                     int = C.FF_PROFILE_MPEG4_N_BIT
	FF_PROFILE_MPEG4_SCALABLE_TEXTURE          int = C.FF_PROFILE_MPEG4_SCALABLE_TEXTURE
	FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION     int = C.FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION
	FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE    int = C.FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE
	FF_PROFILE_MPEG4_HYBRID                    int = C.FF_PROFILE_MPEG4_HYBRID
	FF_PROFILE_MPEG4_ADVANCED_REAL_TIME        int = C.FF_PROFILE_MPEG4_ADVANCED_REAL_TIME
	FF_PROFILE_MPEG4_CORE_SCALABLE             int = C.FF_PROFILE_MPEG4_CORE_SCALABLE
	FF_PROFILE_MPEG4_ADVANCED_CODING           int = C.FF_PROFILE_MPEG4_ADVANCED_CODING
	FF_PROFILE_MPEG4_ADVANCED_CORE             int = C.FF_PROFILE_MPEG4_ADVANCED_CORE
	FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE int = C.FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE
	FF_PROFILE_MPEG4_SIMPLE_STUDIO             int = C.FF_PROFILE_MPEG4_SIMPLE_STUDIO
	FF_PROFILE_MPEG4_ADVANCED_SIMPLE           int = C.FF_PROFILE_MPEG4_ADVANCED_SIMPLE

	AV_NOPTS_VALUE int64 = C.INT64_MAX

	FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0  int = C.FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0
	FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1  int = C.FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1
	FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION int = C.FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION
	FF_PROFILE_JPEG2000_DCINEMA_2K             int = C.FF_PROFILE_JPEG2000_DCINEMA_2K
	FF_PROFILE_JPEG2000_DCINEMA_4K             int = C.FF_PROFILE_JPEG2000_DCINEMA_4K

	FF_PROFILE_VP9_0 int = C.FF_PROFILE_VP9_0
	FF_PROFILE_VP9_1 int = C.FF_PROFILE_VP9_1
	FF_PROFILE_VP9_2 int = C.FF_PROFILE_VP9_2
	FF_PROFILE_VP9_3 int = C.FF_PROFILE_VP9_3

	FF_PROFILE_HEVC_MAIN               int = C.FF_PROFILE_HEVC_MAIN
	FF_PROFILE_HEVC_MAIN_10            int = C.FF_PROFILE_HEVC_MAIN_10
	FF_PROFILE_HEVC_MAIN_STILL_PICTURE int = C.FF_PROFILE_HEVC_MAIN_STILL_PICTURE
	FF_PROFILE_HEVC_REXT               int = C.FF_PROFILE_HEVC_REXT
)
View Source
var (
	AV_CODEC_ID_MPEG1VIDEO int = C.AV_CODEC_ID_MPEG1VIDEO
	AV_CODEC_ID_MPEG2VIDEO int = C.AV_CODEC_ID_MPEG2VIDEO
	AV_CODEC_ID_H264       int = C.AV_CODEC_ID_H264
	AV_CODEC_ID_H265       int = C.AV_CODEC_ID_H265
	AV_CODEC_ID_MPEG4      int = C.AV_CODEC_ID_MPEG4
	AV_CODEC_ID_JPEG2000   int = C.AV_CODEC_ID_JPEG2000
	AV_CODEC_ID_MJPEG      int = C.AV_CODEC_ID_MJPEG
	AV_CODEC_ID_MSMPEG4V1  int = C.AV_CODEC_ID_MSMPEG4V1
	AV_CODEC_ID_MSMPEG4V2  int = C.AV_CODEC_ID_MSMPEG4V2
	AV_CODEC_ID_MSMPEG4V3  int = C.AV_CODEC_ID_MSMPEG4V3
	AV_CODEC_ID_WMV1       int = C.AV_CODEC_ID_WMV1
	AV_CODEC_ID_WMV2       int = C.AV_CODEC_ID_WMV2
	AV_CODEC_ID_FLV1       int = C.AV_CODEC_ID_FLV1
	AV_CODEC_ID_PNG        int = C.AV_CODEC_ID_PNG
	AV_CODEC_ID_TIFF       int = C.AV_CODEC_ID_TIFF
	AV_CODEC_ID_GIF        int = C.AV_CODEC_ID_GIF
	AV_CODEC_ID_RAWVIDEO   int = C.AV_CODEC_ID_RAWVIDEO

	AV_CODEC_ID_AAC int = C.AV_CODEC_ID_AAC

	CODEC_FLAG_GLOBAL_HEADER int   = C.AV_CODEC_FLAG_GLOBAL_HEADER
	AV_CODEC_FLAG_QSCALE     int32 = C.AV_CODEC_FLAG_QSCALE

	FF_MB_DECISION_SIMPLE int = C.FF_MB_DECISION_SIMPLE
	FF_MB_DECISION_BITS   int = C.FF_MB_DECISION_BITS
	FF_MB_DECISION_RD     int = C.FF_MB_DECISION_RD

	FF_QP2LAMBDA int = C.FF_QP2LAMBDA

	AV_SAMPLE_FMT_U8  int32 = C.AV_SAMPLE_FMT_U8
	AV_SAMPLE_FMT_S16 int32 = C.AV_SAMPLE_FMT_S16
	AV_SAMPLE_FMT_S32 int32 = C.AV_SAMPLE_FMT_S32
	AV_SAMPLE_FMT_FLT int32 = C.AV_SAMPLE_FMT_FLT
	AV_SAMPLE_FMT_DBL int32 = C.AV_SAMPLE_FMT_DBL

	AV_SAMPLE_FMT_U8P  int32 = C.AV_SAMPLE_FMT_U8P
	AV_SAMPLE_FMT_S16P int32 = C.AV_SAMPLE_FMT_S16P
	AV_SAMPLE_FMT_S32P int32 = C.AV_SAMPLE_FMT_S32P
	AV_SAMPLE_FMT_FLTP int32 = C.AV_SAMPLE_FMT_FLTP
	AV_SAMPLE_FMT_DBLP int32 = C.AV_SAMPLE_FMT_DBLP
)
View Source
var (
	FF_COMPLIANCE_VERY_STRICT  int = C.FF_COMPLIANCE_VERY_STRICT
	FF_COMPLIANCE_STRICT       int = C.FF_COMPLIANCE_STRICT
	FF_COMPLIANCE_NORMAL       int = C.FF_COMPLIANCE_NORMAL
	FF_COMPLIANCE_UNOFFICIAL   int = C.FF_COMPLIANCE_UNOFFICIAL
	FF_COMPLIANCE_EXPERIMENTAL int = C.FF_COMPLIANCE_EXPERIMENTAL
)
View Source
var (
	SWS_FAST_BILINEAR int = C.SWS_FAST_BILINEAR
	SWS_BILINEAR      int = C.SWS_BILINEAR
	SWS_BICUBIC       int = C.SWS_BICUBIC
	SWS_X             int = C.SWS_X
	SWS_POINT         int = C.SWS_POINT
	SWS_AREA          int = C.SWS_AREA
	SWS_BICUBLIN      int = C.SWS_BICUBLIN
	SWS_GAUSS         int = C.SWS_GAUSS
	SWS_SINC          int = C.SWS_SINC
	SWS_LANCZOS       int = C.SWS_LANCZOS
	SWS_SPLINE        int = C.SWS_SPLINE
)
View Source
var (
	AV_TIME_BASE   int        = C.AV_TIME_BASE
	AV_TIME_BASE_Q AVRational = AVRational{1, C.int(AV_TIME_BASE)}
)
View Source
var (
	IO_BUFFER_SIZE int = 32768
)

Functions

func AvErrno

func AvErrno(ret int) syscall.Errno

func AvError

func AvError(averr int) error

func CompareTimeStamp

func CompareTimeStamp(aTimestamp int, aTimebase AVRational, bTimestamp int, bTimebase AVRational) int

func GenSyntVideoN

func GenSyntVideoN(N, w, h int, fmt int32) chan *Frame

tmp

func GenSyntVideoNewFrame

func GenSyntVideoNewFrame(w, h int, fmt int32) chan *Frame

Synthetic video generator. It produces 25 iteratable frames. Used for tests.

func GetSampleFmtName

func GetSampleFmtName(fmt int32) string

func InitDesc

func InitDesc()

func LogSetLevel

func LogSetLevel(level int)

func NewSample

func NewSample(nbSamples, nbChannels int, format SampleFormat) error

func Release

func Release(i CgoMemoryManager)

func Rescale

func Rescale(a, b, c int64) int64

func RescaleDelta

func RescaleDelta(inTb AVRational, inTs int64, fsTb AVRational, duration int, last *int64, outTb AVRational) int64

func RescaleQ

func RescaleQ(a int64, encBase AVRational, stBase AVRational) int64

func RescaleQRnd

func RescaleQRnd(a int64, encBase AVRational, stBase AVRational) int64

func RescaleTs

func RescaleTs(pkt *Packet, encBase AVRational, stBase AVRational)

Types

type AVAudioFifo

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

func NewAVAudioFifo

func NewAVAudioFifo(sampleFormat int32, channels int, nb_samples int) *AVAudioFifo

func (*AVAudioFifo) Free

func (this *AVAudioFifo) Free()

func (*AVAudioFifo) Read

func (this *AVAudioFifo) Read(sampleCount int) *Frame

func (*AVAudioFifo) SamplesCanWrite

func (this *AVAudioFifo) SamplesCanWrite() int

func (*AVAudioFifo) SamplesToRead

func (this *AVAudioFifo) SamplesToRead() int

func (*AVAudioFifo) Write

func (this *AVAudioFifo) Write(frame *Frame) int

type AVIOContext

type AVIOContext struct {
	CgoMemoryManage
	// contains filtered or unexported fields
}

func NewAVIOContext

func NewAVIOContext(ctx *FmtCtx, handlers *AVIOHandlers, size ...int) (*AVIOContext, error)

AVIOContext constructor. Use it only if You need custom IO behaviour!

Example
package main

import (
	"fmt"
	"io"
	"log"
	"os"

	"github.com/3d0c/gmf"
)

var inputSampleFilename string = "examples/tests-sample.mp4"

var section *io.SectionReader

func customReader() ([]byte, int) {
	var file *os.File
	var err error

	if section == nil {
		file, err = os.Open(inputSampleFilename)
		if err != nil {
			panic(err)
		}

		fi, err := file.Stat()
		if err != nil {
			panic(err)
		}

		section = io.NewSectionReader(file, 0, fi.Size())
	}

	b := make([]byte, gmf.IO_BUFFER_SIZE)

	n, err := section.Read(b)
	if err != nil {
		fmt.Println("section.Read():", err)
		file.Close()
	}

	return b, n
}

func main() {
	ctx := gmf.NewCtx()
	defer ctx.Free()

	// In this example, we're using custom reader implementation,
	// so we should specify format manually.
	if err := ctx.SetInputFormat("mov"); err != nil {
		log.Fatal(err)
	}

	avioCtx, err := gmf.NewAVIOContext(ctx, &gmf.AVIOHandlers{ReadPacket: customReader})
	defer avioCtx.Free()
	if err != nil {
		log.Fatal(err)
	}

	// Setting up AVFormatContext.pb
	ctx.SetPb(avioCtx)

	// Calling OpenInput with empty arg, because all files stuff we're doing in custom reader.
	// But the library have to initialize some stuff, so we call it anyway.
	ctx.OpenInput("")

	for p := range ctx.GetNewPackets() {
		_ = p
		p.Free()
	}
}
Output:

func (*AVIOContext) Flush

func (c *AVIOContext) Flush()

func (*AVIOContext) Free

func (c *AVIOContext) Free()

type AVIOHandlers

type AVIOHandlers struct {
	ReadPacket  func() ([]byte, int)
	WritePacket func([]byte) int
	Seek        func(int64, int) int64
}

Functions prototypes for custom IO. Implement necessary prototypes and pass instance pointer to NewAVIOContext.

E.g.:

func gridFsReader() ([]byte, int) {
	... implementation ...
	return data, length
}

avoictx := NewAVIOContext(ctx, &AVIOHandlers{ReadPacket: gridFsReader})

type AVR

type AVR struct {
	Num int
	Den int
}

func (AVR) AVRational

func (a AVR) AVRational() AVRational

func (AVR) Av2qd

func (a AVR) Av2qd() float64

func (AVR) Invert

func (a AVR) Invert() AVR

func (AVR) String

func (a AVR) String() string

type AVRational

type AVRational C.struct_AVRational

func AvInvQ

func AvInvQ(q AVRational) AVRational

func (AVRational) AVR

func (a AVRational) AVR() AVR

type CgoMemoryManage

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

func (*CgoMemoryManage) Free

func (c *CgoMemoryManage) Free()

func (*CgoMemoryManage) Release

func (c *CgoMemoryManage) Release()

func (*CgoMemoryManage) Retain

func (c *CgoMemoryManage) Retain()

func (*CgoMemoryManage) RetainCount

func (c *CgoMemoryManage) RetainCount() int32

type CgoMemoryManager

type CgoMemoryManager interface {
	Retain()
	RetainCount() int32
	Release()
	Free()
}

type Codec

type Codec struct {
	CgoMemoryManage
	// contains filtered or unexported fields
}

func FindDecoder

func FindDecoder(i interface{}) (*Codec, error)

func FindEncoder

func FindEncoder(i interface{}) (*Codec, error)

func (*Codec) Free

func (this *Codec) Free()

func (*Codec) Id

func (this *Codec) Id() int

func (*Codec) IsDecoder

func (this *Codec) IsDecoder() bool

func (*Codec) IsExperimental

func (this *Codec) IsExperimental() bool

func (*Codec) LongName

func (this *Codec) LongName() string

func (*Codec) Name

func (this *Codec) Name() string

func (*Codec) Type

func (this *Codec) Type() int

type CodecCtx

type CodecCtx struct {
	CgoMemoryManage
	// contains filtered or unexported fields
}

func NewCodecCtx

func NewCodecCtx(codec *Codec, options ...[]*Option) *CodecCtx

func (*CodecCtx) BitRate

func (cc *CodecCtx) BitRate() int

func (*CodecCtx) ChannelLayout

func (cc *CodecCtx) ChannelLayout() int

func (*CodecCtx) Channels

func (cc *CodecCtx) Channels() int

func (*CodecCtx) Close

func (cc *CodecCtx) Close()

func (*CodecCtx) CloseAndRelease

func (cc *CodecCtx) CloseAndRelease()

func (*CodecCtx) Codec

func (cc *CodecCtx) Codec() *Codec

func (*CodecCtx) CopyExtra

func (cc *CodecCtx) CopyExtra(ist *Stream) *CodecCtx

func (*CodecCtx) Decode

func (cc *CodecCtx) Decode(pkt *Packet) ([]*Frame, error)

func (*CodecCtx) Decode2

func (cc *CodecCtx) Decode2(pkt *Packet) (*Frame, int)

func (*CodecCtx) Dump

func (cc *CodecCtx) Dump()

func (*CodecCtx) Encode

func (cc *CodecCtx) Encode(frames []*Frame, drain int) ([]*Packet, error)

func (*CodecCtx) FlushBuffers

func (cc *CodecCtx) FlushBuffers()

func (*CodecCtx) FrameSize

func (cc *CodecCtx) FrameSize() int

func (*CodecCtx) Free

func (cc *CodecCtx) Free()

codec context is freed by avformat_free_context()

func (*CodecCtx) GetAspectRation

func (cc *CodecCtx) GetAspectRation() AVRational

func (*CodecCtx) GetBFrames

func (cc *CodecCtx) GetBFrames() int

func (*CodecCtx) GetBitsPerSample

func (cc *CodecCtx) GetBitsPerSample() int

func (*CodecCtx) GetChannelLayoutName

func (cc *CodecCtx) GetChannelLayoutName() string

func (*CodecCtx) GetCodecTag

func (cc *CodecCtx) GetCodecTag() uint32

func (*CodecCtx) GetCodecTagName

func (cc *CodecCtx) GetCodecTagName() string

func (*CodecCtx) GetCodedHeight

func (cc *CodecCtx) GetCodedHeight() int

func (*CodecCtx) GetCodedWith

func (cc *CodecCtx) GetCodedWith() int

func (*CodecCtx) GetColorRangeName

func (cc *CodecCtx) GetColorRangeName() string

func (*CodecCtx) GetDefaultChannelLayout

func (cc *CodecCtx) GetDefaultChannelLayout(ac int) int

func (*CodecCtx) GetFrameRate

func (cc *CodecCtx) GetFrameRate() AVRational

func (*CodecCtx) GetGopSize

func (cc *CodecCtx) GetGopSize() int

func (*CodecCtx) GetMediaType

func (cc *CodecCtx) GetMediaType() string

func (*CodecCtx) GetPixFmtName

func (cc *CodecCtx) GetPixFmtName() string

func (*CodecCtx) GetProfile

func (cc *CodecCtx) GetProfile() int

func (*CodecCtx) GetProfileName

func (cc *CodecCtx) GetProfileName() string

func (*CodecCtx) GetRefs

func (cc *CodecCtx) GetRefs() int

func (*CodecCtx) GetSampleFmtName

func (cc *CodecCtx) GetSampleFmtName() string

func (*CodecCtx) GetVideoSize

func (cc *CodecCtx) GetVideoSize() string

func (*CodecCtx) Height

func (cc *CodecCtx) Height() int

func (*CodecCtx) Id

func (cc *CodecCtx) Id() int

func (*CodecCtx) IsOpen

func (cc *CodecCtx) IsOpen() bool

func (*CodecCtx) Open

func (cc *CodecCtx) Open(dict *Dict) error

func (*CodecCtx) PixFmt

func (cc *CodecCtx) PixFmt() int32

func (*CodecCtx) Profile

func (cc *CodecCtx) Profile() int

func (*CodecCtx) SampleFmt

func (cc *CodecCtx) SampleFmt() int32

func (*CodecCtx) SampleRate

func (cc *CodecCtx) SampleRate() int

func (*CodecCtx) SelectChannelLayout

func (cc *CodecCtx) SelectChannelLayout() int

func (*CodecCtx) SelectSampleFmt

func (cc *CodecCtx) SelectSampleFmt() int32

func (*CodecCtx) SelectSampleRate

func (cc *CodecCtx) SelectSampleRate() int

func (*CodecCtx) SetBitRate

func (cc *CodecCtx) SetBitRate(val int) *CodecCtx

func (*CodecCtx) SetBitsPerRawSample

func (cc *CodecCtx) SetBitsPerRawSample(val int) *CodecCtx

func (*CodecCtx) SetChannelLayout

func (cc *CodecCtx) SetChannelLayout(channelLayout int)

func (*CodecCtx) SetChannels

func (cc *CodecCtx) SetChannels(val int) *CodecCtx

func (*CodecCtx) SetDimension

func (cc *CodecCtx) SetDimension(w, h int) *CodecCtx

func (*CodecCtx) SetExtradata

func (cc *CodecCtx) SetExtradata(extradata []byte) *CodecCtx

SetExtradata TODO: Improving performance

Free or avcodec_free_context can free extradata

func (*CodecCtx) SetFlag

func (cc *CodecCtx) SetFlag(flag int) *CodecCtx

func (*CodecCtx) SetFrameRate

func (cc *CodecCtx) SetFrameRate(r AVR) *CodecCtx

func (*CodecCtx) SetGlobalQuality

func (cc *CodecCtx) SetGlobalQuality(val int)

func (*CodecCtx) SetGopSize

func (cc *CodecCtx) SetGopSize(val int) *CodecCtx

func (*CodecCtx) SetHasBframes

func (cc *CodecCtx) SetHasBframes(val int) *CodecCtx

func (*CodecCtx) SetHeight

func (cc *CodecCtx) SetHeight(val int) *CodecCtx

func (*CodecCtx) SetMaxBFrames

func (cc *CodecCtx) SetMaxBFrames(val int) *CodecCtx

func (*CodecCtx) SetMbDecision

func (cc *CodecCtx) SetMbDecision(val int) *CodecCtx

func (*CodecCtx) SetOpt

func (cc *CodecCtx) SetOpt()

@todo

func (*CodecCtx) SetOptions

func (cc *CodecCtx) SetOptions(options []Option)

func (*CodecCtx) SetPixFmt

func (cc *CodecCtx) SetPixFmt(val int32) *CodecCtx

func (*CodecCtx) SetPktTimeBase

func (cc *CodecCtx) SetPktTimeBase(val AVR)

func (*CodecCtx) SetProfile

func (cc *CodecCtx) SetProfile(profile int) *CodecCtx

func (*CodecCtx) SetSampleFmt

func (cc *CodecCtx) SetSampleFmt(val int32) *CodecCtx

func (*CodecCtx) SetSampleRate

func (cc *CodecCtx) SetSampleRate(val int) *CodecCtx

func (*CodecCtx) SetStrictCompliance

func (cc *CodecCtx) SetStrictCompliance(val int) *CodecCtx

func (*CodecCtx) SetThreadCount

func (cc *CodecCtx) SetThreadCount(val int)

func (*CodecCtx) SetTimeBase

func (cc *CodecCtx) SetTimeBase(val AVR) *CodecCtx

func (*CodecCtx) SetWidth

func (cc *CodecCtx) SetWidth(val int) *CodecCtx

func (*CodecCtx) SupportedSampleRate

func (cc *CodecCtx) SupportedSampleRate(val int) bool

func (*CodecCtx) TimeBase

func (cc *CodecCtx) TimeBase() AVRational

func (*CodecCtx) Type

func (cc *CodecCtx) Type() int32

func (*CodecCtx) Width

func (cc *CodecCtx) Width() int

type CodecDescriptor

type CodecDescriptor struct {
	IsEncoder bool
	// contains filtered or unexported fields
}

func (*CodecDescriptor) Id

func (this *CodecDescriptor) Id() int

func (*CodecDescriptor) LongName

func (this *CodecDescriptor) LongName() string

func (*CodecDescriptor) Name

func (this *CodecDescriptor) Name() string

func (*CodecDescriptor) Props

func (this *CodecDescriptor) Props() int

func (*CodecDescriptor) Type

func (this *CodecDescriptor) Type() int

type CodecParameters

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

func NewCodecParameters

func NewCodecParameters() *CodecParameters

func (*CodecParameters) BitRate

func (cp *CodecParameters) BitRate() int64

func (*CodecParameters) CodecId

func (cp *CodecParameters) CodecId() int

func (*CodecParameters) CodecType

func (cp *CodecParameters) CodecType() int

func (*CodecParameters) Format

func (cp *CodecParameters) Format() int32

Format video: the pixel format, the value corresponds to enum AVPixelFormat. audio: the sample format, the value corresponds to enum AVSampleFormat.

func (*CodecParameters) Free

func (cp *CodecParameters) Free()

func (*CodecParameters) FromContext

func (cp *CodecParameters) FromContext(cc *CodecCtx) error

func (*CodecParameters) Height

func (cp *CodecParameters) Height() int

func (*CodecParameters) ToContext

func (cp *CodecParameters) ToContext(cc *CodecCtx) error

func (*CodecParameters) Width

func (cp *CodecParameters) Width() int

type Dict

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

func NewDict

func NewDict(pairs []Pair) *Dict

type Filter

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

func NewFilter

func NewFilter(desc string, srcStreams []*Stream, ost *Stream, options []*Option) (*Filter, error)

func (*Filter) AddFrame

func (f *Filter) AddFrame(frame *Frame, istIdx int, flag int) error

func (*Filter) Close

func (f *Filter) Close(istIdx int) error

func (*Filter) Dump

func (f *Filter) Dump()

func (*Filter) GetFrame

func (f *Filter) GetFrame() ([]*Frame, error)

func (*Filter) Release

func (f *Filter) Release()

func (*Filter) RequestOldest

func (f *Filter) RequestOldest() error

type FmtCtx

type FmtCtx struct {
	Filename string
	// contains filtered or unexported fields
}

func NewCtx

func NewCtx(options ...[]Option) *FmtCtx

@todo start_time is it needed?

func NewInputCtx

func NewInputCtx(filename string) (*FmtCtx, error)

Just a helper for NewCtx().OpenInput()

func NewInputCtxWithFormatName

func NewInputCtxWithFormatName(filename, format string) (*FmtCtx, error)

func NewOutputCtx

func NewOutputCtx(i interface{}, options ...[]Option) (*FmtCtx, error)

func NewOutputCtxWithFormatName

func NewOutputCtxWithFormatName(filename, format string) (*FmtCtx, error)

func (*FmtCtx) AddStreamWithCodeCtx

func (ctx *FmtCtx) AddStreamWithCodeCtx(codeCtx *CodecCtx) (*Stream, error)

func (*FmtCtx) BitRate

func (ctx *FmtCtx) BitRate() int64

Total stream bitrate in bit/s

func (*FmtCtx) Close

func (ctx *FmtCtx) Close()

func (*FmtCtx) CloseInput

func (ctx *FmtCtx) CloseInput()

func (*FmtCtx) CloseOutput

func (ctx *FmtCtx) CloseOutput()

func (*FmtCtx) Dump

func (ctx *FmtCtx) Dump()

func (*FmtCtx) DumpAv

func (ctx *FmtCtx) DumpAv()

func (*FmtCtx) Duration

func (ctx *FmtCtx) Duration() float64

func (*FmtCtx) FindStreamInfo

func (ctx *FmtCtx) FindStreamInfo() error

func (*FmtCtx) Free

func (ctx *FmtCtx) Free()

func (*FmtCtx) GetBestStream

func (ctx *FmtCtx) GetBestStream(typ int32) (*Stream, error)

func (*FmtCtx) GetNewPackets

func (ctx *FmtCtx) GetNewPackets() chan *Packet

func (*FmtCtx) GetNextPacket

func (ctx *FmtCtx) GetNextPacket() (*Packet, error)

func (*FmtCtx) GetProbeSize

func (ctx *FmtCtx) GetProbeSize() int64

func (*FmtCtx) GetSDPString

func (ctx *FmtCtx) GetSDPString() (sdp string)

func (*FmtCtx) GetStream

func (ctx *FmtCtx) GetStream(idx int) (*Stream, error)

func (*FmtCtx) IsGlobalHeader

func (ctx *FmtCtx) IsGlobalHeader() bool

func (*FmtCtx) IsNoFile

func (ctx *FmtCtx) IsNoFile() bool

func (*FmtCtx) NewStream

func (ctx *FmtCtx) NewStream(c *Codec) *Stream

func (*FmtCtx) OpenInput

func (ctx *FmtCtx) OpenInput(filename string) error

func (*FmtCtx) OpenInputWithOption

func (ctx *FmtCtx) OpenInputWithOption(filename string, inputOptions *Option) error

func (*FmtCtx) Position

func (ctx *FmtCtx) Position() int

func (*FmtCtx) SeekFile

func (ctx *FmtCtx) SeekFile(ist *Stream, minTs, maxTs int64, flag int) error

func (*FmtCtx) SeekFrameAt

func (ctx *FmtCtx) SeekFrameAt(sec int64, streamIndex int) error

func (*FmtCtx) SetDebug

func (ctx *FmtCtx) SetDebug(val int) *FmtCtx

func (*FmtCtx) SetFlag

func (ctx *FmtCtx) SetFlag(flag int) *FmtCtx

func (*FmtCtx) SetInputFormat

func (ctx *FmtCtx) SetInputFormat(name string) error

func (*FmtCtx) SetOformat

func (ctx *FmtCtx) SetOformat(ofmt *OutputFmt) error

func (*FmtCtx) SetOptions

func (ctx *FmtCtx) SetOptions(options []*Option)

func (*FmtCtx) SetPb

func (ctx *FmtCtx) SetPb(val *AVIOContext) *FmtCtx

func (*FmtCtx) SetProbeSize

func (ctx *FmtCtx) SetProbeSize(v int64)

func (*FmtCtx) SetStartTime

func (ctx *FmtCtx) SetStartTime(val int) *FmtCtx

func (*FmtCtx) StartTime

func (ctx *FmtCtx) StartTime() int

func (*FmtCtx) StreamsCnt

func (ctx *FmtCtx) StreamsCnt() int

Original structure member is called instead of len(this.streams) because there is no initialized Stream wrappers in input context.

func (*FmtCtx) TsOffset

func (ctx *FmtCtx) TsOffset(stime int) int

func (*FmtCtx) WriteHeader

func (ctx *FmtCtx) WriteHeader() error

func (*FmtCtx) WritePacket

func (ctx *FmtCtx) WritePacket(p *Packet) error

func (*FmtCtx) WritePacketNoBuffer

func (ctx *FmtCtx) WritePacketNoBuffer(p *Packet) error

func (*FmtCtx) WriteSDPFile

func (ctx *FmtCtx) WriteSDPFile(filename string) error

func (*FmtCtx) WriteTrailer

func (ctx *FmtCtx) WriteTrailer()

type Frame

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

func DefaultResampler

func DefaultResampler(ost *Stream, frames []*Frame, flush bool) []*Frame

func DefaultRescaler

func DefaultRescaler(ctx *SwsCtx, frames []*Frame) ([]*Frame, error)

func NewAudioFrame

func NewAudioFrame(sampleFormat int32, channels, nb_samples int) (*Frame, error)

func NewFrame

func NewFrame() *Frame

func (*Frame) Channels

func (f *Frame) Channels() int

func (*Frame) CloneNewFrame

func (f *Frame) CloneNewFrame() *Frame

func (*Frame) Dump

func (f *Frame) Dump()

func (*Frame) Encode

func (f *Frame) Encode(enc *CodecCtx) (*Packet, error)

func (*Frame) Format

func (f *Frame) Format() int

AVPixelFormat for video frames, AVSampleFormat for audio

func (*Frame) Free

func (f *Frame) Free()

func (*Frame) GetChannelLayout

func (f *Frame) GetChannelLayout() int

func (*Frame) GetRawAudioData

func (f *Frame) GetRawAudioData(plane int) []byte

func (*Frame) GetRawFrame

func (f *Frame) GetRawFrame() *C.struct_AVFrame

func (*Frame) Height

func (f *Frame) Height() int

func (*Frame) ImgAlloc

func (f *Frame) ImgAlloc() error

func (*Frame) IsNil

func (f *Frame) IsNil() bool

func (*Frame) KeyFrame

func (f *Frame) KeyFrame() int

func (*Frame) LineSize

func (f *Frame) LineSize(idx int) int

func (*Frame) NbSamples

func (f *Frame) NbSamples() int

func (*Frame) PktDts

func (f *Frame) PktDts() int

func (*Frame) PktPos

func (f *Frame) PktPos() int64

func (*Frame) PktPts

func (f *Frame) PktPts() int64

func (*Frame) Pts

func (f *Frame) Pts() int64

func (*Frame) SetChannelLayout

func (f *Frame) SetChannelLayout(val int) *Frame

func (*Frame) SetChannels

func (f *Frame) SetChannels(val int) *Frame

func (*Frame) SetData

func (f *Frame) SetData(idx int, lineSize int, data int) *Frame

func (*Frame) SetFormat

func (f *Frame) SetFormat(val int32) *Frame

func (*Frame) SetHeight

func (f *Frame) SetHeight(val int) *Frame

func (*Frame) SetNbSamples

func (f *Frame) SetNbSamples(val int) *Frame

func (*Frame) SetPictType

func (f *Frame) SetPictType(val uint32)

func (*Frame) SetPktDts

func (f *Frame) SetPktDts(val int)

func (*Frame) SetPktPts

func (f *Frame) SetPktPts(val int64)

func (*Frame) SetPts

func (f *Frame) SetPts(val int64)

func (*Frame) SetQuality

func (f *Frame) SetQuality(val int) *Frame

func (*Frame) SetWidth

func (f *Frame) SetWidth(val int) *Frame

func (*Frame) Time

func (f *Frame) Time(timebase AVRational) int

func (*Frame) Unref

func (f *Frame) Unref()

func (*Frame) Width

func (f *Frame) Width() int

type Image

type Image struct {
	CgoMemoryManage
	// contains filtered or unexported fields
}

func NewImage

func NewImage(w, h int, pixFmt int32, align int) (*Image, error)

@todo find better way to do allocation

func (*Image) Copy

func (i *Image) Copy(frame *Frame)

func (*Image) Free

func (i *Image) Free()

func (*Image) Size

func (i *Image) Size() int

type Option

type Option struct {
	Key string
	Val interface{}
}

func (Option) Set

func (this Option) Set(ctx interface{})

type OutputFmt

type OutputFmt struct {
	Filename string

	CgoMemoryManage
	// contains filtered or unexported fields
}

func FindOutputFmt

func FindOutputFmt(format string, filename string, mime string) *OutputFmt

func (*OutputFmt) Free

func (f *OutputFmt) Free()

func (*OutputFmt) Infomation

func (f *OutputFmt) Infomation() string

func (*OutputFmt) LongName

func (f *OutputFmt) LongName() string

func (*OutputFmt) MimeType

func (f *OutputFmt) MimeType() string

func (*OutputFmt) Name

func (f *OutputFmt) Name() string

type Packet

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

func Init

func Init() *Packet

Init same to NewPacket and av_new_packet

Initialize optional fields of a packet with default values.
Note, this does not touch the data and size members, which have to be
initialized separately.

func NewPacket

func NewPacket() *Packet

func (*Packet) Clone

func (p *Packet) Clone() *Packet

func (*Packet) Data

func (p *Packet) Data() []byte

func (*Packet) Dts

func (p *Packet) Dts() int64

func (*Packet) Dump

func (p *Packet) Dump()

func (*Packet) Duration

func (p *Packet) Duration() int64

func (*Packet) Flags

func (p *Packet) Flags() int

func (*Packet) Free

func (p *Packet) Free()

func (*Packet) FreeData

func (p *Packet) FreeData() *Packet

FreeData free data when use SetData

p := gmf.NewPacket()
defer p.Free()
p.SetData([]byte{0x00, 0x00, 0x00, 0x01, 0x67})
defer p.FreeData()

func (*Packet) Pos

func (p *Packet) Pos() int64

func (*Packet) Pts

func (p *Packet) Pts() int64

func (*Packet) SetData

func (p *Packet) SetData(data []byte) *Packet

SetData [NOT SUGGESTED] should free data later

p := gmf.NewPacket()
defer p.Free()
p.SetData([]byte{0x00, 0x00, 0x00, 0x01, 0x67})
defer p.FreeData()
Example
package main

import (
	"github.com/3d0c/gmf"
)

func main() {
	p := gmf.NewPacket()
	defer p.Free()
	p.SetData([]byte{0x00, 0x00, 0x00, 0x01, 0x67})
	defer p.FreeData()
}
Output:

func (*Packet) SetDts

func (p *Packet) SetDts(val int64) *Packet

func (*Packet) SetDuration

func (p *Packet) SetDuration(duration int64) *Packet

func (*Packet) SetFlags

func (p *Packet) SetFlags(flags int) *Packet
Example
package main

import (
	"github.com/3d0c/gmf"
)

func main() {
	p := gmf.NewPacket()
	p.SetFlags(p.Flags() | gmf.AV_PKT_FLAG_KEY)
	defer p.Free()
}
Output:

func (*Packet) SetPts

func (p *Packet) SetPts(pts int64) *Packet

func (*Packet) SetStreamIndex

func (p *Packet) SetStreamIndex(val int) *Packet

func (*Packet) Size

func (p *Packet) Size() int

func (*Packet) StreamIndex

func (p *Packet) StreamIndex() int

func (*Packet) Time

func (p *Packet) Time(timebase AVRational) int

type Pair

type Pair struct {
	Key string
	Val string
}

type Sample

type Sample struct {
	CgoMemoryManage
	// contains filtered or unexported fields
}

func (*Sample) SampleRealloc

func (s *Sample) SampleRealloc(nbSamples, nbChannels int) error

type SampleFormat

type SampleFormat int

type Stream

type Stream struct {
	SwsCtx *SwsCtx
	SwrCtx *SwrCtx
	AvFifo *AVAudioFifo

	Pts int64
	CgoMemoryManage
	// contains filtered or unexported fields
}

func (*Stream) CodecCtx deprecated

This method has been deprecated.
func (s *Stream) CodecCtx() *CodecCtx

CodecCtx Deprecated: Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.

func (*Stream) CodecPar

func (s *Stream) CodecPar() *CodecParameters

func (*Stream) CopyCodecPar

func (s *Stream) CopyCodecPar(cp *CodecParameters) error

func (*Stream) DumpContexCodec

func (s *Stream) DumpContexCodec(codec *CodecCtx)

func (*Stream) Duration

func (s *Stream) Duration() int64

func (*Stream) Free

func (s *Stream) Free()

func (*Stream) GetAvgFrameRate

func (s *Stream) GetAvgFrameRate() AVRational

func (*Stream) GetCodecPar

func (s *Stream) GetCodecPar() *CodecParameters

func (*Stream) GetRFrameRate

func (s *Stream) GetRFrameRate() AVRational

func (*Stream) GetStartTime

func (s *Stream) GetStartTime() int64

func (*Stream) Id

func (s *Stream) Id() int

func (*Stream) Index

func (s *Stream) Index() int

func (*Stream) IsAudio

func (s *Stream) IsAudio() bool

func (*Stream) IsCodecCtxSet deprecated

This method has been deprecated.
func (s *Stream) IsCodecCtxSet() bool

IsCodecCtxSet Deprecated: Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.

func (*Stream) IsVideo

func (s *Stream) IsVideo() bool

func (*Stream) NbFrames

func (s *Stream) NbFrames() int

func (*Stream) SetAvgFrameRate

func (s *Stream) SetAvgFrameRate(val AVR)

func (*Stream) SetCodecCtx deprecated

This method has been deprecated.
func (s *Stream) SetCodecCtx(cc *CodecCtx)

SetCodecCtx Deprecated: Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.

func (*Stream) SetCodecFlags

func (s *Stream) SetCodecFlags()

func (*Stream) SetCodecPar

func (s *Stream) SetCodecPar(cp *CodecParameters) error

func (*Stream) SetRFrameRate

func (s *Stream) SetRFrameRate(val AVR)

func (*Stream) SetTimeBase

func (s *Stream) SetTimeBase(val AVR) *Stream

func (*Stream) TimeBase

func (s *Stream) TimeBase() AVRational

func (*Stream) Type

func (s *Stream) Type() int32

type SwrCtx

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

func NewSwrCtx

func NewSwrCtx(options []*Option, channels int, format int32) (*SwrCtx, error)

func (*SwrCtx) Convert

func (ctx *SwrCtx) Convert(input *Frame) (*Frame, error)

func (*SwrCtx) Flush

func (ctx *SwrCtx) Flush(nbSamples int) (*Frame, error)

func (*SwrCtx) Free

func (ctx *SwrCtx) Free()

type SwsCtx

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

func NewSwsCtx

func NewSwsCtx(srcW, srcH int, srcPixFmt int32, dstW, dstH int, dstPixFmt int32, method int) (*SwsCtx, error)

func (*SwsCtx) Free

func (ctx *SwsCtx) Free()

func (*SwsCtx) Scale

func (ctx *SwsCtx) Scale(src *Frame, dst *Frame)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL