Пример #1
0
func NewMuxer(source *MediaSource, format, uri string) (*Muxer, error) {
	m := Muxer{done: make(chan bool), recl: make([]reclaimer, 0, 8)}
	m.context = C.avformat_alloc_context()
	if m.context == (*C.AVFormatContext)(null) {
		return nil, fmt.Errorf("allocate output format context failed")
	}
	m.recl = append(m.recl, func() {
		C.avformat_free_context(m.context)
	})
	var f *C.char = C.CString(format)
	var u *C.char = C.CString(uri)
	defer C.free(unsafe.Pointer(f))
	defer C.free(unsafe.Pointer(u))
	m.context.oformat = C.av_guess_format(f, u, (*C.char)(null))
	if m.context.oformat == (*C.AVOutputFormat)(null) {
		return nil, fmt.Errorf("output format not supported")
	}
	C.av_strlcpy(&m.context.filename[0], u, C.size_t(unsafe.Sizeof(m.context.filename)))
	var err error
	if m.capture, err = NewCapture(source.Video.driver, source.Video.device); err != nil {
		return nil, err
	}
	return &m, nil
}
Пример #2
0
func (this *FmtCtx) Free() {
	if this.avCtx != nil {
		C.avformat_free_context(this.avCtx)
	}
}
Пример #3
0
//Free an Context and all its streams.
func (s *Context) AvformatFreeContext() {
	C.avformat_free_context((*C.struct_AVFormatContext)(s))
}
Пример #4
0
//void avformat_free_context (AVFormatContext *s)
//Free an AVFormatContext and all its streams.
func Avformat_free_context(s *AVFormatContext) {
	C.avformat_free_context((*C.struct_AVFormatContext)(s))
}
Пример #5
0
func (ctx *Context) Free() {
	if ctx.CAVFormatContext != nil {
		defer C.avformat_free_context(ctx.CAVFormatContext)
		ctx.CAVFormatContext = nil
	}
}