8000 fix(nix): add GStreamer & PipeWire to build inputs by 0x006E · Pull Request #44 · linkfrg/ignis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(nix): add GStreamer & PipeWire to build inputs #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2024

Conversation

0x006E
Copy link
Contributor
@0x006E 0x006E commented Nov 23, 2024

Currently the recorder service is not working (atleast for me), because python bindings for GStreamer are not included in build-inputs. so this commit adds that

@linkfrg
Copy link
Owner
linkfrg commented Nov 23, 2024

strange, Ignis doesn't require gst-python, it access GStreamer through GObject introspection using pygobject

@0x006E
Copy link
Contributor Author
0x006E commented Nov 23, 2024

Well, this is what I get, and when I add the gst-python bindings, the namespace "Gst" becomes available

File "/nix/store/qb0p0c4l4rj3lh1dc2j74y2s37g1ghn7-python3.12-click-8.1.7/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'config': 'config.py', 'debug': False}
                       └ ()

  File "/nix/store/wll2z2q1pxhmbwbnlvmqjxiij49hfb8z-ignis-0.3+date=20241115_24fd6ab/lib/python3.12/site-packages/ignis/cli.py", line 90, in init
    run_app(config_path, debug)
    │       │            └ False
    │       └ 'config.py'
    └ <function run_app at 0x7f3906ebec00>

  File "/nix/store/wll2z2q1pxhmbwbnlvmqjxiij49hfb8z-ignis-0.3+date=20241115_24fd6ab/lib/python3.12/site-packages/ignis/app.py", line 454, in run_app
    app.run(None)
    │   └ <function Application.run at 0x7f390e92c680>
    └ <app.IgnisApp object at 0x7f3906cd3bc0 (ignis+app+IgnisApp at 0x1e0d2820)>

  File "/nix/store/44n7v64jbkar47zk7nm8mbx36cqxh7y9-python3.12-pygobject-3.48.2/lib/python3.12/site-packages/gi/overrides/Gio.py", line 42, in run
    return Gio.Application.run(self, *args, **kwargs)
           │   │           │   │      │       └ {}
           │   │           │   │      └ (None,)
           │   │           │   └ <app.IgnisApp object at 0x7f3906cd3bc0 (ignis+app+IgnisApp at 0x1e0d2820)>
           │   │           └ gi.FunctionInfo(run, bound=None)
           │   └ <class 'gi.repository.Gio.Application'>
           └ <IntrospectionModule 'Gio' from '/nix/store/fxnchbq09sq279ssqdsgzigsyvp6hz06-glib-2.80.4/lib/girepository-1.0/Gio-2.0.typelib'>

> File "/nix/store/wll2z2q1pxhmbwbnlvmqjxiij49hfb8z-ignis-0.3+date=20241115_24fd6ab/lib/python3.12/site-packages/ignis/app.py", line 292, in do_activate
    __import__(config_filename)
               └ 'config'

  File "/home/nithin/projects/ignis/config.py", line 6, in <module>
    gi.require_version("Gst", "1.0")
    │  └ <function require_version at 0x7f3911439ee0>
    └ <module 'gi' from '/nix/store/44n7v64jbkar47zk7nm8mbx36cqxh7y9-python3.12-pygobject-3.48.2/lib/python3.12/site-packages/gi/__...

  File "/nix/store/44n7v64jbkar47zk7nm8mbx36cqxh7y9-python3.12-pygobject-3.48.2/lib/python3.12/site-packages/gi/__init__.py", line 122, in require_version
    raise ValueError('Namespace %s not available' % namespace)
                                                    └ 'Gst'

ValueError: Namespace Gst not available

config file supplied is

import gi
gi.require_version('Gst', '1.0')

I can close this PR and add a issue, if this is not the right fix.

@linkfrg
Copy link
Owner
linkfrg commented Nov 23, 2024

Well, this is what I get, and when I add the gst-python bindings, the namespace "Gst" becomes available

Does recording itsekf work (start/stop)?

I can close this PR and add a issue, if this is not the right fix.

I am not nix user, so probably will not fix it

@0x006E
Copy link
Contributor Author
0x006E commented Nov 24, 2024

Well, this is what I get, and when I add the gst-python bindings, the namespace "Gst" becomes available

Does recording itsekf work (start/stop)?

No, actually the config errors out saying GStreamer not found.

