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 ¶
- Constants
- Variables
- func AvErrno(ret int) syscall.Errno
- func AvError(averr int) error
- func CompareTimeStamp(aTimestamp int, aTimebase AVRational, bTimestamp int, bTimebase AVRational) int
- func GenSyntVideoN(N, w, h int, fmt int32) chan *Frame
- func GenSyntVideoNewFrame(w, h int, fmt int32) chan *Frame
- func GetSampleFmtName(fmt int32) string
- func InitDesc()
- func LogSetLevel(level int)
- func NewSample(nbSamples, nbChannels int, format SampleFormat) error
- func Release(i CgoMemoryManager)
- func Rescale(a, b, c int64) int64
- func RescaleDelta(inTb AVRational, inTs int64, fsTb AVRational, duration int, last *int64, ...) int64
- func RescaleQ(a int64, encBase AVRational, stBase AVRational) int64
- func RescaleQRnd(a int64, encBase AVRational, stBase AVRational) int64
- func RescaleTs(pkt *Packet, encBase AVRational, stBase AVRational)
- type AVAudioFifo
- type AVIOContext
- type AVIOHandlers
- type AVR
- type AVRational
- type CgoMemoryManage
- type CgoMemoryManager
- type Codec
- type CodecCtx
- func (cc *CodecCtx) BitRate() int
- func (cc *CodecCtx) ChannelLayout() int
- func (cc *CodecCtx) Channels() int
- func (cc *CodecCtx) Close()
- func (cc *CodecCtx) CloseAndRelease()
- func (cc *CodecCtx) Codec() *Codec
- func (cc *CodecCtx) CopyExtra(ist *Stream) *CodecCtx
- func (cc *CodecCtx) Decode(pkt *Packet) ([]*Frame, error)
- func (cc *CodecCtx) Decode2(pkt *Packet) (*Frame, int)
- func (cc *CodecCtx) Dump()
- func (cc *CodecCtx) Encode(frames []*Frame, drain int) ([]*Packet, error)
- func (cc *CodecCtx) FlushBuffers()
- func (cc *CodecCtx) FrameSize() int
- func (cc *CodecCtx) Free()
- func (cc *CodecCtx) GetAspectRation() AVRational
- func (cc *CodecCtx) GetBFrames() int
- func (cc *CodecCtx) GetBitsPerSample() int
- func (cc *CodecCtx) GetChannelLayoutName() string
- func (cc *CodecCtx) GetCodecTag() uint32
- func (cc *CodecCtx) GetCodecTagName() string
- func (cc *CodecCtx) GetCodedHeight() int
- func (cc *CodecCtx) GetCodedWith() int
- func (cc *CodecCtx) GetColorRangeName() string
- func (cc *CodecCtx) GetDefaultChannelLayout(ac int) int
- func (cc *CodecCtx) GetFrameRate() AVRational
- func (cc *CodecCtx) GetGopSize() int
- func (cc *CodecCtx) GetMediaType() string
- func (cc *CodecCtx) GetPixFmtName() string
- func (cc *CodecCtx) GetProfile() int
- func (cc *CodecCtx) GetProfileName() string
- func (cc *CodecCtx) GetRefs() int
- func (cc *CodecCtx) GetSampleFmtName() string
- func (cc *CodecCtx) GetVideoSize() string
- func (cc *CodecCtx) Height() int
- func (cc *CodecCtx) Id() int
- func (cc *CodecCtx) IsOpen() bool
- func (cc *CodecCtx) Open(dict *Dict) error
- func (cc *CodecCtx) PixFmt() int32
- func (cc *CodecCtx) Profile() int
- func (cc *CodecCtx) SampleFmt() int32
- func (cc *CodecCtx) SampleRate() int
- func (cc *CodecCtx) SelectChannelLayout() int
- func (cc *CodecCtx) SelectSampleFmt() int32
- func (cc *CodecCtx) SelectSampleRate() int
- func (cc *CodecCtx) SetBitRate(val int) *CodecCtx
- func (cc *CodecCtx) SetBitsPerRawSample(val int) *CodecCtx
- func (cc *CodecCtx) SetChannelLayout(channelLayout int)
- func (cc *CodecCtx) SetChannels(val int) *CodecCtx
- func (cc *CodecCtx) SetDimension(w, h int) *CodecCtx
- func (cc *CodecCtx) SetExtradata(extradata []byte) *CodecCtx
- func (cc *CodecCtx) SetFlag(flag int) *CodecCtx
- func (cc *CodecCtx) SetFrameRate(r AVR) *CodecCtx
- func (cc *CodecCtx) SetGlobalQuality(val int)
- func (cc *CodecCtx) SetGopSize(val int) *CodecCtx
- func (cc *CodecCtx) SetHasBframes(val int) *CodecCtx
- func (cc *CodecCtx) SetHeight(val int) *CodecCtx
- func (cc *CodecCtx) SetMaxBFrames(val int) *CodecCtx
- func (cc *CodecCtx) SetMbDecision(val int) *CodecCtx
- func (cc *CodecCtx) SetOpt()
- func (cc *CodecCtx) SetOptions(options []Option)
- func (cc *CodecCtx) SetPixFmt(val int32) *CodecCtx
- func (cc *CodecCtx) SetPktTimeBase(val AVR)
- func (cc *CodecCtx) SetProfile(profile int) *CodecCtx
- func (cc *CodecCtx) SetSampleFmt(val int32) *CodecCtx
- func (cc *CodecCtx) SetSampleRate(val int) *CodecCtx
- func (cc *CodecCtx) SetStrictCompliance(val int) *CodecCtx
- func (cc *CodecCtx) SetThreadCount(val int)
- func (cc *CodecCtx) SetTimeBase(val AVR) *CodecCtx
- func (cc *CodecCtx) SetWidth(val int) *CodecCtx
- func (cc *CodecCtx) SupportedSampleRate(val int) bool
- func (cc *CodecCtx) TimeBase() AVRational
- func (cc *CodecCtx) Type() int32
- func (cc *CodecCtx) Width() int
- type CodecDescriptor
- type CodecParameters
- func (cp *CodecParameters) BitRate() int64
- func (cp *CodecParameters) CodecId() int
- func (cp *CodecParameters) CodecType() int
- func (cp *CodecParameters) Format() int32
- func (cp *CodecParameters) Free()
- func (cp *CodecParameters) FromContext(cc *CodecCtx) error
- func (cp *CodecParameters) Height() int
- func (cp *CodecParameters) ToContext(cc *CodecCtx) error
- func (cp *CodecParameters) Width() int
- type Dict
- type Filter
- type FmtCtx
- func NewCtx(options ...[]Option) *FmtCtx
- func NewInputCtx(filename string) (*FmtCtx, error)
- func NewInputCtxWithFormatName(filename, format string) (*FmtCtx, error)
- func NewOutputCtx(i interface{}, options ...[]Option) (*FmtCtx, error)
- func NewOutputCtxWithFormatName(filename, format string) (*FmtCtx, error)
- func (ctx *FmtCtx) AddStreamWithCodeCtx(codeCtx *CodecCtx) (*Stream, error)
- func (ctx *FmtCtx) BitRate() int64
- func (ctx *FmtCtx) Close()
- func (ctx *FmtCtx) CloseInput()
- func (ctx *FmtCtx) CloseOutput()
- func (ctx *FmtCtx) Dump()
- func (ctx *FmtCtx) DumpAv()
- func (ctx *FmtCtx) Duration() float64
- func (ctx *FmtCtx) FindStreamInfo() error
- func (ctx *FmtCtx) Free()
- func (ctx *FmtCtx) GetBestStream(typ int32) (*Stream, error)
- func (ctx *FmtCtx) GetNewPackets() chan *Packet
- func (ctx *FmtCtx) GetNextPacket() (*Packet, error)
- func (ctx *FmtCtx) GetProbeSize() int64
- func (ctx *FmtCtx) GetSDPString() (sdp string)
- func (ctx *FmtCtx) GetStream(idx int) (*Stream, error)
- func (ctx *FmtCtx) IsGlobalHeader() bool
- func (ctx *FmtCtx) IsNoFile() bool
- func (ctx *FmtCtx) NewStream(c *Codec) *Stream
- func (ctx *FmtCtx) OpenInput(filename string) error
- func (ctx *FmtCtx) OpenInputWithOption(filename string, inputOptions *Option) error
- func (ctx *FmtCtx) Position() int
- func (ctx *FmtCtx) SeekFile(ist *Stream, minTs, maxTs int64, flag int) error
- func (ctx *FmtCtx) SeekFrameAt(sec int64, streamIndex int) error
- func (ctx *FmtCtx) SetDebug(val int) *FmtCtx
- func (ctx *FmtCtx) SetFlag(flag int) *FmtCtx
- func (ctx *FmtCtx) SetInputFormat(name string) error
- func (ctx *FmtCtx) SetOformat(ofmt *OutputFmt) error
- func (ctx *FmtCtx) SetOptions(options []*Option)
- func (ctx *FmtCtx) SetPb(val *AVIOContext) *FmtCtx
- func (ctx *FmtCtx) SetProbeSize(v int64)
- func (ctx *FmtCtx) SetStartTime(val int) *FmtCtx
- func (ctx *FmtCtx) StartTime() int
- func (ctx *FmtCtx) StreamsCnt() int
- func (ctx *FmtCtx) TsOffset(stime int) int
- func (ctx *FmtCtx) WriteHeader() error
- func (ctx *FmtCtx) WritePacket(p *Packet) error
- func (ctx *FmtCtx) WritePacketNoBuffer(p *Packet) error
- func (ctx *FmtCtx) WriteSDPFile(filename string) error
- func (ctx *FmtCtx) WriteTrailer()
- type Frame
- func (f *Frame) BestEffortTimestamp() int64
- func (f *Frame) Channels() int
- func (f *Frame) ChromaLocation() string
- func (f *Frame) CloneNewFrame() *Frame
- func (f *Frame) CodedPictureNumber() int
- func (f *Frame) DisplayPictureNumber() int
- func (f *Frame) Dump()
- func (f *Frame) Encode(enc *CodecCtx) (*Packet, error)
- func (f *Frame) Format() int
- func (f *Frame) Free()
- func (f *Frame) GetChannelLayout() int
- func (f *Frame) GetRawAudioData(plane int) []byte
- func (f *Frame) GetRawFrame() *C.struct_AVFrame
- func (f *Frame) Height() int
- func (f *Frame) ImgAlloc() error
- func (f *Frame) InterlacedFrame() int
- func (f *Frame) IsNil() bool
- func (f *Frame) KeyFrame() int
- func (f *Frame) LineSize(idx int) int
- func (f *Frame) NbSamples() int
- func (f *Frame) PictType() byte
- func (f *Frame) PktDts() int64
- func (f *Frame) PktPos() int64
- func (f *Frame) PktPts() int64
- func (f *Frame) PktSize() int
- func (f *Frame) Pts() int64
- func (f *Frame) Quality() int
- func (f *Frame) RepeatPict() int
- func (f *Frame) SampleAspectRatio() AVRational
- func (f *Frame) SetChannelLayout(val int) *Frame
- func (f *Frame) SetChannels(val int) *Frame
- func (f *Frame) SetData(idx int, lineSize int, data int) *Frame
- func (f *Frame) SetFormat(val int32) *Frame
- func (f *Frame) SetHeight(val int) *Frame
- func (f *Frame) SetNbSamples(val int) *Frame
- func (f *Frame) SetPictType(val uint32)
- func (f *Frame) SetPktDts(val int64)
- func (f *Frame) SetPktPts(val int64)
- func (f *Frame) SetPts(val int64)
- func (f *Frame) SetQuality(val int) *Frame
- func (f *Frame) SetWidth(val int) *Frame
- func (f *Frame) Time(timebase AVRational) int
- func (f *Frame) TopFieldFirst() int
- func (f *Frame) Unref()
- func (f *Frame) Width() int
- type Image
- type Option
- type OutputFmt
- type Packet
- func (p *Packet) Clone() *Packet
- func (p *Packet) Data() []byte
- func (p *Packet) Dts() int64
- func (p *Packet) Dump()
- func (p *Packet) Duration() int64
- func (p *Packet) Flags() int
- func (p *Packet) Free()
- func (p *Packet) FreeData() *Packet
- func (p *Packet) Pos() int64
- func (p *Packet) Pts() int64
- func (p *Packet) SetData(data []byte) *Packet
- func (p *Packet) SetDts(val int64) *Packet
- func (p *Packet) SetDuration(duration int64) *Packet
- func (p *Packet) SetFlags(flags int) *Packet
- func (p *Packet) SetPts(pts int64) *Packet
- func (p *Packet) SetStreamIndex(val int) *Packet
- func (p *Packet) Size() int
- func (p *Packet) StreamIndex() int
- func (p *Packet) Time(timebase AVRational) int
- type Pair
- type Sample
- type SampleFormat
- type Stream
- func (s *Stream) CodecCtx() *CodecCtx
- func (s *Stream) CodecPar() *CodecParameters
- func (s *Stream) CopyCodecPar(cp *CodecParameters) error
- func (s *Stream) DumpContexCodec(codec *CodecCtx)
- func (s *Stream) Duration() int64
- func (s *Stream) Free()
- func (s *Stream) GetAvgFrameRate() AVRational
- func (s *Stream) GetCodecPar() *CodecParameters
- func (s *Stream) GetRFrameRate() AVRational
- func (s *Stream) GetStartTime() int64
- func (s *Stream) Id() int
- func (s *Stream) Index() int
- func (s *Stream) IsAudio() bool
- func (s *Stream) IsCodecCtxSet() bool
- func (s *Stream) IsVideo() bool
- func (s *Stream) NbFrames() int
- func (s *Stream) SetAvgFrameRate(val AVR)
- func (s *Stream) SetCodecCtx(cc *CodecCtx)
- func (s *Stream) SetCodecFlags()
- func (s *Stream) SetCodecPar(cp *CodecParameters) error
- func (s *Stream) SetRFrameRate(val AVR)
- func (s *Stream) SetTimeBase(val AVR) *Stream
- func (s *Stream) TimeBase() AVRational
- func (s *Stream) Type() int32
- type SwrCtx
- type SwsCtx
Examples ¶
Constants ¶
const ( AVIO_FLAG_READ = 1 AVIO_FLAG_WRITE = 2 AVIO_FLAG_READ_WRITE = (AVIO_FLAG_READ | AVIO_FLAG_WRITE) )
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 )
const ( AV_BUFFERSINK_FLAG_PEEK = 1 AV_BUFFERSINK_FLAG_NO_REQUEST = 2 AV_BUFFERSRC_FLAG_PUSH = 4 )
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 )
const ( PLAYLIST_TYPE_NONE int = iota PLAYLIST_TYPE_EVENT PLAYLIST_TYPE_VOD PLAYLIST_TYPE_NB )
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 )
const (
AVERROR_EOF = -541478725
)
const (
AV_PKT_FLAG_KEY = C.AV_PKT_FLAG_KEY // The packet contains a keyframe
)
Variables ¶
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_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_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 )
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 )
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 )
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 )
var ( AV_TIME_BASE int = C.AV_TIME_BASE AV_TIME_BASE_Q AVRational = AVRational{1, C.int(AV_TIME_BASE)} )
var Codecs []*CodecDescriptor
var (
IO_BUFFER_SIZE int = 32768
)
Functions ¶
func CompareTimeStamp ¶
func CompareTimeStamp(aTimestamp int, aTimebase AVRational, bTimestamp int, bTimebase AVRational) int
func GenSyntVideoNewFrame ¶
Synthetic video generator. It produces 25 iteratable frames. Used for tests.
func GetSampleFmtName ¶
func LogSetLevel ¶
func LogSetLevel(level int)
func NewSample ¶
func NewSample(nbSamples, nbChannels int, format SampleFormat) error
func Release ¶
func Release(i CgoMemoryManager)
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" "github.com/3d0c/gmf" "io" "log" "os" ) 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 ¶
func (AVR) AVRational ¶
func (a AVR) AVRational() AVRational
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() }
func Retain ¶
func Retain(i CgoMemoryManager) CgoMemoryManager
type Codec ¶
type Codec struct { CgoMemoryManage // contains filtered or unexported fields }
func FindDecoder ¶
func FindEncoder ¶
func (*Codec) IsExperimental ¶
type CodecCtx ¶
type CodecCtx struct { CgoMemoryManage // contains filtered or unexported fields }
func NewCodecCtx ¶
func (*CodecCtx) ChannelLayout ¶
func (*CodecCtx) CloseAndRelease ¶
func (cc *CodecCtx) CloseAndRelease()
func (*CodecCtx) FlushBuffers ¶
func (cc *CodecCtx) FlushBuffers()
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 (*CodecCtx) GetBitsPerSample ¶
func (*CodecCtx) GetChannelLayoutName ¶
func (*CodecCtx) GetCodecTag ¶
func (*CodecCtx) GetCodecTagName ¶
func (*CodecCtx) GetCodedHeight ¶
func (*CodecCtx) GetCodedWith ¶
func (*CodecCtx) GetColorRangeName ¶
func (*CodecCtx) GetDefaultChannelLayout ¶
func (*CodecCtx) GetFrameRate ¶
func (cc *CodecCtx) GetFrameRate() AVRational
func (*CodecCtx) GetGopSize ¶
func (*CodecCtx) GetMediaType ¶
func (*CodecCtx) GetPixFmtName ¶
func (*CodecCtx) GetProfile ¶
func (*CodecCtx) GetProfileName ¶
func (*CodecCtx) GetSampleFmtName ¶
func (*CodecCtx) GetVideoSize ¶
func (*CodecCtx) SampleRate ¶
func (*CodecCtx) SelectChannelLayout ¶
func (*CodecCtx) SelectSampleFmt ¶
func (*CodecCtx) SelectSampleRate ¶
func (*CodecCtx) SetBitRate ¶
func (*CodecCtx) SetBitsPerRawSample ¶
func (*CodecCtx) SetChannelLayout ¶
func (*CodecCtx) SetChannels ¶
func (*CodecCtx) SetDimension ¶
func (*CodecCtx) SetExtradata ¶
SetExtradata TODO: Improving performance
Free or avcodec_free_context can free extradata
func (*CodecCtx) SetFrameRate ¶
func (*CodecCtx) SetGlobalQuality ¶
func (*CodecCtx) SetGopSize ¶
func (*CodecCtx) SetHasBframes ¶
func (*CodecCtx) SetMaxBFrames ¶
func (*CodecCtx) SetMbDecision ¶
func (*CodecCtx) SetOptions ¶
func (*CodecCtx) SetPktTimeBase ¶
func (*CodecCtx) SetProfile ¶
func (*CodecCtx) SetSampleFmt ¶
func (*CodecCtx) SetSampleRate ¶
func (*CodecCtx) SetStrictCompliance ¶
func (*CodecCtx) SetThreadCount ¶
func (*CodecCtx) SetTimeBase ¶
func (*CodecCtx) SupportedSampleRate ¶
func (*CodecCtx) TimeBase ¶
func (cc *CodecCtx) TimeBase() AVRational
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 Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
func (*Filter) RequestOldest ¶
type FmtCtx ¶
type FmtCtx struct { Filename string // contains filtered or unexported fields }
func NewInputCtx ¶
Just a helper for NewCtx().OpenInput()
func NewOutputCtx ¶
func (*FmtCtx) AddStreamWithCodeCtx ¶
func (*FmtCtx) CloseInput ¶
func (ctx *FmtCtx) CloseInput()
func (*FmtCtx) CloseOutput ¶
func (ctx *FmtCtx) CloseOutput()
func (*FmtCtx) FindStreamInfo ¶
func (*FmtCtx) GetNewPackets ¶
func (*FmtCtx) GetNextPacket ¶
func (*FmtCtx) GetProbeSize ¶
func (*FmtCtx) GetSDPString ¶
func (*FmtCtx) IsGlobalHeader ¶
func (*FmtCtx) OpenInputWithOption ¶
func (*FmtCtx) SetInputFormat ¶
func (*FmtCtx) SetOformat ¶
func (*FmtCtx) SetOptions ¶
func (*FmtCtx) SetPb ¶
func (ctx *FmtCtx) SetPb(val *AVIOContext) *FmtCtx
func (*FmtCtx) SetProbeSize ¶
func (*FmtCtx) SetStartTime ¶
func (*FmtCtx) StreamsCnt ¶
Original structure member is called instead of len(this.streams) because there is no initialized Stream wrappers in input context.
func (*FmtCtx) WriteHeader ¶
func (*FmtCtx) WritePacket ¶
func (*FmtCtx) WritePacketNoBuffer ¶
func (*FmtCtx) WriteSDPFile ¶
func (*FmtCtx) WriteTrailer ¶
func (ctx *FmtCtx) WriteTrailer()
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
func NewAudioFrame ¶
func (*Frame) BestEffortTimestamp ¶
func (*Frame) ChromaLocation ¶
func (*Frame) CloneNewFrame ¶
func (*Frame) CodedPictureNumber ¶
func (*Frame) DisplayPictureNumber ¶
func (*Frame) GetChannelLayout ¶
func (*Frame) GetRawAudioData ¶
func (*Frame) GetRawFrame ¶
func (f *Frame) GetRawFrame() *C.struct_AVFrame
func (*Frame) InterlacedFrame ¶
func (*Frame) RepeatPict ¶
func (*Frame) SampleAspectRatio ¶
func (f *Frame) SampleAspectRatio() AVRational
func (*Frame) SetChannelLayout ¶
func (*Frame) SetChannels ¶
func (*Frame) SetNbSamples ¶
func (*Frame) SetPictType ¶
func (*Frame) SetQuality ¶
func (*Frame) Time ¶
func (f *Frame) Time(timebase AVRational) int
func (*Frame) TopFieldFirst ¶
type Image ¶
type Image struct { CgoMemoryManage // contains filtered or unexported fields }
type OutputFmt ¶
type OutputFmt struct { Filename string CgoMemoryManage // contains filtered or unexported fields }
func (*OutputFmt) Infomation ¶
type Packet ¶
type Packet struct {
// contains filtered or unexported fields
}
func Init ¶
func Init() *Packet
Init same to NewPacket and av_init_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 (*Packet) FreeData ¶
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) SetData ¶
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) SetDuration ¶
func (*Packet) SetFlags ¶
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) SetStreamIndex ¶
func (*Packet) StreamIndex ¶
func (*Packet) Time ¶
func (p *Packet) Time(timebase AVRational) int
type Sample ¶
type Sample struct { CgoMemoryManage // contains filtered or unexported fields }
func (*Sample) SampleRealloc ¶
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 ¶
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 (*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 (*Stream) IsCodecCtxSet ¶
IsCodecCtxSet Deprecated: Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
func (*Stream) SetAvgFrameRate ¶
func (*Stream) SetCodecCtx ¶
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 (*Stream) SetTimeBase ¶
func (*Stream) TimeBase ¶
func (s *Stream) TimeBase() AVRational