https://github.com/notedit/gstreamer-go
gstreamer wrap for golang
https://github.com/notedit/gstreamer-go
golang gstreamer
Last synced: about 1 year ago
JSON representation
gstreamer wrap for golang
- Host: GitHub
- URL: https://github.com/notedit/gstreamer-go
- Owner: notedit
- Created: 2018-12-04T12:19:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-21T07:22:30.000Z (about 6 years ago)
- Last Synced: 2025-03-26T12:47:01.905Z (about 1 year ago)
- Topics: golang, gstreamer
- Language: Go
- Size: 15.6 KB
- Stars: 65
- Watchers: 3
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gstreamer-go
gstreamer simple wrap for golang
## You can also try https://github.com/notedit/gst
## Install
Ubuntu or Dedian
```sh
apt-get install pkg-config
apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-ugly gstreamer1.0-libav
```
Mac os
```sh
brew install gstreamer
brew install gst-plugins-base
brew install gst-plugins-good
brew install gst-plugins-bad
brew install gst-plugins-ugly
```
Then
```sh
go get github.com/notedit/gstreamer-go
```
## How to use
```go
pipeline, err := New("videotestsrc ! capsfilter name=filter ! autovideosink")
if err != nil {
t.Error("pipeline create error", err)
t.FailNow()
}
filter := pipeline.FindElement("filter")
if filter == nil {
t.Error("pipeline find element error ")
}
filter.SetCap("video/x-raw,width=1280,height=720")
pipeline.Start()
```
## Send Media data to pipeline
```go
pipeline, err := New("appsrc name=mysource format=time is-live=true do-timestamp=true ! videoconvert ! autovideosink")
if err != nil {
t.Error("pipeline create error", err)
t.FailNow()
}
appsrc := pipeline.FindElement("mysource")
appsrc.SetCap("video/x-raw,format=RGB,width=320,height=240,bpp=24,depth=24")
pipeline.Start()
for {
time.Sleep(1 * time.Second)
appsrc.Push(make([]byte, 320*240*3))
}
```
push raw rgb data to the pipeline
## Poll Media data from pipeline
```go
pipeline, err := New("videotestsrc ! video/x-raw,format=I420,framerate=15/1 ! x264enc bframes=0 speed-preset=veryfast key-int-max=60 ! video/x-h264,stream-format=byte-stream ! appsink name=sink")
if err != nil {
t.Error("pipeline create error", err)
t.FailNow()
}
appsink := pipeline.FindElement("sink")
pipeline.Start()
out := appsink.Poll()
for {
buffer := <-out
fmt.Println("push ", len(buffer))
}
```
now we can get the h264 raw data from the pipeline
## Check Plugins does exist
```go
plugins := []string{"videotestsrc", "audiotestsrc", "rtp", "curl","x264", "rtmp"}
err := CheckPlugins(plugins)
if err != nil {
panic(err)
}
```