示例#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
}
示例#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
}
示例#3
0
文件: format.go 项目: 0x46616c6b/gmf
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))
}
示例#5
0
文件: format.go 项目: Dim0N22/gmf
func (this *FmtCtx) WriteTrailer() {
	C.av_write_trailer(this.avCtx)
}
示例#6
0
文件: context.go 项目: 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)))
}
示例#7
0
文件: avformat.go 项目: hyhy01/goav
//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)))
}