link89 / dlna-cast

A cross-platform command-line tool that casts screen and media file to remote DLNA device.
GNU General Public License v3.0
28 stars 1 forks source link

dlna-cast not working in linux #2

Closed obertugo closed 6 months ago

obertugo commented 7 months ago

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 commented 7 months ago

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:

You may use arecord -l to check available devices.

obertugo commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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_forced2)" -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_forced2)" -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 commented 7 months ago

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_forced2)" -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_forced2)" -f hls -hls_time 2 -hls_list_size 10 -hls_flags delete_segments /home/tugo/dlna- cast/index.m3u8'

obertugo commented 7 months ago

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_forcedx11grab)" -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_forcedx11grab)" -f hls -hls_time x11grab -hls_list_size 10 -hls_flags delete_segments /home/tugo/dlna-cast/index.m3u8'

emk2203 commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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

obertugo commented 6 months ago

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