GStreamer must be initialized before using it. Initialization loads the GStreamer libraries and plug-ins.
(require gstreamer) (unless (gst-initialized?) (if (gst-initialize) (displayln (gst-version-string)) (error "Could not load GStreamer")))
This initializes GStreamer if it hasn’t already been loaded, and prints its version, or raises an error if GStreamer could not be initialized.
(define test-pattern (element-factory%-make "videotestsrc")) (define preview (element-factory%-make "osxvideosink")) (define my-pipeline (pipeline%-compose "my-pipeline" test-pattern preview))
This code creates two elements: a source that generates test video data and a native macOS video sink. It then composes a pipeline by linking those two elements together. Every GStreamer application needs a pipeline and pipeline%-compose is a convenient mechanism for quickly creating them.
From here the pipeline can be played by setting its state:
This will draw a new window where a test video signal of SMPTE color bars will be displayed.
Shut down the pipeline by setting its state again:
A quick way to create a pipeline is by using parse/launch to parse a pipeline description into an element.
(define trailer-uri "http://movietrailers.apple.com/movies/marvel/thor-ragnarok/thor-ragnarok-trailer-1_h720p.mov") (define movie-trailer (parse/launch (format "playbin uri=~a" trailer-uri))) (send movie-trailer play!)
A playbin element is used to quickly play media from a URI. In addition to parse/launch, the gstreamer module provides a number of utilities and helpers for working with Common Elements for building basic pipelines.