Project

General

Profile

Several problems/questions about using Tvheadend, starting with not waiting long enoough for stream to begin

Added by K Shea 3 months ago

Tvheadend has been driving me crazy because I am trying to receive a particular stream that takes a long time to start. The issue is that I am using a pipe:// link and calling ffmpeg to get a stream. For whatever reason this particular stream usually takes a little over one minute to start returning data after it has been called. But Tvheadend will only wait 20 seconds before it gives up and retries the stream (it re-launches ffmpeg). Of course because it is starting over that also fails, and if you have set a recording it will do an endless loop of retries and fails until the recording time ends (hammering the server in the process). I even tried changing the "Maximum timeout (seconds):" value in the Network settings from 20 to 180 (just to give plenty of time no matter what) and yet it totally ignores that and keeps restarting after 20 seconds.

I have been trying to think of ways around this but everything I think of won't work. For example in a Tvheadend recording profile you can run a Pre-processor command. If I could do this a couple minutes in advance of when Tvheadend actually attempts to start recording there might be a very kludgey workaround I could use, but it appears Tvheadend runs the Pre-processor command and then immediately starts the recording. This would not be my preferred way to deal with this anyway (since the more kludges you use the less reliable it gets).

I wish there were an option to just try firing off a pipe:// link ONCE, and then WAIT until a stream actually comes in or the timeout set in the Network settings is reached.

Then another issue is that with certain tuners it would be helpful to do a dummy "warmup" recording without actually saving anything to the hard drive. If Linux had something like /dev/null but that was a directory I would just send the warm-up recording there, but it doesn't so I can't. It would be helpful to have a way to specify in a recording profile that you don't really want to record anything, just go through the motions to warm up the equipment.

Finally, is there any relatively easy way to schedule using a manual recording from the Linux command prompt or a bash shell script? I found an old Python script that was supposed to do it but it wanted a Python module called tvh which apparently is no longer in the Python modules repository, also I suspect it was written for Python 2 not Python 3. It would be REALLY helpful to be able to be able to use a program or a script to start recording a particular channel now, for a duration of say 10 minutes and then quit, WITHOUT needing to do it through the Tvheadend web interface.


Replies (2)

RE: Several problems/questions about using Tvheadend, starting with not waiting long enoough for stream to begin - Added by Dave Pickles 3 months ago

I can help with your last wish.

You can create a time-based recording through the HTTP API (https://github.com/dave-p/TVH-API-docs/wiki/). For example

curl -d 'conf={"config_name":"4e3a1e13acd2d5a9c129e7b00f6c986e","channel":"9ca3e952594a9e6c527b0530a976a715","start":"13:00","stop":"13:30","name":"My test","title":"mytitle","weekdays":[1]}'  http://user:[email protected]:9981/api/dvr/timerec/create

"config_name" is the UID of the recording profile you wish to use, get these from api/dvr/config/grid.
"channel" is the UID of the channel to record, get it from api/channel/grid?limit=9999
"weekdays" set to the current day of the week (0 = Sunday). It's not possible to create a one-off timer so you'll need to delete it when it's no longer needed.

RE: Several problems/questions about using Tvheadend, starting with not waiting long enoough for stream to begin - Added by K Shea 3 months ago

Thank you Dave. Actually it looks like one of your older posts gives an arguably slightly better solution:

https://tvheadend.org/boards/5/topics/28252?r=29093#message-29093

The reason I say that is slightly better is because you can specify the channel by channel name, and because you can specify the start and stop times using Unix timestamps, which makes the math much easier if you want to schedule something to start in say one minute from whenever a script runs. And there are no long hexadecimal strings to worry about with that one. And as far as I can tell, that one will let you create a one-off timer, unless I am not fully understanding it. But it won't let you use a specific recording profile, so the one you just posted is better if you need that, but in my case the default profile will work fine.

If I weren't seriously sleep deprived I'd go read your document at https://github.com/dave-p/TVH-API-docs/wiki/ which looks potentially very useful, and I definitely want to look it over later today.

    (1-2/2)