tgorgdotcom / locast2plex

A very simple script to connect locast to Plex's live tv/dvr feature.
MIT License
232 stars 43 forks source link

Plex doesn't stop recording at the end of a show (may not be a locast2plex bug) #105

Open dshanks01 opened 3 years ago

dshanks01 commented 3 years ago

I'm reporting this here as well as in the Plex forums because I don't know where the problem lies, and I don't know enough about the Plex/Tuner interface to debug the problem myself.

locast2plex version 0.5.3 plexmediaserver version 1.20.2.3402 Operation system Linux Mint 19.3 All software is running directly on the Linux OS. No Docker.

Most of the time the lowcast2plex/plexmediaserver interface works correctly. When a show is scheduled for recording, Plex gets the video stream from locast2plex, records the show, runs the commercial remover, and copies the show into my TV shows library. On two occasions, however, I have checked Plex several hours later and discovered that Plex is still "recording." The shows it's "recording" have ended, but Plex appears not to know it. When I reset the server, a truncated video file ends up in my TV shows library. Both times this has happened, Plex is using two of the three locast2plex "tuners" I have configured.

As I said earlier, I don't have any reason to believe the problem is with locast2plex. This seems much more likely to be a Plex bug. I'm reporting it here only to make others aware of this potential problem and because this is the only place I know of to get help with using locast2plex.

I've attached a screen shot of my Plex DVR screen to show what I'm seeing. The screen shot was taken a ~9AM the morning after. Note that two shows are still "recording" even though the last one finished at 3AM. A 14 minute partial video from The Late Show episode (which Plex shows still recording) is in my TV shows library, and commercials have been removed. The Nova episode (which Plex shows still recording) is NOT in my TV shows library at all.

Thanks for any suggestions anyone can make for how to solve this problem.

StillRecordingHoursLater

dshanks01 commented 3 years ago

It appears that at least one of the problems above is due to a hung Plex Transcoder process. Looking at the process table:

david@shankscloud:~$ ps -ef |grep -i transcode
david    19232 32718  0 11:13 pts/1    00:00:00 grep --color=auto -i transcode
plex     24631 15443  0 01:30 ?        00:01:40 /usr/lib/plexmediaserver/Plex Transcoder -noaccurate_seek -ignore_unknown -scan_all_pmts -1 -rw_timeout 30000000 -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 30 -fflags +discardcorruptts+fillwallclockdts -probesize 20000000 -i http://127.0.0.1:6077/watch/1572389492146 -map 0:V? -codec:V copy -map 0:a? -codec:a copy -map 0:s? -codec:s copy -break_non_keyframes 1 -segment_format mpegts -f ssegment -individual_header_trailer 0 -segment_time 1 -segment_start_number 0 -segment_time_delta 0.25 -segment_list http://127.0.0.1:32400/video/:/transcode/session/6c7a8748-ea52-4d94-844f-590a32fcae2f/c496c639-3527-4509-aa40-27c8784bc9e5/seglist?X-Plex-Http-Pipeline=infinite -segment_list_type csv -segment_list_size 5 -segment_list_separate_stream_times 1 -segment_list_unfinished 1 -max_delay 5000000 -map_metadata -1 -map_chapters -1 media-%05d.ts -y -nostats -loglevel quiet -loglevel_plex error -xioerror -progressurl http://127.0.0.1:32400/video/:/transcode/session/6c7a8748-ea52-4d94-844f-590a32fcae2f/c496c639-3527-4509-aa40-27c8784bc9e5/progress
plex     24688 15443  6 01:30 ?        00:40:33 /usr/lib/plexmediaserver/Plex Transcoder -codec:0 h264 -live_start_index 0 -probesize 20000000 -i http://127.0.0.1:32400/livetv/sessions/6c7a8748-ea52-4d94-844f-590a32fcae2f/7e62e937-4317-4125-a077-8461acc5c326/index.m3u8?offset=-1.000000&X-Plex-Token=kvnSxEfDqqcMK7rMtLMh -filter_complex [0:0]scale=w=1280:h=720[0];[0]format=pix_fmts=yuv420p|nv12[1] -map [1] -codec:0 libx264 -crf:0 16 -r:0 30 -preset:0 veryfast -x264opts:0 subme=1:me_range=4:rc_lookahead=10:me=hex:8x8dct=0:partitions=none -map 0:1 -codec:1 copy -copypriorss:1 0 -f mpegts -map_metadata -1 -map_chapters -1 /home/plex/tv/.grab/f1e162b691dbdc18e9247fff61ebe43f77c67bcd-b098b33f8a405814a7d2dbd52d7aa6772708be5c/NOVA (1973) - S46E16 - Ice Worlds.ts -y -nostats -loglevel quiet -loglevel_plex error -xioerror -progressurl http://127.0.0.1:32400/video/:/transcode/session/7e62e937-4317-4125-a077-8461acc5c326/31080a8e-1e40-43ad-80ff-53a9800eee94/progress

