Пример #1
0
func main() {
	src := makeElement("videotestsrc", "testSource")

	encoder := makeElement("x264enc", "encoder")
	setProperty(encoder, "key-int-max", 250)

	parser := makeElement("h264parse", "parser")

	mux := makeElement("mpegtsmux", "muxer")

	sink := makeElement("hlssink", "sink")
	setProperty(sink, "target-duration", 5)
	setProperty(sink, "location", "segments/segment%05d.ts")
	setProperty(sink, "playlist-location", "segments/playlist.m3u8")

	if err != nil {
		fmt.Fprintf(os.Stderr, "Cannot proceed %v\n", err)
		os.Exit(-1)
	}

	pipe := gst.NewPipeline("TestPipeline")
	if pipe == nil {
		panic("Failed to create pipe")
	}
	pipe.Add(src, encoder, parser, mux, sink)

	link(src, encoder, parser, mux, sink)

	pipe.SetState(gst.STATE_PLAYING)
	for {
	}
}
Пример #2
0
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()
}
Пример #3
0
func main() {
	src := gst.ElementFactoryMake("videotestsrc", "Test source")
	src.SetProperty("do-timestamp", true)
	src.SetProperty("pattern", 18) // ball

	//enc := gst.ElementFactoryMake("vp8enc", "VP8 encoder")
	enc := gst.ElementFactoryMake("x264enc", "H.264 encoder")

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

	demux := gst.ElementFactoryMake("matroskademux", "Matroska demuxer")

	//dec := gst.ElementFactoryMake("vp8dec", "VP8 dcoder")
	dec := gst.ElementFactoryMake("ffdec_h264", "H.264 dcoder")

	sink := gst.ElementFactoryMake("autovideosink", "Video display element")

	pl := gst.NewPipeline("MyPipeline")

	pl.Add(src, enc, mux, demux, dec, sink)

	src.Link(enc, mux, demux)
	demux.ConnectNoi("pad-added", cbPadAdded, dec.GetStaticPad("sink"))
	dec.Link(sink)
	pl.SetState(gst.STATE_PLAYING)

	glib.NewMainLoop(nil).Run()
}
Пример #4
0
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()
}
Пример #5
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
}