IPTV Simple Client w/ HD Recording
#46
(2018-05-31, 19:28)el_gonz87 Wrote:
(2018-05-31, 16:15)Mr Groch Wrote: I have changed this line:
https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L272

To:
strParams = strParams + " --"+lineVect[0]+"="+lineVect[1];

And recrding of rtmp streams is now working. So I can confirm that problem is with too many " chars

Now I have problem with duration of those recordings, ffprobe says that duration is 00:00:00. I have tried adding --use_wallclock_as_timestamps 1 -fflags +genpts to output parameters but with no luck...
I think this is an FFMPEG issue. It may be due to the -v copy parameters, maybe it does not create timestamps appropriately. The fact FFPROBE detects a duration of 0 makes me think the FLV file doesn't have the appropriate data to get a duration. Have you tried actually remuxing? using a video codec and audio codec?

I must admit I was not able to test rtmp streams as I have none.  
 Hi, i've found cause of the issue. Is not FFMPEG problem - problem is in:
https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L399

ffmpeg in exec_stream_t can't properly exit when executing e_Stream.close(); so it is killed after. The solution is to clean exit ffmpeg - then duration and any other metadata is fine.

My working and tested proposition is in this diff of PVRRecorderThread.cpp file:

@@ -352,6 +352,7 @@ void *PVRRecorderThread:Tonguerocess(void)
   e_Stream.set_binary_mode(exec_stream_t:Confused_out);
   e_Stream.set_wait_timeout(exec_stream_t:Confused_in, g_iStrmTimeout*1000);
   e_Stream.set_wait_timeout(exec_stream_t:Confused_out, g_iStrmTimeout*1000);
+  e_Stream.set_wait_timeout(exec_stream_t:Confused_child, g_iStrmTimeout*1000);
   e_Stream.start(g_strFFMPEG, strParams);
 
   XBMC->Log(LOG_NOTICE, "Set stream timeout: %d", g_iStrmTimeout);