Process 24631 was reading from locast2plex and became hung such that a sigkill was required to terminate it. I tried sighup, sigterm, and sigint first before resorting to sigkill.

Is there any possibility that data provided by locast2plex was the root cause of the Plex Transcoder hanging?

dshanks01 commented 3 years ago

More information. About halfway through two of the shows last night, I see main.py throw two exceptions; apparently associated with opening a file for reading for each of the two shows being recorded. Is this normal? I've occasionally seen this exception while locast2plex was, apparently, not receiving any program stream. But this time it seems to be associated with Plex having difficulty with two recordings.

Oct 06 00:07:50 shankscloud locast2plex[20984]: [hls,applehttp @ 0x562dbda30900] Opening 'https://sea.locastnet.org/proxy/sea/kiro_src266994704.ts' for reading
Oct 06 00:07:50 shankscloud locast2plex[20984]: [hls,applehttp @ 0x55a2483e9900] Opening 'https://sea.locastnet.org/proxy/sea/king_src266994686.ts' for reading
Oct 06 00:07:50 shankscloud locast2plex[20984]: [290B blob data]
Oct 06 00:07:50 shankscloud locast2plex[20984]: video:258094kB audio:47907kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 10.669032%
Oct 06 00:07:50 shankscloud locast2plex[20984]: Exiting normally, received signal 15.
Oct 06 00:07:50 shankscloud locast2plex[20984]: Traceback (most recent call last):
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 293, in _handle_request_noblock
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.process_request(request, client_address)
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.finish_request(request, client_address)
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.RequestHandlerClass(request, client_address, self)
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 657, in __init__
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.finish()
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 716, in finish
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.wfile.close()
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/socket.py", line 283, in close
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.flush()
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/socket.py", line 307, in flush
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self._sock.sendall(view[write_offset:write_offset+buffer_size])
Oct 06 00:07:50 shankscloud locast2plex[20984]: error: [Errno 32] Broken pipe
Oct 06 00:07:51 shankscloud locast2plex[20984]: [290B blob data]
Oct 06 00:07:51 shankscloud locast2plex[20984]: video:280236kB audio:46545kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 10.523701%
Oct 06 00:07:51 shankscloud locast2plex[20984]: Exiting normally, received signal 15.
Oct 06 00:07:51 shankscloud locast2plex[20984]: Traceback (most recent call last):
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 293, in _handle_request_noblock
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.process_request(request, client_address)
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.finish_request(request, client_address)
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.RequestHandlerClass(request, client_address, self)
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 657, in __init__
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.finish()
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 716, in finish
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.wfile.close()
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/socket.py", line 283, in close
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.flush()
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/socket.py", line 307, in flush
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self._sock.sendall(view[write_offset:write_offset+buffer_size])
Oct 06 00:07:51 shankscloud locast2plex[20984]: error: [Errno 32] Broken pipe
Oct 06 00:08:06 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:06] "GET /discover.json HTTP/1.0" 200 -
Oct 06 00:08:06 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:06] "GET /lineup_status.json HTTP/1.0" 200 -
Oct 06 00:08:11 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:11] "GET /device.xml HTTP/1.1" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /lineup.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /discover.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /lineup_status.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /discover.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /lineup.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /lineup_status.json HTTP/1.0" 200 -
Oct 06 00:08:13 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:13] "GET /watch/1572389491672 HTTP/1.1" 200 -
Oct 06 00:08:13 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:13] "GET /watch/1572389491219 HTTP/1.1" 200 -
Oct 06 00:08:13 shankscloud locast2plex[20984]: ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
Oct 06 00:08:13 shankscloud locast2plex[20984]:   built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
Oct 06 00:08:13 shankscloud locast2plex[20984]:   configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incd
Oct 06 00:08:13 shankscloud locast2plex[20984]:   WARNING: library configuration mismatch
mkoreen commented 3 years ago

