Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPTV Multirec Scheduling not working #1053

Closed
angelaschmid opened this issue Mar 3, 2025 · 18 comments
Closed

IPTV Multirec Scheduling not working #1053

angelaschmid opened this issue Mar 3, 2025 · 18 comments

Comments

@angelaschmid
Copy link
Contributor

  • MythTV version: v36-pre/master (issue also exists on v35)

Multiple recordings with an IPTV input connection is not working. Max Recordings (Interactions Between Inputs) is set to 8.

capturecard.csv
inputgroup.csv

Multirec with DVB works.

@kmdewaal
Copy link
Contributor

kmdewaal commented Mar 4, 2025

@gigem can you please have a look at how this can be done? I did have a look myself a while ago but it is not obvious to me where and how to make changes. I try to stay close to the DVB tuner model where a capture card is connected to at most one video source.

@angelaschmid
Copy link
Contributor Author

angelaschmid commented Mar 4, 2025

Just noticed that back to back recordings worked, same channel with two programs with modified start/end offset, therefor overlapping and recording at the same time.

@jpoet
Copy link
Member

jpoet commented Mar 4, 2025

Just noticed that back to back recordings worked, same channel with two programs with modified start/end offset, therefor overlapping and recording at the same time.

Are you receiving a Transport Stream via IPTV? I would expect you to be able to record from any "programs" within that Transport Stream. If instead, you are wanting to record simultaneous programs which are not in the same Transport Stream, then you would need a separate recorder/input for each one.

@angelaschmid
Copy link
Contributor Author

HLS using tcp or udp:

Capture card #71: https://api.init7.net/tvchannels.m3u

#EXTM3U
#EXTINF:0001 tvg-id="SRF1.ch" tvg-chno="90001" group-title="German" tvg-logo="https://images.zattic.com/logos/d0b44da81b954a5fb01c/black/210x120.png", SRF 1 HD
http://192.168.1.11:5000/api/zch/live/sf-1
#EXTINF:0001 tvg-id="SRF2.ch" tvg-chno="90002" group-title="German" tvg-logo="https://images.zattic.com/logos/419de2ea55351056b116/black/210x120.png", SRF zwei HD
http://192.168.1.11:5000/api/zch/live/sf-2

Capture card #81: https://api.init7.net/tvchannels.m3u?rp=true (not included in the original posts .csv files)

#EXTM3U
#EXTINF:0 tvg-logo="https://api.tv.init7.net/media/logos/1102_SRF1.ch.png" tvg-name="SRF1.ch" group-title="chde", SRF 1
udp://@233.50.230.80:5000
#EXTINF:0 tvg-logo="https://api.tv.init7.net/media/logos/1104_SRFzwei.ch.png" tvg-name="SRFzwei.ch" group-title="chde", SRF zwei
udp://@233.50.230.212:5000

I can simultaneously record one program on each of the capture cards, each having it's own video source (same program data but different source-id) and input connection.
What I would like is to record multiple programs on different channels on a capture card.

@angelaschmid angelaschmid changed the title IPTV Multirec not working IPTV Multirec Scheduling not working Mar 5, 2025
@angelaschmid
Copy link
Contributor Author

Maybe I wrote this issue without emphasizing that multiple IPTV recordings are not the problem; the actual issue is that scheduling isn't working.

After interpreting the following:
https://github.com/MythTV/mythtv/blame/e59ad8a4fe7ec021f1118e78a77b5aadca6d8a42/mythtv/programs/mythbackend/scheduler.cpp#L1125

When mplexid=0 it allows recording only when the two to be compared chanid's are the same.

After setting mplexid=1 for the IPTV channels, I was able to multirecord different channels on the same capture card.

Looking at scheduler.cpp it seems it additionally takes the sourceid in consideration, but not the capture capture capabilities (DVB,IPTV,other cards) and reduces it to only checking the DVB mplex, and when not set (mplexid==0), limiting it to allow scheduling only on the same channel.

