[mythtv-users] [OT] Recover from interrupted streams

Stephen Worthington stephen_agent at jsw.gen.nz
Sun Sep 25 00:58:24 UTC 2016


On Sat, 24 Sep 2016 09:09:58 -0700, you wrote:

>Hello All,
>
>I've written a tool to interface with the "ExternalRecorder" feature in
>0.28. I've got everything working, including an EPG.
>
>I am trying to harden the tool now. In my tool, I use FFMPEG to pull the
>source and convert it to an MPEG-TS for the External Recorder. Every now
>and again, the stream dies and needs to be restarted. If I don't do
>anything, MythTV records until the stream dies. The tool seems to properly
>detect the failure and restart the stream, but in the frontend the video
>becomes corrupted. I am assuming that this is because FFMPEG died before
>setting a complete frame... The underlying video is in H.264.
>
>I am not even sure how to phrase the question... Anyone know how to have
>the "new" stream append cleanly? Or, can I force MythTv to just restart the
>ExternalRecorder when it dies?
>
>I'd rather have a continuity error, than only 30 mins of 3 hour sports
>event. :)
>
>Thanks in advance for help and guidance.
>Marc

Here are some ideas that came to mind:

One way to do it might be to record to a new file somehow each time
the stream is disrupted, then use ffmpeg or some other tool to merge
the files at the end of the recording.  The merge process might make
the tool used correctly close off the stream from one file before
starting the next.

Do the files your recorder produces have all the data from after the
stream dies recorded, or does the recording stop at the discontinuity?
If all the data is there, a tool that repairs bad TS files might be
the answer.  Just run it automatically at the end of the recording, or
send the streams through it before writing them to the recording file.

The LiveTV code creates recordings where the channel changes in the
middle, but you are able to go back and forwards in the recording
despite the channel change, which can involve considerable changes in
the streams being recorded (eg SD channel to HD channel).  I have no
idea how it does that, but looking at that code might give you some
ideas.  I do know that when I stop a LiveTV recording with mythbackend
having the -v record logging option on, I get damaged recording
reports in the log such as this:

Sep 20 23:05:19 mypvr mythbackend: mythbackend[5691]: I TVRecEvent
tv_rec.cpp:848 (FinishedRecording) TVRec[1]:
FinishedRecording(1001_2016-09-20T11:04:14Z) damaged
recq:<RecordingQuality overall_score="0"
key="1001_2016-09-20T11:04:14Z" countinuity_error_count="0"
packet_count="310194">#012    <Gap start="2016-09-20T11:00:00Z"
end="2016-09-20T11:04:14Z" duration="254" />#012    <Gap
start="2016-09-20T11:05:18Z" end="2016-09-20T12:50:00Z"
duration="6281" />#012</RecordingQuality>

These reports also happen each time I tell the LiveTV session to
change tuners.  As it is able to play these recordings back, it is
obviously coping with those errors somehow.  Due to the appearance of
the FinishedRecording reports, I think it is probably closing off and
restarting a recording each time it happens, then linking the
recordings together somehow.

I am looking for a way to record SAT>IP streams in MythTV, which it is
not yet able to do.  So I was wondering if your external recorder code
was able to record that sort of stream?  If so, I would love to be
able to try it out.  Even if it does not handle SAT>IP streams, it
would still be good to see how you have made a working external
recorder, in case I need to write my own one for SAT>IP.  I am
unlikely to have disruptions in my streams as I am only intending to
record from SAT>IP tuners on other boxes in my local network, or even
from the same PC.


More information about the mythtv-users mailing list