I'm having this same problem, except it appears to happen with every recording I try. I don't have the debug info at the moment, but just pointing out you're not the only one.

I do have some more info though, when I look in the cache for plex I find thousands of ts files.. It appears locast sends plex 1 .ts file per second of video recorded.

image

A friend looked through logs on the plex server and found a lot of WARN - MDE: unable to find a working transcode profile for video stream. Hope some of this helps.

ratherDashing commented 3 years ago

This also happens to me 5-10% of the time. It happened last night to me as well recording the news.

I seem to see this in the logs when it happens

[mpegts @ 0x55a056fb3940] Non-monotonous DTS in output stream 0:1; previous: 8585023855, current: 939513600; changing to 8585023856. This may result in incorrect timestamps in the output file.

@tgorgdotcom what do you think about this suggestion: https://stackoverflow.com/questions/55914754/how-to-fix-non-monotonous-dts-in-output-stream-01-when-using-ffmpeg

dshanks01 commented 3 years ago

It appears locast sends plex 1 .ts file per second of video recorded.

locast2plex does not send files to Plex at all. The interface is HTTP, and locast2plex responds to each HTTP GET request with a short amount of video data. If huge numbers of .ts files are being created, it's Plex that's doing the file creations.

For what it's worth, I don't see this behavior on my Plex system. My server appears to be growing a single .ts file in the .grab folder tree as it receives data from locast2plex.

I need to look into @ratherDashing's suggestion, but I don't think that could be the problem I'm seeing. DTS and stream 0:1 are audio, and the stations whose broadcasts are triggering the problem encode their audio in AAC. OTOH, mediainfo says the "Muxing Mode" is ADTS. Could that be the same thing as DTS?

One hint I got over in the Plex forums was to turn the "CONVERT VIDEO WHILE RECORDING" option off in the Locast2Plex Device Settings (see below). Previously I had it set to Transcode, which is an experimental feature. I haven't seen a failed recording since turning that off, but it's onlly been a couple of days. Locast2PlexDeviceSettings

You can read the discussion that's been happening in the Plex forum regarding this problem here: Recording Not Ending. Partial or Non-existent Recordings. Commercials Not Removed.

ratherDashing commented 3 years ago

More information. About halfway through two of the shows last night, I see main.py throw two exceptions; apparently associated with opening a file for reading for each of the two shows being recorded. Is this normal? I've occasionally seen this exception while locast2plex was, apparently, not receiving any program stream. But this time it seems to be associated with Plex having difficulty with two recordings.