To not over-complicate the source the IPTV channel scan could set the mplexid=-1 or null, making it clear it is not an DVB mplex, however that crashed mythbackend during startup. Either choose =1 or maybe a sentinel value.

mplexid=0 would still work for all other cards, possible those who anyway do not allow or are not capable of multirecording different channels.

@kmdewaal
Copy link
Contributor

kmdewaal commented Mar 5, 2025

Hi @angelaschmid I am not able to reproduce IPTV multirec for different channels on the same capture card.

For this test I did the following:

  • set mplexid to 1 for all iptv channels in the multiplex
  • in scheduler.cpp:1125 comment out the expression and hard-code "bool mplexid = true;"
    What happens is that as soon as I start the second, overlapping, recording then the first recording is terminated.

What does work for me is having one video source and multiple capture cards connecting to that single video source; then I can record as many channels simultaneously as there are capture cards.

The way how it works with the DVB multirec is there is for each additional recording a virtual capture card created which then gets a copy of the data received by the one and only physical capture card.
For each recording you do need a capture card, either a physical or a virtual one.
I think this is also true for IPTV multirec.

So I think that what we need for IPTV multirec is to use the existing mechanism that creates virtual capture cards but for IPTV multirec it must get the data from IP just like the real capture card instead of getting a copy of the data of the real capture card.

@angelaschmid
Copy link
Contributor Author

I had the virtual capture cards configured with the web-setup: Max Recordings (Interactions Between Inputs) is set to 8

As I have two IPTV capture cards (tcp and udp) I could run 15 (not 16) simultaneous recordings.

One culprit I found was that schedorder needs to have a value other than 0, otherwise the virtual capture card is disabled.
I was just lucky that I had it setup for one capture card, maybe set by hand, to notice it's importance. I am not sure, but this might need an update of the web-setup.

Why 15 instead of 16: I haven't figured that out:

2025-03-06 03:21:52.350948 I [155088/155137] TVRecEvent tv_rec.cpp:1765:HandlePendingRecordings  TVRec[78]: ASK_RECORDING 78 0 0 0
2025-03-06 03:21:52.361844 I [155088/155131] TVRecEvent tv_rec.cpp:1765:HandlePendingRecordings  TVRec[72]: ASK_RECORDING 72 0 0 0
2025-03-06 03:21:52.378732 I [155088/155134] TVRecEvent tv_rec.cpp:1765:HandlePendingRecordings  TVRec[75]: ASK_RECORDING 75 0 0 0
2025-03-06 03:21:52.385414 I [155088/155133] TVRecEvent tv_rec.cpp:1765:HandlePendingRecordings  TVRec[74]: ASK_RECORDING 74 0 0 0
2025-03-06 03:21:52.539959 I [155088/155135] TVRecEvent tv_rec.cpp:1765:HandlePendingRecordings  TVRec[76]: ASK_RECORDING 76 0 0 0
2025-03-06 03:21:52.807769 I [155088/155132] TVRecEvent tv_rec.cpp:1765:HandlePendingRecordings  TVRec[73]: ASK_RECORDING 73 0 0 0
2025-03-06 03:21:52.897802 I [155088/155130] TVRecEvent tv_rec.cpp:1765:HandlePendingRecordings  TVRec[71]: ASK_RECORDING 71 0 0 0
2025-03-06 03:21:56.059843 E [155088/155136] TVRecEvent tv_rec.cpp:4027:TuningSignalCheck  TVRec[77]: TuningSignalCheck: Hit pre-fail timeout
2025-03-06 03:21:57.061511 W [155088/155136] TVRecEvent tv_rec.cpp:4055:TuningSignalCheck  TVRec[77]: TuningSignalCheck: taking more than 5000 ms to get a lock. marking this recording as 'Failing'.

When stopping another recording, I could restart the recording, without any further issues.

