Hi,
for months I was fighting with some issues on recorded files, mostly:
* The length of the recording was displayed totally wrong in Kodi (i.e: A 50 minutes show was displayed with a runtime like 20:58:17)
* In some recordings I was not able to skip forward - in that case Kodi immediately ends the playback
As it seems that these issues are not going to be fixed within short term in TVH and I read also about people with the same (unresolved) issue, I took some time today, read through forums and "merged" what I've found into a post recording script.
I did play around with some other recording formats than "pass" before. Recording as MKV seems to be more reliable in term of the two bugs mentioned above, but the big issue is that you can't start watching what is currently recorded. Or better: You can start watching, but that only goes to a certain point and then breaks - it does not recognize that the file "grows" on the other end while still being recorded. But that's what we often do: Record a show and start watching some 20-30 mins later to be able to skip over commercials.
The only solution for this seems to stay in the "pass" recording format.
The wrong time display and the issue with the non-working skip forward seems to be errors in the recorded TS container. It seems to happen more often on recordings which are descrambled (German HD+ via OSCAM), but that's more a statistics feeling - I've at least had wrong time displays also with normal FTA recordings.
But finally I found that rerunning ffmpeg over the file can fix these two issues! :-))
So I did a script like this:
#!/bin/sh
# variables
TSVIDEO=$1 #Full path to recording /video/Recordings/%{ShowName}/%{FileName.ext}
error=$2 #error from tvheadend recorder "OK" if no error
# exit if not ok
if [ $error != "OK" ]; then
echo " Not OK"
exit 1
fi
/usr/bin/ffmpeg -i $TSVIDEO -c copy -f mpegts $TSVIDEO.tmp
mv -f $TSVIDEO.tmp $TSVIDEO
... and put it into /home/hts. You need to make it executable!
In the Post-processor-command field in the DVR profile in TVH you then need to enter:
/home/hts/postprocess.sh %f %e
So after finishing the recording TVH will start the ffmpeg process which fixes the TS error but does not recode the streams. That is pretty fast (takes around a minute for a 60h recording) and uses only around 30-40% of a single CPU core. So the load on my ESXi VM is basically around 7-8% when that is processing a file.
As the temporary file is just doing a rename operation over the original file, the original file is not missing at any point - so TVH will not put the recording in "Removed Recordings" by mistake.
And: When you are already watching the recording "from the start" while this process happens, it does not break the playback when the file is replaced (which is curious, but I'm happy about this).
Finally I hope that one day the TS issues are solved at the root in TVH, but this may help some of you guys until that is done.
VBR,
Marco