Skip to content
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

dlna-cast not working in linux #2

Closed
obertugo opened this issue Dec 6, 2023 · 11 comments
Closed

dlna-cast not working in linux #2

obertugo opened this issue Dec 6, 2023 · 11 comments

Comments

@obertugo
Copy link

obertugo commented Dec 6, 2023

Hello and thank you in advance for having done dlna-cast...
I have installed with:
pip install dlna-cast
The program detects my DLNA device perfectly.
The problem arises when I try to run:
dlna-cast screen --dlna_device BF913C44
I think the program cannot find my ffmpeg, this is the error trace:
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 112, in screen
self._start_ffmpeg_streaming(framerate, input_opts, segment_size, crf)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 82, in _start_ffmpeg_streaming
cmd = ' '.join(cmd)
^^^^^^^^^^^^^
TypeError: sequence item 3: expected str instance, NoneType found

Waiting for your prompt attention, I remain at your service to provide you with any details that seem pertinent, again, thank you...!

@link89
Copy link
Owner

link89 commented Dec 6, 2023

I didn't get a chance to test on Linux, so the default option is missing in the current version. However, you can pass your own string if you familiar with ffmpeg via the command line, for example, on Windows you can use

dlna-cast screen --dlna_device BF913C44 --input_opts '-f dshow -i video="screen-capture-recorder":audio="virtual-audio-capturer"'

According to ChatGPT, possible options are:

  • -f x11grab -i :0.0 -f pulse -ac 2 -i default
  • -f x11grab -i :0.0 -f alsa -ac 2 -i hw:0,0

You may use arecord -l to check available devices.

@obertugo
Copy link
Author

obertugo commented Dec 6, 2023

Hello again link89, thanks for your prompt response, the part of the code that generates the empty string error, I think it expects the name of the ffmpeg executable,; I have tried to pass it with:
export FFMPEG_BIN=/usr/bin/ffmpeg and nothing has changed, perhaps due to the difference in the naming between Windows \ / Linux and the slash / and the backslash \ ... And again my thanks in advance.
I'm going to try his suggestions and let him know when I get back from work...

@obertugo
Copy link
Author

obertugo commented Dec 6, 2023

Greetings link89, thanks for your quick response, I tried before going to work:
dlna-cast screen --dlna_device BF913C44 --input_opts '-f x11grab -i :0.0 -f alsa -ac 2 -i hw:0,0'
And this is the result:
HTTP: start to serve at port 35859
Traceback (most recent call last):
File "/home/tugo/.local/bin/dlna-cast", line 8, in
sys.exit(main())
^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 180, in main
Fire(LinuxCast)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
^^^^^^^^^^^^^^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 112, in screen
self._start_ffmpeg_streaming(framerate, input_opts, segment_size, crf)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 82, in _start_ffmpeg_streaming
cmd = ' '.join(cmd)
^^^^^^^^^^^^^
TypeError: sequence item 3: expected str instance, bool found
At least now the string is still not found, but there is a boolean ...

@link89
Copy link
Owner

link89 commented Dec 6, 2023

It looks like fire fail to parse the args correctly. Please try this way (add =)

dlna-cast screen --dlna_device BF913C44 --input_opts='-f x11grab -i :0.0 -f alsa -ac 2 -i hw:0,0'

@obertugo
Copy link
Author

obertugo commented Dec 6, 2023

Sorry but I made a mistake when copying your suggestion, the command without single quotes:
dlna-cast screen --dlna_device BF913C44 --input_opts -f x11grab -i :0.0 -f alsa -ac 2 -i hw:0.0
Returns:
HTTP: start to serve at port 33707
run command: /usr/bin/ffmpeg -framerate alsa hw:0,0 -c:v libx264 -preset fast -tune zerolatency -crf 21 -vf format=yuv420p -keyint_min:v 1 -force_key_frames:v "expr:gte( t,n_forced*2)" -f hls -hls_time 2 -hls_list_size 10 -hls_flags delete_segments /home/tugo/dlna-cast/index.m3u8
Traceback (most recent call last):
File "/home/tugo/.local/bin/dlna-cast", line 8, in
sys.exit(main())
^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 180, in main
Fire(LinuxCast)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
^^^^^^^^^^^^^^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 112, in screen
self._start_ffmpeg_streaming(framerate, input_opts, segment_size, crf)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 84, in _start_ffmpeg_streaming
self._ffmpeg_process = sp.Popen(cmd)
^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.12/subprocess.py", line 1950, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/ffmpeg -framerate alsa hw:0,0 -c:v libx264 -preset fast -tune zerolatency -crf 21 -vf format=yuv420p -keyint_min:v 1 -force_key_frames:v "expr:gte(t,n_forced
2)" -f hls -hls_time 2 -hls_list_size 10 -hls_flags delete_segments /home/tugo/dlna-cast/index.m3u8'
And effectively monitoring in /home/tugo/dlna-cast/
the file index.m3u8 does not exist...