There might be a MythTV limitation of the available sockets, maybe there is a MythTV http connection pool/manager.

Another issue I found, during having these 15 recordings simultaneous running, I had some additional conflicting recordings, after I stopped some recordings, and restarted the conflicting recordings, they started, even that the max recordings was surpassed, they failed at the end. Somehow the scheduler did not check continuously for conflicts. Maybe it does not reschedule failed recordings, to set it to conflicting, as there is only one status, and just starts the recording on a restart.

What I also noticed, as I have three input sources (DVB: 4x, IPTV tcp, IPTV udp), the failed or conflicting scheduled recordings, never changed the capture card, e.g. moving from IPTV tcp to IPTV udp. With DVB it changes the capture card, maybe it is related to the sourceid, which is the same for the DVB cards. Maybe to have this working I would need to configure to use only on input source for the capture cards. I mention this, because during adding a recording, say for a "tcp" channel, it used a "udp" channel, but during reschedule conflicts it does not change anymore. Maybe I am talking about failed recordings, as said before they are not rescheduled.

The mentioned issues are complaints on a very high level (live is too short to view so many recordings), and for sure would need some further investigation.

@gigem
Copy link
Contributor

gigem commented Mar 6, 2025

@gigem can you please have a look at how this can be done? I did have a look myself a while ago but it is not obvious to me where and how to make changes. I try to stay close to the DVB tuner model where a capture card is connected to at most one video source.

Sorry for the slow response. My internet has been fubar for most of the last two days due to storm damage. I hope to get it fully fixed this afternoon.

I'll try to look tomorrow or over the weekend. It's going to depend on how the IPTV recorder was designed. If it was originally derived from the DVB recorder, it might just need a small tweak. If not, it could be a much bigger task. As an alternative, John Poet's black-box, external recorder can be used for IPTV. I know it supports multirec.

@kmdewaal
Copy link
Contributor

kmdewaal commented Mar 6, 2025

A bit of context might be useful.

The typical IPTV stream is a single program transport stream so it is a transport stream but with one video stream, one audio stream and sometimes a few subtitle streams. Sometimes there is the possibility to select one of many video streams but these then have a different bitrate/quality but it is the same program. MythTV always selects the stream with the highest bitrate.

To play around with this, do create an IPTV capture card and a videosource and use for example
https://iptv-org.github.io/iptv/categories/cooking.m3u (found on https://github.com/iptv-org/iptv/) for a number of cooking channels. MythTV cannot receive all of them due to either the format, encryption or geofencing but a number of them play OK. This is what I use for testing.

A minimal configuration consists of one capture card (in which the URL is specified) connected to one video source.
After the channel scan is done this can receive one channel.

What we want to achieve is that we can receive multiple channels simultaneously and that the capture cards for these additional channels are created automatically. This similar to what is done for DVB multirec.
The difference is that the virtual/child capture card for IPTV needs to be a full-feature capture card that can receive a channel independent of the other channels. The similarity with the virtual/child capture cards for DVB multirec is that there is no hardware needed for a new virtual/child capture card.

Angela reports that she gets it running with only a few hacks (setting schedorder to a value > 0, setting mplexid to 1 and pre-creating the virtual tuners) and this sounds promising but I have not been able to reproduce this.

@kmdewaal
Copy link
Contributor

kmdewaal commented Mar 7, 2025

Angela reports that she gets it running with only a few hacks (setting schedorder to a value > 0, setting mplexid to 1 and pre-creating the virtual tuners) and this sounds promising but I have not been able to reproduce this.

I can now reproduce this. Had missed the mplexid of one channel. This then caused the termination of the first recording when starting the second recording.

@gigem
Copy link
Contributor

gigem commented Mar 8, 2025

@angelaschmid, how did you configure the 8 recordings setting? Did you do it through the web UI or mythtv-setup?
According to CardUtil::IsTunerSharingCapable(), the IPTV recorder does not support multirec. If you did it through the the web UI, that should not be allowed and is a bug. mythtv-setup should likewise not allow it but there is misfeature that can allow it if the tuner type is changed.

