GStreamer: Difference between revisions

imported>Malteneuss
Extend page
(5 intermediate revisions by 3 users not shown)
Line 58: Line 58:
   Name                    coreelements
   Name                    coreelements
   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/p39g1.../libgstcoreelements.so
...
  ...
</syntaxhighlight>
</syntaxhighlight>


  or by using it in a pipeline. Here, we could play a video from the local machine with
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>
== Troubleshooting ==
==== erroneous pipeline: no element "filesrc" ====
In some cases while creating a shell using "mkShell" or "writeShellApplication" just setting the "runtimeInputs" is not enough. It's necessary to manually set the "GST_PLUGIN_SYSTEM_PATH_1_0" environment variable.<ref>https://discourse.nixos.org/t/how-to-use-gst-plugins/6345</ref>
Adding the following export to your script, sets "gstreamer" and "gst-plugins-base" and "gst-plugins-good" paths. Similarly you can add any other "gst-plugins" package as well.
<syntaxhighlight lang="shell">
export GST_PLUGIN_SYSTEM_PATH_1_0="${gst_all_1.gstreamer.out}/lib/gstreamer-1.0:${gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${gst_all_1.gst-plugins-good}/lib/gstreamer-1.0"
</syntaxhighlight>Note: "gstreamer.out" is the derivative that contains "/lib" directory for that package.
<references />
==== nautilus: "Your GStreamer installation is missing a plug-in." ====
[[File:Screenshot From 2025-03-28 09-58-50.png|thumb|nautilus: "Your GStreamer installation is missing a plug-in."]]
To fix the issue I found the following solutions:
* use <code>nix-shell</code>:<syntaxhighlight lang="bash">
nix-shell -p gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-ugly gst_all_1.gst-libav gst_all_1.gst-vaapi --run "nautilus"
</syntaxhighlight>
* [[File:Screenshot From 2025-03-28 12-51-31.png|thumb|"Audio and Video Properties" of "Properties" window of nautilus after fix]]use <code>sudo nano /etc/nixos/configuration.nix</code> and set the environment variable <code>GST_PLUGIN_PATH</code>:<syntaxhighlight lang="nix" line="1">{ config, pkgs, ... }:
{
  environment.systemPackages = with pkgs; [
    gst_all_1.gstreamer
    gst_all_1.gst-plugins-base
    gst_all_1.gst-plugins-good
    gst_all_1.gst-plugins-bad
    gst_all_1.gst-plugins-ugly
    gst_all_1.gst-libav
    gst_all_1.gst-vaapi
  ];
  environment.variables = {
    GST_PLUGIN_PATH = "/run/current-system/sw/lib/gstreamer-1.0/";
  };
}</syntaxhighlight><syntaxhighlight lang="bash">
sudo nixos-rebuild switch
</syntaxhighlight>A system restart is needed to get the environment variable set system wide.