Oct 06 00:07:50 shankscloud locast2plex[20984]: [hls,applehttp @ 0x562dbda30900] Opening 'https://sea.locastnet.org/proxy/sea/kiro_src266994704.ts' for reading
Oct 06 00:07:50 shankscloud locast2plex[20984]: [hls,applehttp @ 0x55a2483e9900] Opening 'https://sea.locastnet.org/proxy/sea/king_src266994686.ts' for reading
Oct 06 00:07:50 shankscloud locast2plex[20984]: [290B blob data]
Oct 06 00:07:50 shankscloud locast2plex[20984]: video:258094kB audio:47907kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 10.669032%
Oct 06 00:07:50 shankscloud locast2plex[20984]: Exiting normally, received signal 15.
Oct 06 00:07:50 shankscloud locast2plex[20984]: Traceback (most recent call last):
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 293, in _handle_request_noblock
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.process_request(request, client_address)
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.finish_request(request, client_address)
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.RequestHandlerClass(request, client_address, self)
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 657, in __init__
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.finish()
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 716, in finish
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.wfile.close()
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/socket.py", line 283, in close
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self.flush()
Oct 06 00:07:50 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/socket.py", line 307, in flush
Oct 06 00:07:50 shankscloud locast2plex[20984]:     self._sock.sendall(view[write_offset:write_offset+buffer_size])
Oct 06 00:07:50 shankscloud locast2plex[20984]: error: [Errno 32] Broken pipe
Oct 06 00:07:51 shankscloud locast2plex[20984]: [290B blob data]
Oct 06 00:07:51 shankscloud locast2plex[20984]: video:280236kB audio:46545kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 10.523701%
Oct 06 00:07:51 shankscloud locast2plex[20984]: Exiting normally, received signal 15.
Oct 06 00:07:51 shankscloud locast2plex[20984]: Traceback (most recent call last):
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 293, in _handle_request_noblock
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.process_request(request, client_address)
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.finish_request(request, client_address)
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.RequestHandlerClass(request, client_address, self)
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 657, in __init__
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.finish()
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/SocketServer.py", line 716, in finish
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.wfile.close()
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/socket.py", line 283, in close
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self.flush()
Oct 06 00:07:51 shankscloud locast2plex[20984]:   File "/usr/lib/python2.7/socket.py", line 307, in flush
Oct 06 00:07:51 shankscloud locast2plex[20984]:     self._sock.sendall(view[write_offset:write_offset+buffer_size])
Oct 06 00:07:51 shankscloud locast2plex[20984]: error: [Errno 32] Broken pipe
Oct 06 00:08:06 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:06] "GET /discover.json HTTP/1.0" 200 -
Oct 06 00:08:06 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:06] "GET /lineup_status.json HTTP/1.0" 200 -
Oct 06 00:08:11 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:11] "GET /device.xml HTTP/1.1" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /lineup.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /discover.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /lineup_status.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /discover.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /lineup.json HTTP/1.0" 200 -
Oct 06 00:08:12 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:12] "GET /lineup_status.json HTTP/1.0" 200 -
Oct 06 00:08:13 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:13] "GET /watch/1572389491672 HTTP/1.1" 200 -
Oct 06 00:08:13 shankscloud locast2plex[20984]: 127.0.0.1 - - [06/Oct/2020 00:08:13] "GET /watch/1572389491219 HTTP/1.1" 200 -
Oct 06 00:08:13 shankscloud locast2plex[20984]: ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
Oct 06 00:08:13 shankscloud locast2plex[20984]:   built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
Oct 06 00:08:13 shankscloud locast2plex[20984]:   configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incd
Oct 06 00:08:13 shankscloud locast2plex[20984]:   WARNING: library configuration mismatch

that is running python 2.7 it looks like, an update or two before the python 3 update those traces were removed. can you update to the latest version?

ratherDashing commented 3 years ago

I need to look into @ratherDashing's suggestion, but I don't think that could be the problem I'm seeing. DTS and stream 0:1 are audio, and the stations whose broadcasts are triggering the problem encode their audio in AAC. OTOH, mediainfo says the "Muxing Mode" is ADTS. Could that be the same thing as DTS?

the ffmpeg process is pretty simple:

ffmpeg_proc = subprocess.Popen(["ffmpeg", "-i", channelUri, "-codec", "copy", "-f", "mpegts", "pipe:1"], stdout=subprocess.PIPE)