As for the IPTV recorder not currently supporting multirec, in theory, it can and probably should. Making it do so, however, will require some refactoring. I don't remember all of the details but at a minimum, it needs to support the concept of a "master" channel. Look at dvbchannel.{h,cpp}, hdhrchannel.{h,cpp} and ExternalChannel.{h,cpp} for examples. @jpoet, is probably more familiar with it all than I am. I've only dabbled in the recorder code over the years but he still actively maintains the external recorder.

@kmdewaal
Copy link
Contributor

kmdewaal commented Mar 8, 2025

@angelaschmid @gigem @jpoet please have a look at my comment from yesterday starting with

A bit of context might be useful.

and please comment. We do need to have a common understanding of what this feature request is about!

@angelaschmid
Copy link
Contributor Author

@gigem
Copy link
Contributor

gigem commented Mar 8, 2025

@angelaschmid, thanks. That's what I suspected and I'll file a ticket for the web UI not to allow that. Your only solution for the near term is to set schedule as group to false and max recordings back to 1 for your existing tuner and create, independent tuners for however many simultaneous streams you want to record.

@gigem
Copy link
Contributor

gigem commented Mar 8, 2025

@kmdewaal, I skimmed all of the earlier comments but they don't really matter. The IPTV recorder, as currently written, doesn't support multirec. To support it, someone will have to modify it to support the concept of a "master" tuner and possibly some other things I'm forgetting.

Even then, it will likely only really support overlapping recordings of the same stream. That is essentially how the external recorder and HDHR recorder (when using virtual channels) work now.

@bennettpeter
Copy link
Member

see #1057

@angelaschmid
Copy link
Contributor Author

The issue previously mentioned with the maximum 15 recordings (7xudp, 8xtcp), might be caused by the maximum allowed multicast groups, either by my router or my provider, allowing only max. 7 groups.

@gigem
I configured like you proposed and everything is working

  • created independent cards
  • each having their own input group
  • each having max recordings = 1
  • channel: mplexid set = 0

It would still be nice to have the maximum recordings be set and generated by the Web UI:

  • separate (IPTV or a generic term so that it can be used for other input cards) configuration (not within Interactions between inputs)
  • generate virtual cards with like Schedule as Group unset, which sets all card schedorder = 1
  • set for master and virtual cards reclimit =1
  • in inputgroup, create the master and virtual card, but instead of linking inputgroupid to the master card cardinputid, set the inputgroupid to the virtual card cardinputid

@gigem
Copy link
Contributor

gigem commented Mar 9, 2025

@gigem I configured like you proposed and everything is working

  • created independent cards
  • each having their own input group
  • each having max recordings = 1
  • channel: mplexid set = 0

It would still be nice to have the maximum recordings be set and generated by the Web UI:

  • separate (IPTV or a generic term so that it can be used for other input cards) configuration (not within Interactions between inputs)
  • generate virtual cards with like Schedule as Group unset, which sets all card schedorder = 1
  • set for master and virtual cards reclimit =1
  • in inputgroup, create the master and virtual card, but instead of linking inputgroupid to the master card cardinputid, set the inputgroupid to the virtual card cardinputid

@angelaschmid, @bennettpeter is going to make the necessary changes in the web UI to prevent misconfiguring multirec for IPTV tuners. I fear there is still a misunderstanding on your part, though, as you keep saying master and virtual tuners. The IPTV tuner cannot support multirec (master and virtual tuners are only used with multrec) due to missing support. Until someone submits a patch with that support or one of the developers adds it, it will stay this way.

Note that if you want to have basic, multirec support to record overlapping parts of the same stream, you can currently switch to using the external recorder. The only extra thing you would need to do is convert the m3u file to the format needed by the external recorder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants