GStreamer: Difference between revisions
| imported>Malteneuss  Extend page | imported>Malteneuss  Add error example | ||
| Line 59: | Line 59: | ||
|    Description              GStreamer core elements |    Description              GStreamer core elements | ||
|    Filename                 /nix/store/p39g1gmpymya3blmqxmf54bpvv3s9z61-gstreamer-1.20.3/lib/gstreamer-1.0/libgstcoreelements.so |    Filename                 /nix/store/p39g1gmpymya3blmqxmf54bpvv3s9z61-gstreamer-1.20.3/lib/gstreamer-1.0/libgstcoreelements.so | ||
| ... |   ... | ||
| </syntaxhighlight> | </syntaxhighlight> | ||
|  or by using it in a pipeline. Here, we could play a video from the local machine with | |||
| <syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
| $ gst-launch-1.0 filesrc location=my_video.mp4 ! videoconvert ! autovideosink | $ gst-launch-1.0 filesrc location=my_video.mp4 ! videoconvert ! autovideosink | ||
| </syntaxhighlight> | </syntaxhighlight> | ||
| If the plugins are not correctly made available to the higher level tools, you'll get an error | |||
| <syntaxhighlight lang="nix"> | |||
| $ gst-inspect-1.0 filesrc | |||
| No such element or plugin 'filesrc' | |||
| </syntaxhighlight> | |||
| You could try setting the plugin path environment variable manually as described [https://discourse.nixos.org/t/how-to-use-gst-plugins/6345/2 here]. | |||
Revision as of 10:45, 6 April 2023
GStreamer is a popular multimedia framework to handle a variety of video and audio formats on different platforms in a uniform way through a powerful and convenient API in order to build multimedia apps, video/audio editors and streaming services. It consists of a huge amount low-level plugins like "videotestsrc", "videoconvert" and "autovideosink" as well as a few higher level test-and-combine framework tools like "gst-inspect", "gst-launch" etc.
Installing via nixpkgs
In Nix as in other Linux distributions those tools and plugins are split into separate packages, which you can bring together with a custom Nix shell environment:
# file: flake.nix
{
  description = "A GStreamer development flake";
  outputs = { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          # Video/Audio data composition framework tools like "gst-inspect", "gst-launch" ...
          gst_all_1.gstreamer
          # Common plugins like "filesrc" to combine within e.g. gst-launch
          gst_all_1.gst-plugins-base
          # Specialized plugins separated by quality
          gst_all_1.gst-plugins-good
          gst_all_1.gst-plugins-bad
          gst_all_1.gst-plugins-ugly
          # Plugins to reuse ffmpeg to play almost every video format
          gst_all_1.gst-libav
          # Support the Video Audio (Hardware) Acceleration API
          gst_all_1.gst-vaapi
          #...
        ];
      };
    };
}
To activate this environment in your terminal run
$ nix develop
You can find all available Nix package names through the Nix search page.
Test the installation
You can test that the gst_all_1.gstreamer tools are available by running a dummy pipeline
$ gst-launch-1.0 videotestsrc ! videoconvert ! autovideosink
which should open a colored video window.
You can test that the plugins like from gst_all_1.gst-plugins-base are available to the higher level tools by inspecting such a base plugin like filesrc with
$ gst-inspect-1.0 filesrc
Factory Details:
  ...
  Long-name                File Source
  Description              Read from arbitrary point in a file
  ...
Plugin Details:
  Name                     coreelements
  Description              GStreamer core elements
  Filename                 /nix/store/p39g1gmpymya3blmqxmf54bpvv3s9z61-gstreamer-1.20.3/lib/gstreamer-1.0/libgstcoreelements.so
  ...
or by using it in a pipeline. Here, we could play a video from the local machine with
$ gst-launch-1.0 filesrc location=my_video.mp4 ! videoconvert ! autovideosink
If the plugins are not correctly made available to the higher level tools, you'll get an error
$ gst-inspect-1.0 filesrc
No such element or plugin 'filesrc'
You could try setting the plugin path environment variable manually as described here.
