Esempio n. 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
}
Esempio n. 2
0
func (this *FmtCtx) CloseOutputAndRelease() {
	if this.avCtx == nil || this.IsNoFile() {
		return
	}

	if this.avCtx.pb != nil && !this.customPb {
		this.WriteTrailer()
		C.avio_close(this.avCtx.pb)
	}

	Release(this)
}
Esempio n. 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()
}
Esempio n. 4
0
func url_fclose(ctx *FormatContext) int {
	return int(C.avio_close(ctx.ctx.pb))
}
Esempio n. 5
0
func (ctx *IOContext) Close() {
	if ctx.CAVIOContext != nil {
		defer C.avio_close(ctx.CAVIOContext)
		ctx.CAVIOContext = nil
	}
}