Skip to content

gst sinks and sources #25

@dexterlb

Description

@dexterlb

The go-gst library provides a convenient api for GStreamer that can be used to implement a sink. It should be quite straight-forward, something like this:

// ensure to call once, globally
gst.Init(nil)

// create a pipeline and attach its source
// pipelineStr should come from the config file and be something like
// `appsrc name="source_foo" ! ...`
pipeline, err := gst.ParseLaunch(pipelineStr)
if err != nil {
    // oops
}

// make the source name configurable
// might even be easy to allow multiple sinks to go
// into the same gstreamer…
src := pipeline.GetByName("source_foo")
if src == nil {
    // oops
}

// the pipeline can be controlled
pipeline.SetState(gst.StatePlaying)

// now for each frame
frame := frames.GetFrameForReading()
buffer := gst.NewBufferFromBytes(frame.Data)    // need to check if this does a copy, I hope not
buffer.SetPresentationTimestamp(frame.Timestamp)  // would be nice to provide sane timestamps
err := src.PushBuffer(buffer)
if err != nil {
    frames.FailedReading(frame)
} else {
    frames.FinishedReading(frame)
}

A similar thing could be used for sources, and would even allow sources that pause their video while they are not visible, etc.

It should also have much less latency and memory bandwidth usage than the naïve ffmpeg_stdin approach. Nevertheless, a native libva sink/source implementation might also be useful to investigate…

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions