[mythtv-users] convoluted questiom

James jam at tigger.ws
Tue Dec 28 22:39:24 UTC 2021

> On 28 Dec 2021, at 6:03 pm, Stephen Worthington <stephen_agent at jsw.gen.nz> wrote:
> On Mon, 27 Dec 2021 10:49:18 +0800, you wrote:
>>> I just had a quick look at the Services API and it appears that there
>>> is no API to start a recording in the manner that you do for Live TV,
>>> where it starts immediately and continues until you stop it.  What is
>>> needed is a call to GetRecordSchedule using the option that gets the
>>> template rule that you want to use (eg 'Default'), then modify that to
>>> set up a new recording rule, and call AddRecordSchedule to add it to
>>> the schedule.  Then at the scheduled time, it will start recording. My
>>> experience with manually starting and stopping scheduled recordings is
>>> that if the starttime in the recording rule is in the past, and the
>>> endtime is in the future, the recording can be restarted.  So I would
>>> hope that setting the starttime to a little in the past and calling
>>> AddRecordSchedule would immediately start recording.  But I would need
>>> to test that.  If not, then a ReactivateRecording call would be needed
>>> to get it to start recording.  All of which is a bit complicated for
>>> what you want, but it looks doable.
>>> However, the Sensoray 2263 is not likely to have MythTV support as a
>>> capture device unless it has Linux V4L drivers.  The web page I found
>>> says Linux is supported, but whether that means V4L support I am not
>>> sure.  I suspect not.  So supporting it would likely mean also writing
>>> an External Recorder program to interface between the Sensoray 2263
>>> API and MythTV.  Something like what MythHDRecorder does with Silicon
>>> Dust HDHR devices:
>>> https://www.mythtv.org/wiki/Mythhdhrrecorder
>>> That is a bit more work, but again likely doable.
>> Stephen Thanks. The 2263 does have v4l2 support and does indeed work.
> I have wanted for some time to have a quick way of starting manual
> recordings so that I can test the performance of my MythTV boxes and
> stress test them.  Then you asked about this and that prompted me to
> think about exactly how it might be done.  So I have spent some time
> over the last couple of days creating a "proof of concept" Python
> program to do that, based on what might work for you.  I have put a
> copy of my initial working version (0.1) on my web server here:
> http://www.jsw.gen.nz/mythtv/start-recording.py
> What it does is to create a manual recording rule with the start time
> set to the current time and the end time set to six hours later.  The
> recording is instantly started by mythbackend, and the recordid (index
> of the recording rule in the record table) is reported back.  With the
> current default settings, the title of the rule and the recording it
> makes is set to "Dive Cam (Manual Record)".  There are command line
> options to set the title and add an optional subtitle, and also to
> select the MythTV channel to be recorded.  But you would want to set
> the default values you need for all those things in the
> "Configuration" section at the top of the code, so that simply running
> "start-recording.py" from a command line will start a recording.  If
> the Sensoray 2263 capture card in MythTV is set up with multirec
> available, you can record to multiple different recordings at once, so
> you could start a new recording before the previous one stops after
> its default duration of 6 hours.
> To install it download a copy to your /usr/local/bin directory and do
> chmod +x on it.  Change the default settings in the "Configuration"
> section - at the very least, you will need to set the CHANID value to
> the chanid for the Sensoray 2263 device.  Then run it using the "-n"
> dry run option.  You may get exceptions about missing Python modules -
> install the correct modules and dry run it again until it reports that
> the dry run worked.  If you can not get it to work, you can set the
> DEBUG_OUTPUT option to True and send me a copy of what all the debug
> code I have left in it says.
> The way it creates its recording rules is to copy from a template rule
> and then make changes to the copy.  It is currently set to use the
> Default template.  So if you have specific settings you want in the
> recording rules it creates, you can create a new template rule with
> those settings, and change the TEMPLATE configuration option to make
> it copy from that template.
> It will run from any PC that has network access to the MythTV box -
> just install a config.xml file that points back to the MythTV box, and
> install the MythTV Python packages.
> There are likely to be various ways it could still fail that it will
> not handle well as I have not tried to test all the possible code
> paths and error handling yet.  If you get anything like that, please
> forward a copy of any exception messages.
> I have not tried to write a corresponding "stop-recording.py" yet - to
> stop any recording started by "start-recording.py", you will need to
> go to the upcoming recordings list and stop it from there, then
> manually delete the recording rule as well if you want to.  Old manual
> recording rules set to do a single record should be cleaned up by
> mythbackend automatically after their "endtime" elapses - it may only
> happen when the housekeeper task does one of its 3-4 times a day runs
> after the rule expires.  But I have not checked to see if that does
> happen with recording rules created by "start-recording.py".
> There is probably some redundant code - I just copied bits of my
> existing Python MythTV code to patch this program together.  If it is
> useful to you I can clean it up later, and incorporate anything
> specific that you might need.

I had a query. Lots of people gave very useful ideas, but you went to a huge effort with a useable end tool not even proof-of-concept. Thank you lots.

More information about the mythtv-users mailing list