Example #1
0
func (m *Muxer) Open() bool {
	w, h := m.capture.Resolution()
	if !m.AddVideoStream(C.AV_CODEC_ID_H264, w, h) {
		return false
	}
	if !m.AddAudioStream(C.AV_CODEC_ID_AAC) {
		return false
	}
	if m.context.oformat.flags&C.AVFMT_NOFILE == 0 {
		if C.avio_open(&m.context.pb, &m.context.filename[0], C.AVIO_FLAG_WRITE) < 0 {
			return false
		}
		m.recl = append(m.recl, func() {
			C.avio_close(m.context.pb)
		})
	}
	C.av_dump_format(m.context, 0, &m.context.filename[0], 1)
	if C.avformat_write_header(m.context, (**C.AVDictionary)(null)) < 0 {
		return false
	}
	m.recl = append(m.recl, func() {
		C.av_write_trailer(m.context)
	})
	m.loop = true
	go m.routine()
	if m.display != nil {
		m.display.Open()
	}
	return true
}
Example #2
0
func (ctx *Context) WriteTrailer() error {
	code := C.av_write_trailer(ctx.CAVFormatContext)
	if code < 0 {
		return avutil.NewErrorFromCode(avutil.ErrorCode(code))
	}
	return nil
}
Example #3
0
func (this *FmtCtx) CloseOutput() {
	if this.avCtx == nil {
		return
	}

	if this.avCtx.pb != nil {
		C.av_write_trailer(this.avCtx)
		C.avio_close(this.avCtx.pb)
	}

	this.Free()
}
func av_write_trailer(ctx *FormatContext) int {
	return int(C.av_write_trailer(ctx.ctx))
}
Example #5
0
func (this *FmtCtx) WriteTrailer() {
	C.av_write_trailer(this.avCtx)
}
Example #6
0
File: context.go Project: ovr/goav
//Write the stream trailer to an output media file and free the file private data.
func (s *Context) AvWriteTrailer() int {
	return int(C.av_write_trailer((*C.struct_AVFormatContext)(s)))
}
Example #7
0
//int av_write_trailer (AVFormatContext *s)
//Write the stream trailer to an output media file and free the file private data.
func Av_write_trailer(s *AVFormatContext) int {
	return int(C.av_write_trailer((*C.struct_AVFormatContext)(s)))
}