mkchromecast icon indicating copy to clipboard operation
mkchromecast copied to clipboard

Exit after streaming one video stream instead of waiting for ctrl-c?

Open jthigh opened this issue 3 years ago • 4 comments

I'm almost certain I'm missing something in the documentation or command line help, but if I need to only stream one video to a chromcast device from the command line and then exit (e.g. running inside of a bash script), is there a switch to invoke this option?

I can play a test stream using this command: mkchromecast -n "my Friendly Name Here" -y https://www.youtube.com/watch?v=drVQdw6oQ6U --video

but after playing it waits for Ctrl-C input from STDIN, and I want to kill the process and move to another line in a bash script... Thanks for pointing me in the right direction.

jthigh avatar Jan 22 '22 17:01 jthigh

Any update on this? Are there any acceptable hacks to stop casting and/or kill the process quickly after the video has finished?

I really would like to setup mkchromecast on my mediaserver and have it connect to my TV's chromecast on demand and then die. Ideally I would just copy an URL to my phone's clipboard, press a termux shortcut which takes the URL and connects to the mediaserver via SSH to run mkchromecast which exits after the video ends.

I found the following (zsh) shell command to at least kill the previous instance of mkchromecast for it to not block the new cast but this setup still leaves a permanent phantom process hanging on the server...

ssh -t mediaserver killall mkchromecast \; mkchromecast --video -y \''https://www.youtube.com/watch?v=dQw4w9WgXcQ'\'

ssh -t mediaserver killall mkchromecast \; mkchromecast --video -y \'"$(termux-clipboard-get)"\'

Edit: ssh -t enables pseudo-terminal allocation which allows for sending Ctrl+C interrupt signal over the SSH, if the connection is still alive.

drjaska avatar Dec 10 '23 07:12 drjaska

Could this StackOverflow post be helpful in automatically stopping casting after the reported video duration? I tried looking at the mkchromecast source briefly but couldn't find where this could be implemented.

Edit: this requires double checking whether it gets individual video length or combined playlist length. Shutting down after the first video of a playlist would break all playlist compatibility.

drjaska avatar Dec 10 '23 07:12 drjaska

Howdy, and thanks for checking in! I'm in the middle of a pretty significant revamp of the mkchromecast codebase, and there are several bugs that I plan to fix that might be keeping it from exiting when appropriate.

I'm focusing on foundational changes right now, to hopefully make the codebase easier to maintain and less bug-prone than it currently is (see #425, for example). But once I get around to addressing the shutdown issues that I've spotted, I'll check back in here to see whether this has improved.

xsdg avatar Dec 10 '23 23:12 xsdg

Thanks for the update. Hopefully the revamp goes well.

jthigh avatar Feb 18 '24 19:02 jthigh