Beispiel #1
0
func GuessOutputFromMimeType(mimeType string) *Output {
	cMimeType := C.CString(mimeType)
	defer C.free(unsafe.Pointer(cMimeType))
	cOutput := C.av_guess_format(nil, nil, cMimeType)
	if cOutput == nil {
		return nil
	}
	return NewOutputFromC(unsafe.Pointer(cOutput))
}
Beispiel #2
0
func GuessOutputFromFileName(fileName string) *Output {
	cFileName := C.CString(fileName)
	defer C.free(unsafe.Pointer(cFileName))
	cOutput := C.av_guess_format(nil, cFileName, nil)
	if cOutput == nil {
		return nil
	}
	return NewOutputFromC(unsafe.Pointer(cOutput))
}
Beispiel #3
0
func GuessOutputFromShortName(shortName string) *Output {
	cShortName := C.CString(shortName)
	defer C.free(unsafe.Pointer(cShortName))
	cOutput := C.av_guess_format(cShortName, nil, nil)
	if cOutput == nil {
		return nil
	}
	return NewOutputFromC(unsafe.Pointer(cOutput))
}
func av_guess_format(format, filename string) OutputFormat {
	result := OutputFormat{}
	cfilename := C.CString(filename)
	cformat := C.CString(format)
	defer C.free(unsafe.Pointer(cfilename))
	defer C.free(unsafe.Pointer(cformat))
	fmt := C.av_guess_format(cformat, cfilename, nil)
	result.format = fmt
	return result
}
Beispiel #5
0
func FindOutputFmt(format string, filename string, mime string) *OutputFmt {
	cformat := C.CString(format)
	defer C.free(unsafe.Pointer(cformat))

	cfilename := C.CString(filename)
	defer C.free(unsafe.Pointer(cfilename))

	cmime := C.CString(mime)
	defer C.free(unsafe.Pointer(cmime))

	var ofmt *C.AVOutputFormat

	if ofmt = C.av_guess_format(cformat, nil, cmime); ofmt == nil {
		ofmt = C.av_guess_format(nil, cfilename, cmime)
	}

	if ofmt == nil {
		return nil
	}

	return &OutputFmt{Filename: filename, avOutputFmt: ofmt}
}
Beispiel #6
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
}
Beispiel #7
0
//Return the output format in the list of registered output formats which best matches the provided parameters, or return NULL if there is no match.
func AvGuessFormat(sn, f, mt string) *OutputFormat {
	return (*OutputFormat)(C.av_guess_format(C.CString(sn), C.CString(f), C.CString(mt)))
}