i believe all of the locast channels send AAC audio. i brought up my finding just because if Plex is having an issue figuring out the time a recording can be stopped, and locast2plex is having trouble with timestamps at the same time, they may be related. i never had this issue with the exact same setup with a hdhomerunner. something tells me there is something that plex is looking for that locast2plex is either sending incorrectly or not at all to say that a recording is over.

dshanks01 commented 3 years ago

that is running python 2.7 it looks like, an update or two before the python 3 update those traces were removed. can you update to the latest version?

I updated to the python3 version yesterday and am still seeing unhandled exceptions. They appear to be coming from locast2plex reading from a closed file (or, more likely, socket):

Oct 07 13:45:07 shankscloud locast2plex[9555]: 127.0.0.1 - - [07/Oct/2020 12:22:36] "GET /lineup_status.json HTTP/1.0" 200 -
Oct 07 13:45:07 shankscloud locast2plex[9555]: ----------------------------------------
Oct 07 13:45:07 shankscloud locast2plex[9555]: Exception happened during processing of request from ('127.0.0.1', 56078)
Oct 07 13:45:07 shankscloud locast2plex[9555]: Traceback (most recent call last):
Oct 07 13:45:07 shankscloud locast2plex[9555]:   File "/usr/lib/python3.6/socketserver.py", line 320, in _handle_request_noblock
Oct 07 13:45:07 shankscloud locast2plex[9555]:     self.process_request(request, client_address)
Oct 07 13:45:07 shankscloud locast2plex[9555]:   File "/usr/lib/python3.6/socketserver.py", line 351, in process_request
Oct 07 13:45:07 shankscloud locast2plex[9555]:     self.finish_request(request, client_address)
Oct 07 13:45:07 shankscloud locast2plex[9555]:   File "/usr/lib/python3.6/socketserver.py", line 364, in finish_request
Oct 07 13:45:07 shankscloud locast2plex[9555]:     self.RequestHandlerClass(request, client_address, self)
Oct 07 13:45:07 shankscloud locast2plex[9555]:   File "/usr/lib/python3.6/socketserver.py", line 724, in __init__
Oct 07 13:45:07 shankscloud locast2plex[9555]:     self.handle()
Oct 07 13:45:07 shankscloud locast2plex[9555]:   File "/usr/lib/python3.6/http/server.py", line 418, in handle
Oct 07 13:45:07 shankscloud locast2plex[9555]:     self.handle_one_request()
Oct 07 13:45:07 shankscloud locast2plex[9555]:   File "/usr/lib/python3.6/http/server.py", line 406, in handle_one_request
Oct 07 13:45:07 shankscloud locast2plex[9555]:     method()
Oct 07 13:45:07 shankscloud locast2plex[9555]:   File "main.py", line 157, in do_GET
Oct 07 13:45:07 shankscloud locast2plex[9555]:     ffmpeg_proc.communicate()
Oct 07 13:45:07 shankscloud locast2plex[9555]:   File "/usr/lib/python3.6/subprocess.py", line 850, in communicate
Oct 07 13:45:07 shankscloud locast2plex[9555]:     stdout = self.stdout.read()
Oct 07 13:45:07 shankscloud locast2plex[9555]: ValueError: read of closed file
Oct 07 13:45:07 shankscloud locast2plex[9555]: ----------------------------------------
Oct 07 13:45:07 shankscloud locast2plex[9555]: 127.0.0.1 - - [07/Oct/2020 13:08:15] "GET /device.xml HTTP/1.1" 200 -

Aside: I wonder if it would be possible to change the minor version number every time a change is made to the project. Both the latest python 2.7 version and, apparently multiple earlier python 2.7 versions, AND the current python3 version are all v 0.5.3.

dshanks01 commented 3 years ago

i never had this issue with the exact same setup with a hdhomerunner. something tells me there is something that plex is looking for that locast2plex is either sending incorrectly or not at all to say that a recording is over.

That sounds right. All the data I've seen point to this being an interface problem. But whether locast2plex is incorrectly emulating the HDHomeRun interface or Plex is dependent on some undocumented feature (read: bug) in the HDHomeRun interface is pretty difficult to say without access to the Plex source code or HDHomeRun interface documentation. :/

deathbybandaid commented 3 years ago

I found whilst coding a separate, yet similar project emulating HDHR, I've determined that even hardcoding the path /watch can cause some breakage. Plex will attempt to go to /auto/v3.1 for channel 3.1, even though the lineup says /watch

tgorgdotcom commented 3 years ago

@dshanks01 Yeah, you're right about the versioning. It has to do with how I'm merging updated code. I need to think about creating a dev branch for this project, so these changes aren't visible to end users until they're completely ready.

@ratherDashing thanks for the tip on ADTS -- I'll take a look

@deathbybandaid thanks for bringing that up -- I'm in process of adding that url as an endpoint

rottdog32 commented 3 years ago

I am using Plex on Windows 2019 and have the locast2plex tuner running on Windows 10 as a service. I was having a difficult time getting full recordings using locast2plex as the tuner for Plex. On most recordings one transcode process initiated by Plex would hang so only a portion of the show was recorded and would also never finish recording the show. It would always show 100% complete and never finish. What I found was that Plex would always reliably start a recording and ffmpeg would reliably fork the *.ts files from the tuner without exception even when the transcode process for the mpeg file in the grab folder hung. So there are two transcode processes that Plex initiates for each recording, One to fork the ts files and one to generate the file in the grab folder from the mpeg ts files. I wrote a program in C# .NET that fixes the hung and partial recording issue. Its a Console program that runs in the background on the Plex Media Server and fixes the hung Plex transcode process. I've been using it for about a week and can now with %100 reliability use the Plex DVR with the locast2plex tuner to record shows and movies.

tharris9d commented 3 years ago

Can you share your c# project I am running into similar issues.

rottdog32 commented 3 years ago

Hi its in VS2019 using C# .NET for now. How do you want me to share it?

Can you share your c# project I am running into similar issues.

Hi its in VS2019 using C# .NET for now. How do you want me to share it?

MichelLopez commented 3 years ago

Hi its in VS2019 using C# .NET for now. How do you want me to share it?

@rottdog32 could you save it in your fork of this repo ?

hdmllr commented 3 years ago

Has anyone solved the initial issue - DVR recording not stopping when the show is finished? I am also having this problem. I record about 5 shows or so each day, and it happens about once every 2-3 days.

mkoreen commented 3 years ago

I am using Plex on Windows 2019 and have the locast2plex tuner running on Windows 10 as a service. I was having a difficult time getting full recordings using locast2plex as the tuner for Plex. On most recordings one transcode process initiated by Plex would hang so only a portion of the show was recorded and would also never finish recording the show. It would always show 100% complete and never finish. What I found was that Plex would always reliably start a recording and ffmpeg would reliably fork the *.ts files from the tuner without exception even when the transcode process for the mpeg file in the grab folder hung. So there are two transcode processes that Plex initiates for each recording, One to fork the ts files and one to generate the file in the grab folder from the mpeg ts files. I wrote a program in C# .NET that fixes the hung and partial recording issue. Its a Console program that runs in the background on the Plex Media Server and fixes the hung Plex transcode process. I've been using it for about a week and can now with %100 reliability use the Plex DVR with the locast2plex tuner to record shows and movies.

@rottdog32 if you could just share the code on your github account or give us a link, no matter what it is, we could either use Visual Studio ourselves or write an equivalent script. Your explanation is not detailed enough for us to figure out how we're supposed to fix it. I'm getting that one of the processes hangs, but we want to see your code so we can figure out how you detect that and either compile your code or write something equivalent.

mkoreen commented 2 years ago

Uh, this is a thread on a locast software, and the locast service shut down. So I think you're reporting your problem in the wrong place.