@@ -395,9 +396,15 @@ void *PVRRecorderThread:Tonguerocess(void)
     if (nowTimer.Timer.endTime<time(NULL) || nowTimer.Status == PVR_STREAM_IS_STOPPING || nowTimer.Status == PVR_STREAM_STOPPED || nowTimer.bIsDeleted == true)
     {
       // recording stopped
-      e_Stream.close();
-      e_Stream.kill();
-              
+      // send "q" to ffmpeg for clean exit
+      e_Stream.in() << "q";
+      e_Stream.close_in();
+      if (!e_Stream.close())
+      {
+        e_Stream.kill();
+        XBMC->Log(LOG_NOTICE, "Record command failed to close, killing");
+      }
+
       XBMC->Log(LOG_NOTICE, "Recording stopped %s", nowTimer.Timer.strTitle);
                  
       // correct duration time & add to cache
@@ -459,9 +466,15 @@ void *PVRRecorderThread:Tonguerocess(void)
     else if (now-lastRead>=g_iStrmTimeout)
     {
       // something wrong - data not growing
-      e_Stream.close();
-      e_Stream.kill();
-         
+      // send "q" to ffmpeg for clean exit
+      e_Stream.in() << "q";
+      e_Stream.close_in();
+      if (!e_Stream.close())
+      {
+        e_Stream.kill();
+        XBMC->Log(LOG_NOTICE, "Record command failed to close, killing");
+      }
+
       XBMC->Log(LOG_NOTICE, "Recording failed %s", nowTimer.Timer.strTitle);
                    
       // correct duration time & add to cache
Reply
#47
(2018-06-02, 16:36)Mr Groch Wrote:
(2018-05-31, 19:28)el_gonz87 Wrote:
(2018-05-31, 16:15)Mr Groch Wrote: I have changed this line:
https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L272

To:
strParams = strParams + " --"+lineVect[0]+"="+lineVect[1];

And recrding of rtmp streams is now working. So I can confirm that problem is with too many " chars

Now I have problem with duration of those recordings, ffprobe says that duration is 00:00:00. I have tried adding --use_wallclock_as_timestamps 1 -fflags +genpts to output parameters but with no luck...
I think this is an FFMPEG issue. It may be due to the -v copy parameters, maybe it does not create timestamps appropriately. The fact FFPROBE detects a duration of 0 makes me think the FLV file doesn't have the appropriate data to get a duration. Have you tried actually remuxing? using a video codec and audio codec?

I must admit I was not able to test rtmp streams as I have none.   
 Hi, i've found cause of the issue. Is not FFMPEG problem - problem is in:
https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L399

ffmpeg in exec_stream_t can't properly exit when executing e_Stream.close(); so it is killed after. The solution is to clean exit ffmpeg - then duration and any other metadata is fine.

My working and tested proposition is in this diff of PVRRecorderThread.cpp file:

@@ -352,6 +352,7 @@ void *PVRRecorderThread:Tonguerocess(void)
   e_Stream.set_binary_mode(exec_stream_t:Confused_out);
   e_Stream.set_wait_timeout(exec_stream_t:Confused_in, g_iStrmTimeout*1000);
   e_Stream.set_wait_timeout(exec_stream_t:Confused_out, g_iStrmTimeout*1000);
+  e_Stream.set_wait_timeout(exec_stream_t:Confused_child, g_iStrmTimeout*1000);
   e_Stream.start(g_strFFMPEG, strParams);
 
   XBMC->Log(LOG_NOTICE, "Set stream timeout: %d", g_iStrmTimeout);
@@ -395,9 +396,15 @@ void *PVRRecorderThread:Tonguerocess(void)
     if (nowTimer.Timer.endTime<time(NULL) || nowTimer.Status == PVR_STREAM_IS_STOPPING || nowTimer.Status == PVR_STREAM_STOPPED || nowTimer.bIsDeleted == true)
     {
       // recording stopped
-      e_Stream.close();
-      e_Stream.kill();
-              
+      // send "q" to ffmpeg for clean exit
+      e_Stream.in() << "q";
+      e_Stream.close_in();
+      if (!e_Stream.close())
+      {
+        e_Stream.kill();
+        XBMC->Log(LOG_NOTICE, "Record command failed to close, killing");
+      }
+
       XBMC->Log(LOG_NOTICE, "Recording stopped %s", nowTimer.Timer.strTitle);
                  
       // correct duration time & add to cache
@@ -459,9 +466,15 @@ void *PVRRecorderThread:Tonguerocess(void)
     else if (now-lastRead>=g_iStrmTimeout)
     {
       // something wrong - data not growing
-      e_Stream.close();
-      e_Stream.kill();
-         
+      // send "q" to ffmpeg for clean exit
+      e_Stream.in() << "q";
+      e_Stream.close_in();
+      if (!e_Stream.close())
+      {
+        e_Stream.kill();
+        XBMC->Log(LOG_NOTICE, "Record command failed to close, killing");
+      }
+
       XBMC->Log(LOG_NOTICE, "Recording failed %s", nowTimer.Timer.strTitle);
                    
       // correct duration time & add to cache
 
That's excellent and good catch! Will commit this to master branch, thanks for supporting the addon development.
Reply
#48
I've found another issue - there is huge glitch when any text from EPG have new line chars (\n) - timers and recordings handling crashes then...
There should be eresing new line chars or escaping/taging them like you do with | char
Reply
#49
deleted
Reply
#50
(2018-06-05, 17:03)Mr Groch Wrote: I've found another issue - there is huge glitch when any text from EPG have new line chars (\n) - timers and recordings handling crashes then...
There should be eresing new line chars or escaping/taging them like you do with | char
 Hmmmmm.... I thought my EPG provider had line breaks, will look at translating them when reading/writing to cache file.
Reply
#51
Another bug, but I haven't yet found place in code responsible for that...

Kodi crashes when recording is stoped from timer end. When I end recording manually, there is no crash.

Here is compare of logs when recording stoped by timer (with crash):
https://paste.ubuntu.com/p/DMjvK64gY2/

Here when I stop recording manually (no crash):
https://paste.ubuntu.com/p/B8Rvhyx28h/
Reply
#52
I think, that I have found the issue. But can't test it right now.

After adding sleep, scheduler process loop isn't able to execute else if statament on line https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L185, but always first will be executed https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L146, and then pRecorder on line https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L162 is not ready for deleting, because is still busy.

Conclusion - https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L185 need to be executed first, I will try to refactor this localy later and test it
Reply
#53
(2018-06-13, 14:03)Mr Groch Wrote: I think, that I have found the issue. But can't test it right now.

After adding sleep, scheduler process loop isn't able to execute else if statament on line https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L185, but always first will be executed https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L146, and then pRecorder on line https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L162 is not ready for deleting, because is still busy.

Conclusion - https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L185 need to be executed first, I will try to refactor this localy later and test it
 Hi there. Thanks again for your committed testing. I have implemented fixes to this issue and the previous (line breaks in EPG). Please download latest commits from master branch.

For some reason Ubuntu 16.04 did not crash when timer ended recording, so I have no way of knowing if this actually fixed it but I think you are right the IFs should be reordered. I put the stop recording IF as the first to execute. Let me know if this does not fix the problem for you.
Reply
#54
I have implemented other solution, I think that it is better, because sheduler now waits for recording thread to end. No race condition. Your solution only changes the order, so still recorder can be destroyed before recording ends.

@@ -143,7 +143,7 @@ void *PVRSchedulerThread:Tonguerocess(void)
       
             s_triggerTimerUpdate = true;
           }
-          else if (currTimer.Timer.endTime < time(NULL))
+          else if (currTimer.Timer.endTime < time(NULL) && (currTimer.Timer.state == PVR_TIMER_STATE_COMPLETED))
           {
             if (currTimer.Timer.iTimerType != PVR_TIMER_TYPE_NONE) 
             {

Also I have fund that your commit adcab0fbecc208912f83135952b7d967f2a11fde need also following timeot to be set:

@@ -352,6 +352,7 @@ void *PVRRecorderThread:Tonguerocess(void)
   e_Stream.set_binary_mode(exec_stream_t:Confused_out);
   e_Stream.set_wait_timeout(exec_stream_t:Confused_in, g_iStrmTimeout*1000);
   e_Stream.set_wait_timeout(exec_stream_t:Confused_out, g_iStrmTimeout*1000);
+  e_Stream.set_wait_timeout(exec_stream_t:Confused_child, g_iStrmTimeout*1000);
   e_Stream.start(g_strFFMPEG, strParams);
 
   XBMC->Log(LOG_NOTICE, "Set stream timeout: %d", g_iStrmTimeout);

Default child timeout is 1 s and not always quiting ffmpeg with 'q' will end in 1 s, so it is killed...
Reply
#55
(2018-06-13, 20:56)Mr Groch Wrote: I have implemented other solution, I think that it is better, because sheduler now waits for recording thread to end. No race condition. Your solution only changes the order, so still recorder can be destroyed before recording ends.

@@ -143,7 +143,7 @@ void *PVRSchedulerThread:Tonguerocess(void)
       
             s_triggerTimerUpdate = true;
           }
-          else if (currTimer.Timer.endTime < time(NULL))
+          else if (currTimer.Timer.endTime < time(NULL) && (currTimer.Timer.state == PVR_TIMER_STATE_COMPLETED))
           {
             if (currTimer.Timer.iTimerType != PVR_TIMER_TYPE_NONE) 
             {

Also I have fund that your commit adcab0fbecc208912f83135952b7d967f2a11fde need also following timeot to be set:

@@ -352,6 +352,7 @@ void *PVRRecorderThread:Tonguerocess(void)
   e_Stream.set_binary_mode(exec_stream_t:Confused_out);
   e_Stream.set_wait_timeout(exec_stream_t:Confused_in, g_iStrmTimeout*1000);
   e_Stream.set_wait_timeout(exec_stream_t:Confused_out, g_iStrmTimeout*1000);
+  e_Stream.set_wait_timeout(exec_stream_t:Confused_child, g_iStrmTimeout*1000);
   e_Stream.start(g_strFFMPEG, strParams);
 
   XBMC->Log(LOG_NOTICE, "Set stream timeout: %d", g_iStrmTimeout);

Default child timeout is 1 s and not always quiting ffmpeg with 'q' will end in 1 s, so it is killed...
 I see your point on first one, although very unlikely it would not execute first IF (perfect timing), I added a safe guard, however the added code should be this:
&& !(currTimer.Timer.state == PVR_TIMER_STATE_RECORDING)

Recordings can exit due to completion or error (stream times out due to buffering, etc..). The above code basically checks for no active recording.

As for 2nd, again this was not issue on Ubuntu for me, but I added the lines, check out latest commit and let me know.
Reply
#56
Thanks, I have tested your latest commit and both - recording from manual start/stop and recording from timer works great!

I have found another issue :/ Timers don't work well after Kodi restart. Timers will be loaded at start (I can see notification and in log), but timer tasks aren't added to Kodi recording taks. Next when it is time for recording start - I can see in log lots of "Try to start recording ..." till timer end. Recording is not started. I think that addon can't get channel for recording at https://github.com/gonzalo-hvega/pvr.ipt...d.cpp#L283

When I add after Kodi restart another timer for this channel, I see that channeluid in timer cache file is different...

I think that you should delete timers on addon load when channeluid is not known

I don't have idea how to fix this right now, maybe mark channel ny name or channel number (or both, because my prvider sometimes double the same channel name - alternative source) in timers?
Reply
 
Thread Rating:
  • 8 Vote(s) - 4.38 Average



Logout Mark Read Team Forum Stats Members Help
IPTV Simple Client w/ HD Recording4.388