> File "/nix/store/wll2z2q1pxhmbwbnlvmqjxiij49hfb8z-ignis-0.3+date=20241115_24fd6ab/lib/python3.12/site-packages/ignis/app.py", line 292, in do_activate
    __import__(config_filename)
               └ 'config'

  File "/home/nithin/projects/ignis/config.py", line 1, in <module>
    from ignis.services.recorder import RecorderService

  File "/nix/store/wll2z2q1pxhmbwbnlvmqjxiij49hfb8z-ignis-0.3+date=20241115_24fd6ab/lib/python3.12/site-packages/ignis/services/recorder/__init__.py", line 2, in <module>
    from .service import RecorderService

  File "/nix/store/wll2z2q1pxhmbwbnlvmqjxiij49hfb8z-ignis-0.3+date=20241115_24fd6ab/lib/python3.12/site-packages/ignis/services/recorder/service.py", line 11, in <module>
    from ._imports import Gst

  File "/nix/store/wll2z2q1pxhmbwbnlvmqjxiij49hfb8z-ignis-0.3+date=20241115_24fd6ab/lib/python3.12/site-packages/ignis/services/recorder/_imports.py", line 10, in <module>
    raise GstNotFoundError(
          └ <class 'ignis.exceptions.GstNotFoundError'>

ignis.exceptions.GstNotFoundError: ('GStreamer not found! To use the recorder service, install GStreamer', 'GStreamer not found! To use the recorder service, install GStreamer.')

The underlying error is Gst namespace is not available.

I can close this PR and add a issue, if this is not the right fix.

I am not nix user, so probably will not fix it

This was my mistake, gst-python is not needed, but the namespace Gst only becomes available when Gstreamer is present (pkgs.gst_all_1.gstreamer) in the buildInputs. After reading through the packaging section on nixpkgs, I see that there is no attribute in mkDerivation called "runtimeInputs", (it only exists of writeShellApplicaition), the buildInputs attribute is what is used to supply runtime dependencies to the package.

I would like to keep this PR open, so that after I fix other issues ( pipewire gst plugin not visible ), I could contribute.

@0x006E
Copy link
Contributor Author
0x006E commented Nov 26, 2024

@linkfrg These dependencies seems to solve the dependency issues for me.

  • Added pipewire for gst-plugin, in nixos, there is no separate package that provides this plugin, pipewire package itself does this
  • Added gst-plugin-bad. I'm not sure why this is the case, but for me the recorder fails with no h264parse if gst-plugins-bad is not included, I checked the source of gst-plugins-bad and it contains openh264 extension.
  • Removed runtimeInputs, this does not exist for mkDerivation, only for writeShellApplication which this package does not use
  • Moved everything from runtimeInputs to buildInputs.

Even after solving this dep issue, the recorder seems to hang for me. The XDG portal opens to share the screen and after accepting that ignis becomes unresponsive. I had to kill the process to stop it. so nothing is being saved. But this may be related to another issue

You can test this build by using

nix run "git+https://github.com/0x006e/ignis?ref=patch-1&submodules=1" -- init -c /path/to/config/file

@linkfrg
Copy link
Owner
linkfrg commented Nov 27, 2024

I get error when trying to record internal audio or audio from microphone:

from ignis.services.recorder import RecorderService

recorder = RecorderService.get_default()

recorder.start_recording(record_internal_audio=True)
2024-11-27 20:58:40 [ERROR] TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Traceback (most recent call last):

  File "/nix/store/zlx58nx4jrl0klnq42ah5n5c2j2x531n-ignis-0.3+date=20241126_173e4ca/bin/.ignis-wrapped", line 5, in <module>
    main()
    └ <function main at 0x78e336dacf40>

  File "/nix/store/zlx58nx4jrl0klnq42ah5n5c2j2x531n-ignis-0.3+date=20241126_173e4ca/lib/python3.12/site-packages/ignis/main.py", line 12, in main
    cli(prog_name="ignis")
    └ <OrderedGroup cli>

  File "/nix/store/qb0p0c4l4rj3lh1dc2j74y2s37g1ghn7-python3.12-click-8.1.7/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           │    │     │       └ {'prog_name': 'ignis'}
           │    │     └ ()
           │    └ <function BaseCommand.main at 0x78e334dff060><OrderedGroup cli>

  File "/nix/store/qb0p0c4l4rj3lh1dc2j74y2s37g1ghn7-python3.12-click-8.1.7/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         │    │      └ <click.core.Context object at 0x78e332d2b0e0>
         │    └ <function MultiCommand.invoke at 0x78e334c102c0><OrderedGroup cli>

  File "/nix/store/qb0p0c4l4rj3lh1dc2j74y2s37g1ghn7-python3.12-click-8.1.7/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           │               │       │       │      └ <click.core.Context object at 0x78e332ea0c20>
           │               │       │       └ <function Command.invoke at 0x78e334dffc40>
           │               │       └ <Command init>
           │               └ <click.core.Context object at 0x78e332ea0c20><function MultiCommand.invoke.<locals>._process_result at 0x78e33786d6c0>

  File "/nix/store/qb0p0c4l4rj3lh1dc2j74y2s37g1ghn7-python3.12-click-8.1.7/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │   │      │    │           │   └ {'config': '/home/link/Documents/asd.py', 'debug': False}
           │   │      │    │           └ <click.core.Context object at 0x78e332ea0c20>
           │   │      │    └ <function init at 0x78e332d64220>
           │   │      └ <Command init>
           │   └ <function Context.invoke at 0x78e334dfe5c0><click.core.Context object at 0x78e332ea0c20>

  File "/nix/store/qb0p0c4l4rj3lh1dc2j74y2s37g1ghn7-python3.12-click-8.1.7/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'config': '/home/link/Documents/asd.py', 'debug': False}
                       └ ()

  File "/nix/store/zlx58nx4jrl0klnq42ah5n5c2j2x531n-ignis-0.3+date=20241126_173e4ca/lib/python3.12/site-packages/ignis/cli.py", line 90, in init
    run_app(config_path, debug)
    │       │            └ False
    │       └ '/home/link/Documents/asd.py'<function run_app at 0x78e332d66c00>

  File "/nix/store/zlx58nx4jrl0klnq42ah5n5c2j2x531n-ignis-0.3+date=20241126_173e4ca/lib/python3.12/site-packages/ignis/app.py", line 454, in run_app
    app.run(None)
    │   └ <function Application.run at 0x78e334c2c680><app.IgnisApp object at 0x78e332b4fe00 (ignis+app+IgnisApp at 0x2dfb0410)>

  File "/nix/store/44n7v64jbkar47zk7nm8mbx36cqxh7y9-python3.12-pygobject-3.48.2/lib/python3.12/site-packages/gi/overrides/Gio.py", line 42, in run
    return Gio.Application.run(self, *args, **kwargs)
           │   │           │   │      │       └ {}
           │   │           │   │      └ (None,)
           │   │           │   └ <app.IgnisApp object at 0x78e332b4fe00 (ignis+app+IgnisApp at 0x2dfb0410)>
           │   │           └ gi.FunctionInfo(run, bound=None)
           │   └ <class 'gi.repository.Gio.Application'><IntrospectionModule 'Gio' from '/nix/store/fxnchbq09sq279ssqdsgzigsyvp6hz06-glib-2.80.4/lib/girepository-1.0/Gio-2.0.typelib'>

> File "/nix/store/zlx58nx4jrl0klnq42ah5n5c2j2x531n-ignis-0.3+date=20241126_173e4ca/lib/python3.12/site-packages/ignis/app.py", line 292, in do_activate
    __import__(config_filename)
               └ 'asd'

  File "/home/link/Documents/asd.py", line 5, in <module>
    recorder.start_recording(record_internal_audio=True)
    │        └ <function RecorderService.start_recording at 0x78e331112200><service.RecorderService object at 0x78e332b67980 (ignis+services+recorder+service+RecorderService at 0x2e38a830)>

  File "/nix/store/zlx58nx4jrl0klnq42ah5n5c2j2x531n-ignis-0.3+date=20241126_173e4ca/lib/python3.12/site-packages/ignis/services/recorder/service.py", line 207, in start_recording
    audio_pipeline, self._audio.speaker.name + ".monitor"
    │               │    │      │       └ 'speaker'
    │               │    │      └ <GObject Property speaker (PyObject)>
    │               │    └ <service.AudioService object at 0x78e33110f300 (ignis+services+audio+service+AudioService at 0x2e0a3630)>
    │               └ <service.RecorderService object at 0x78e332b67980 (ignis+services+recorder+service+RecorderService at 0x2e38a830)>''

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Looks like there is some problem with AudioService...

@0x006E
Copy link
Contributor Author
0x006E commented Nov 28, 2024

I'm having a hard time debugging this. I have no experience working with PyGObject. @linkfrg any idea where to start?

@linkfrg
Copy link
Owner
linkfrg commented Dec 1, 2024

I'm having a hard time debugging this. I have no experience working with PyGObject. @linkfrg any idea where to start?

Looks like AudioService doesn't work properly on Nix, probably some issue with Gvc, it doesn't detect any audio devices

e.g.:

from ignis.services.audio import AudioService

audio = AudioService.get_default()

print(audio.speakers)

Returns an empty list:

2024-12-02 00:00:36 [INFO] Using configuration file: /home/link/Documents/asd.py
[]
2024-12-02 00:00:38 [INFO] Ready.

@linkfrg linkfrg added the nix Related to the Nix package manager label Dec 1, 2024
@linkfrg linkfrg changed the title fix(nix): add GStreamer python bindings to build inputs fix(nix): add GStreamer & PipeWire to build inputs Dec 1, 2024
@linkfrg
Copy link
Owner
linkfrg commented Dec 1, 2024

Okay, I will merge this anyway, the issue with AudioService and Gvc should be fixed separately

@linkfrg linkfrg merged commit 342a4bf into linkfrg:main Dec 1, 2024
@0x006E 0x006E deleted the patch-1 branch December 10, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nix Related to the Nix package manager
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0