@obertugo
Copy link
Author

obertugo commented Dec 6, 2023

Trying with the command:
dlna-cast screen --dlna_device BF913C44 --input_opts='-f x11grab -i :0.0 -f alsa -ac 2 -i hw:0,0'
Result:
dlna-cast screen --dlna_device BF913C44 --input_opts='-f x11grab -i :0.0 -f alsa -ac 2 -i hw:0,0'
HTTP: start to serve at port 38979
run command: /usr/bin/ffmpeg -framerate 30 -f x11grab -i :0.0 -f alsa -ac 2 -i hw:0,0 -c:v libx264 -preset fast -tune zerolatency -crf 21 -vf format= yuv420p -keyint_min:v 1 -force_key_frames:v "expr:gte(t,n_forced*2)" -f hls -hls_time 2 -hls_list_size 10 -hls_flags delete_segments /home/tugo/dlna-cast/index.m3u8
Traceback (most recent call last):
File "/home/tugo/.local/bin/dlna-cast", line 8, in
sys.exit(main())
^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 180, in main
Fire(LinuxCast)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
^^^^^^^^^^^^^^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 112, in screen
self._start_ffmpeg_streaming(framerate, input_opts, segment_size, crf)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 84, in _start_ffmpeg_streaming
self._ffmpeg_process = sp.Popen(cmd)
^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.12/subprocess.py", line 1950, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 36] File name too long: '/usr/bin/ffmpeg -framerate 30 -f x11grab -i :0.0 -f alsa -ac 2 -i hw:0,0 -c:v libx264 -preset fast - tune zerolatency -crf 21 -vf format=yuv420p -keyint_min:v 1 -force_key_frames:v "expr:gte(t,n_forced
2)" -f hls -hls_time 2 -hls_list_size 10 -hls_flags delete_segments /home/tugo/dlna- cast/index.m3u8'

@obertugo
Copy link
Author

obertugo commented Dec 6, 2023

And finally, from the same command above, but without the single quotes:
dlna-cast screen --dlna_device BF913C44 --input_opts=-f x11grab -i :0.0 -f alsa -ac 2 -i hw:0.0
Result:
HTTP: start to serve at port 43937
run command: /usr/bin/ffmpeg -framerate alsa hw:0,0 -c:v libx264 -preset fast -tune zerolatency -crf 21 -vf format=yuv420p -keyint_min:v 1 -force_key_frames:v "expr:gte( t,n_forced*x11grab)" -f hls -hls_time x11grab -hls_list_size 10 -hls_flags delete_segments /home/tugo/dlna-cast/index.m3u8
Traceback (most recent call last):
File "/home/tugo/.local/bin/dlna-cast", line 8, in
sys.exit(main())
^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 180, in main
Fire(LinuxCast)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
^^^^^^^^^^^^^^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(varargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 112, in screen
self._start_ffmpeg_streaming(framerate, input_opts, segment_size, crf)
File "/home/tugo/.local/pipx/venvs/dlna-cast/lib/python3.12/site-packages/dlna_cast/main.py", line 84, in _start_ffmpeg_streaming
self._ffmpeg_process = sp.Popen(cmd)
^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.12/subprocess.py", line 1950, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/ffmpeg -framerate alsa hw:0,0 -c:v libx264 -preset fast -tune zerolatency -crf 21 -vf format=yuv420p -keyint_min:v 1 -force_key_frames:v "expr:gte(t,n_forced
x11grab)" -f hls -hls_time x11grab -hls_list_size 10 -hls_flags delete_segments /home/tugo/dlna-cast/index.m3u8'

@emk2203
Copy link

emk2203 commented Dec 9, 2023

I am very interested in having this work on linux as well. Unfortunately, I cannot help you with the coding, but if you need a tester, hit me up.

@obertugo
Copy link
Author

Hello link89, I am not a Python programmer, but if you tell me what to do, to debug your program, I will be happy to undertake the task.

I tell you, I ran your program a while ago, in a super user or root session and the result is the same, the index.m3u8 file is not generated.

I am also very interested in your program running on Linux.

Well, waiting for your response, I greet you sincerely...

@link89
Copy link
Owner

link89 commented Dec 13, 2023

I just release a new version 0.1.6 to provide default input options for Linux without audio. I have test this on a Ubuntu 22.04. You may try this new version with pip install -U dlna-cast and see if it works for you.

@obertugo @emk2203

@link89 link89 closed this as completed Dec 13, 2023
@obertugo
Copy link
Author

Greetings @link89 and I can confirm that the program now works, on Void Linux i686 32 bits.
Thank you so much !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants