alexballas / go2tv

Cast media files to UPnP/DLNA Media Renderers and Smart TVs.
MIT License
504 stars 50 forks source link

CLI not working on Windows? #63

Closed EZTechhelp closed 1 year ago

EZTechhelp commented 1 year ago

Hello,

First, excellent work on this utility. its exactly what I want, simple and lightweight. I'm baffled how hard it has been to find something that's not some huge Media Server/SDK for simple casting.

Anyway, I cant seem to get go2tv to work at all in command line mode on Windows 10. GUI mode works just fine.

I'm able to find my device fine using go2tv.exe -l

Results

Device 1
--------
Model: [LG] webOS TV NANO85UNA
URL:   http://192.168.50.231:1688/

Then I've tried running this from command line

go2tv.exe -t http://192.168.50.231:1839 -v c:\TheHobbit.mp4

I get this error

Encountered error(s): interactive screen error: The handle is invalid.

I've tried using a Media URL instead of a local file, get the same error.

If I use the GUI and select the same file and select the device which shows under Select Device, and hit Play, it works great

I'm wondering if I'm just missing some simple syntax. I've also tried adding -tc and made sure ffmpeg is installed but no difference.

I've tried 2 machines on my network (both Windows 10) with the same result. Any ideas?

Thanks!

alexballas commented 1 year ago

Hello! Thanks for taking the time to raise it. This looks like a windows specific error. I'll try to replicate and let you know

alexballas commented 1 year ago

Could please omit the -t option and just run go2tv.exe -v c:\TheHobbit.mp4. Do you still get the same error?

EZTechhelp commented 1 year ago

Thanks for the reply

I just tried it without -t but unfortunately the same error occurs

Results

Encountered error(s): interactive screen error: The handle is invalid

Something else that I'm not sure if it could be related or not but wanted to mention. I'm unable to execute go2tv directly from cmd or Powershell and get any output. In order to see any output, I have to use the following syntax (here in Powershell)

go2tv -v c:\TheHobbit.mp4 | out-string

If I dont add the out-string pipe, nothing ever outputs to console. Must have something to do with how it writes to stnd output?

Alternatively this also works in powershell to get output written to a file (though doesn't output to console)

Start-process 'go2tv.exe' -ArgumentList '-v c:\TheHobbit.mp4' -RedirectStandardOutput "c:\logs\go2tv_standard.log"  -RedirectStandardError "c:\logs\go2tv_error.log"

Here is another example using .NET directly in PS. This will output standard and errors to console. So it appears to only work if using output redirection. I dont know anything about go so not sure if any of this information is helpful but sharing it all the same

$process = [System.Diagnostics.Process]::new()
$process.StartInfo.FileName = 'go2tv.exe'
$process.StartInfo.Arguments = '-v c:\TheHobbit.mp4'
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
$process.Start()
[console]::WriteLine($process.StandardOutput.ReadToEnd())
[console]::WriteLine($process.StandardError.ReadToEnd())
$process.WaitForExit()

Unfortunately any of these methods results in the same original error. I just had to get a bit creative to finally get any output to know what was going on

alexballas commented 1 year ago

I have the feeling that the reason you can't get any media playback is the fact that there is no attached console to the application. When I first built the application for Windows, there was a command prompt appearing when I double clicked the app. The solution to that was to use the "windowsgui" flag during compilation. I didn't realize that this flag would cause issues with ability to pass arguments from cmd. I’m a Linux user myself and nobody raised it until now. There is no clean way to both get a “prompt-less” GUI and a fully working command line. I did find some workarounds online, but I need to invest some more time into it.

I compiled the latest stable version without this flag just to confirm if this is what is causing the "The handle is invalid" error. Could you please test it and let me know if that fixes it? go2tv.zip

EZTechhelp commented 1 year ago

Ah ok that makes sense. I had wondered if there were little to few Windows users. Honesty, for my needs I don't really need any gui at all since I want to incorporate it into automation script/app. So if I can use it 100% command-line, that is perfect for me!

I just tested the upload you provided and I'm happy to say it now works as expected! I tested quickly with go2tv -v c:\TheHobbit.mp4 and casting started and worked first attempt. This is great!

I was also able to still use the GUI without any issue as well

I'll do some more extensive testing in a day or so (such as casting URLs and trying transcoding with -tc..etc) but otherwise this version looks like it will solve my issue. Can't thank you enough!

alexballas commented 1 year ago

No worries, glad this fixed the issue. I also have https://github.com/alexballas/go2tv/tree/main/cmd/go2tv-lite which is an ever lighter version. No gui and no ability to use hot keys in the CLI. Just raw streaming. Also pasting it here in case you want to use that instead. go2tv-lite.zip

EZTechhelp commented 1 year ago

Oh wow, now I feel kind of silly for not seeing that! That is actually exactly what I was looking for! Thank you!

One last question and this is a bit off topic but, is there a way to transcode with ffmpeg and pass parameters to it through go2tv when casting from URLs? Such as if I want to change the encoding format or other parameters?. I'm doing some streaming through libvlc and I'm having a lot of trouble with its transcoding while also streaming via HTTP. If I can bypass transcoding at all with libvlc and instead do so while casting through go2tv, that would simplify my life significantly!

alexballas commented 1 year ago

Transcoding in Go2TV with URLs works by passing the http stream through pipes to the ffmpeg command as seen here https://github.com/alexballas/go2tv/blob/main/utils/transcode_windows.go#L24-L45. It's all hard coded as the goal of the app is to provide an easy way for everyone to stream stuff. If you have some specific ffmpeg parametres in mind you can change the code in that part and recompile.

EZTechhelp commented 1 year ago

Ah ok understood and makes sense. I haven't ever compiled with go before so it will be a good learning exercise at least.

Thanks again!

alexballas commented 1 year ago

Nothing further to do in this issue. Resolving.

alexballas commented 7 months ago

go2tv_1.15.zip

EZTechhelp commented 7 months ago

Thank you so much for including an updated build!