Project

General

Profile

I need modify tvheadend precision and add button

Added by Dominik Nepoviem 10 days ago

Hello,

i added job / task on freelancer

https://www.freelancer.com/projects/c-programming/TVHEADEND-digital-video-recording

please check...

can anyone help ?

thanks !


Replies (7)

RE: I need modify tvheadend precision and add button - Added by Em Smith 10 days ago

(I'm not looking for the work, just offering thoughts since I recognize none of the people on that website who are asking you for money).

I don't think this would be easy, or maybe even possible. The system's timers aren't accurate enough for what you want. So, if an alarm went off saying "it's end time", it needs to be scheduled by the OS, then go to the program, lookup the timer, determine what to do, log, process it, etc. All this will give you some unspecified, variable and uncontrolled delay.

Additionally, programmes are frequently broadcast with "groups of pictures". So, instead of broadcasting unique pictures after pictures (mjpeg), the broadcaster might have a picture sent, then a few frames that only contain differences from that pictures (such as just the bits that are a person's eyes blinking), then after a few seconds it sends a new whole frame picture so everything is reset. This is mainly to reduce space/costs. So, if you interrupt in the middle of this group you end up with "corrupted" pictures at the start of your next hour since there is no reference frame, so you have just "here are some eyes", but no "face frame".

If you don't need it real-time, I'd record a 24-hour show and then split it using an hourly (external) cron/timer task to extract the previous hour's recording from the ongoing recording by specifying a start/stop time (similar to "-ss" or "-itsoffset" in ffmpeg with "-t" duration of an hour). There are some programs that will re-encode frames from a group so you don't have corruption at the start of an hour. I think avidemux does that (which can be run as a command line). But, even then you're relying on the very start of the recording being at 00:00:00.00, which is likely to be a little off due to delays at starting, but perhaps if you start at 23:55 then the stream may have an internal correct broadcast timestamp that could be used.

RE: I need modify tvheadend precision and add button - Added by Dominik Nepoviem 10 days ago

Hello,

we need it for professional using.... thats why we need precision ... there should be some differences... but we need as less as possible .. for example ~100 ms will be ok for start /stop every hour recording

this will be possible to make ?

thanks for helping !!

RE: I need modify tvheadend precision and add button - Added by Em Smith 9 days ago

I'm assuming you are trying to archive one recording per hour (09:00--10:00; 10:00--11:00) and that the recordings don't need to be streamed from within Tvheadend (though they could be re-imported if necessary).

If you don't need it in real time, then you could use some simple script like the one below (untested).

You'd need to edit it a bit to alter INPUT and OUTPUT.

But, assuming you are recording 24 hours a day in to a file with some known filename (based on start date), you could then just run this script via cron every hour (via crontab).

The script would then open the currently recording file, determine the current hour, and copy the previous hour to a new output file.

In your recording rules, you can (presumably), record every day from 00:00. If it's not from midnight (example you start at 6am), then you'd need to do some extra hour calculations in the script. The script also doesn't handle the scenario where Tvheadend crashes during the day (so start time of recording will be wrong).

This script is untested. But, it might give you an idea of how to proceed instead of doing something complicated. If you need the hourly files available inside Tvheadend, there are examples in the forums for importing a recording.

hth.

#! /bin/sh

INPUT=/some/file/being/recorded/with/date/in/it.ts

# Determine current hour
HOUR=`date +%H`
# Then work out previous hour, allowing for running at midnight.
HOUR=`expr $HOUR + 23`
PREV_HOUR=`expr $HOUR % 24`

# 60 seconds in a minute, 60 minutes in an hour.
SEEK_SECONDS=`expr $PREV_HOUR \* 60 \* 60`

# Generate a unique hourly file.
OUTPUT_SUFFIX=`date +%F-%H`
OUTPUT=/tmp/some_file.$OUTPUT_SUFFIX.ts

# Finally, generate the output file.  You might need to put "-ss $SEEK_SECONDS" after the "-i "$INPUT"".
ffmpeg -ss $SEEK_SECONDS -i "$INPUT" -codec copy -t 3600  "$OUTPUT" 

RE: I need modify tvheadend precision and add button - Added by Em Smith 9 days ago

Alternatively, if you need everything real-time, you could use a simple script to use the api to programmatically create a timer for every hour (or do it manually if your schedule is simple). But you would have to ensure that you override/remove any pre-record/post-record padding, and I think you'd run a very slight risk of missing a few seconds of recording as one timer ends and the next programme record begins and has to tune/lock the channel. For that reason I think recording 24 hours at a time is probably less risky.

RE: I need modify tvheadend precision and add button - Added by saen acro 9 days ago

Read this
https://tvheadend.org/boards/4/topics/32005
You can record without problem with ffmpeg.
There is more advansed command in example.

RE: I need modify tvheadend precision and add button - Added by Tristan Antonina 4 days ago

The system's timers aren't accurate enough for what you want. So, if an alarm went off saying "it's end time", it needs to be scheduled by the OS, then go to the program, lookup the timer, determine what to do, log, process it, etc. All this will give you some unspecified, variable and uncontrolled delay. https://www.myprepaidbalance.me/

Additionally, programmes are frequently broadcast with "groups of pictures". So, instead of broadcasting unique pictures after pictures (mjpeg), the broadcaster might have a picture sent, then a few frames that only contain differences from that pictures (such as just the bits that are a person's eyes blinking), then after a few seconds it sends a new whole frame picture so everything is reset. This is mainly to reduce space/costs.

RE: I need modify tvheadend precision and add button - Added by Dominik Nepoviem 4 days ago

hello,

thanks everyone for helping, but i solved it another way

because we need precision... we started using recording using ffmpeg by UDP ...

this solved our precision ...

    (1-7/7)