示例#1
0
文件: simple.go 项目: sergey789/gst
func main() {
	src := gst.ElementFactoryMake("videotestsrc", "VideoSrc")
	checkElem(src, "videotestsrc")
	//vsink := "autovideosink"
	vsink := "xvimagesink"
	sink := gst.ElementFactoryMake(vsink, "VideoSink")
	checkElem(sink, vsink)

	pl := gst.NewPipeline("MyPipeline")

	pl.Add(src, sink)
	filter := gst.NewCapsSimple(
		"video/x-raw,format=yuv",
		glib.Params{
			"width":     int32(192),
			"height":    int32(108),
			"framerate": &gst.Fraction{25, 1},
		},
	)
	fmt.Println(filter)
	//src.LinkFiltered(sink, filter)
	src.Link(sink)
	pl.SetState(gst.STATE_PLAYING)

	glib.NewMainLoop(nil).Run()
}
示例#2
0
文件: simple.go 项目: jmrobles/gst
func main() {
	src := gst.ElementFactoryMake("videotestsrc", "VideoSrc")
	sink := gst.ElementFactoryMake("autovideosink", "VideoSink")
	pl := gst.NewPipeline("MyPipeline")

	pl.Add(src, sink)
	filter := gst.NewCapsSimple(
		"video/x-raw-yuv",
		glib.Params{
			"width":     192,
			"height":    108,
			"framerate": &gst.Fraction{25, 1},
		},
	)
	fmt.Println(filter)
	src.LinkFiltered(sink, filter)
	pl.SetState(gst.STATE_PLAYING)

	glib.NewMainLoop(nil).Run()
}
示例#3
0
func NewWebM(width, height, fps int) *WebM {
	wm := new(WebM)
	wm.conns = make(map[int]net.Conn)

	src := gst.ElementFactoryMake("videotestsrc", "Test source")
	src.SetProperty("do-timestamp", true)
	src.SetProperty("pattern", 18) // ball

	enc := gst.ElementFactoryMake("vp8enc", "VP8 encoder")

	mux := gst.ElementFactoryMake("webmmux", "WebM muxer")
	mux.SetProperty("streamable", true)

	wm.sink = gst.ElementFactoryMake("multifdsink", "Multifd sink")
	wm.sink.SetProperty("sync", true)
	wm.sink.SetProperty("recover-policy", 3) // keyframe
	wm.sink.SetProperty("sync-method", 2)    // latest-keyframe

	wm.pl = gst.NewPipeline("WebM generator")
	wm.pl.Add(src, enc, mux, wm.sink)

	filter := gst.NewCapsSimple(
		"video/x-raw,format=yuv",
		glib.Params{
			"width":     int32(width),
			"height":    int32(height),
			"framerate": &gst.Fraction{fps, 1},
		},
	)
	src.LinkFiltered(enc, filter)
	enc.Link(mux, wm.sink)

	wm.sink.ConnectNoi("client-fd-removed", (*WebM).cbClientFdRemoved, wm)

	return wm
}