Prevent Auto shutdown Whilst streaming

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
hex1
Newcomer
Posts: 1
Joined: Wed Dec 04, 2019 1:59 pm
Great Britain

Prevent Auto shutdown Whilst streaming

Post by hex1 » Wed Dec 04, 2019 2:04 pm

I have myth tv set to shutdown whilst nothing is being recorded in order to help save power however whilst streaming content it likes to shut itself down because it isnt recording anything, is the any way to detect that someone is streaming and prevent the auto shutdown?
Thanks in advance

wmorrison
Junior
Posts: 59
Joined: Sat Dec 01, 2018 12:05 am
United States of America

Re: Prevent Auto shutdown Whilst streaming

Post by wmorrison » Thu Dec 05, 2019 4:29 pm

Streaming how? In a program external to MythTV? (Chrome browser, etc?)

Yes, you can do it, if you launch the external program via a script. Use mythshutdown --lock before you launch the program, and mythshutdown --unlock after. Don't launch anything in your script with '&' at the end of the command so it waits for each command to complete in sequence. (lock, stream, unlock.)

However, if you integrate this script into the MythTV menus, you can launch it asynchronously ('&' at end.) You have to escape the '&' in the menu xml but I don't remember the syntax.

If you don't launch the script asynchronously, mythfrontend will "freeze" until your script ends. If you do launch it asynchronously, you can alt-tab back to mythfrontend if necessary (nice to pause streaming and switch over to set up a recording, etc.)

Be careful of scripts erroring out and not getting to unlock, leaving your machine on until you manually unlock it (from command line or mythwelcome menu.)

I've done this with Chrome browser. Integrated into main menu, machine won't shut down while running Chrome. I'll have to look at my machine tonight to get the details if you need them.

wmorrison
Junior
Posts: 59
Joined: Sat Dec 01, 2018 12:05 am
United States of America

Re: Prevent Auto shutdown Whilst streaming

Post by wmorrison » Thu Dec 05, 2019 4:33 pm

Also, be aware that the "lock" is a counter. If you lock twice, you have to unlock twice. This means you can run multiple scripts concurrently that lock shutdown, as long as they do one lock at the beginning and one unlock at the end, and MythTV should keep track of how many locks there are.

User avatar
pgbennett
Developer
Posts: 322
Joined: Mon Apr 27, 2015 5:41 pm
United States of America

Re: Prevent Auto shutdown Whilst streaming

Post by pgbennett » Thu Dec 05, 2019 5:50 pm

I recently added an API call to mythbackend master, that will delay shutdown 5 minutes. It is used by the "leanfront" android frontend, which calls it every 4 minutes to prevent shutdown. If you are writing a frontend application you can use that, or you can call it from a script every 4 minutes. This has the advantage that if your application shuts down or the script stops calling it, the normal shutdown can continue. You do not have to remember to unlock.

User avatar
bill6502
Developer
Posts: 1408
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Prevent Auto shutdown Whilst streaming

Post by bill6502 » Thu Dec 05, 2019 6:18 pm

Just added the above to the Wiki: https://www.mythtv.org/wiki/Myth_Service. Note that it's a POST.

Post Reply