Skip to content

plugins.ustreamtv: re-implement plugin #4164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2021

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Nov 10, 2021

  • replace flvconcat with ffmpegmux
  • add typed namedtuples for stream formats and stream segments
  • implement WebsocketClient
    • simplify message handling and remove state polling
    • use validation schemas to parse messages
    • parse stream formats once
    • add subscribable thread-safe segment queues (deques)
  • rewrite UStreamTVStream{,Reader,Worker,Writer}
  • rename stream shortname from "uhs" to "ustreamtv"
  • simplify segment waiting logic and immediately stop worker and writer
    threads when the stream gets closed
  • find channel ID via XPath
  • simplify stream initialization

ref #4040

This is a complete rewrite of the ustreamtv plugin which uses muxed MPEG4 video and audio streams and finally removes the last import of flash video stuff. 🎉

The streams which I've tested are working fine, but it's possible that I've missed something, so please review carefully.

The websocket initialization has been refactored from the old code and cleaned up a lot. I only thing I checked on their website were the stream format and segment ID/hash messages, which I used for writing the new stream logic. I am not sure about the reconnect functionality (referrer and cluster change) which was already implemented, same with password protected streams.

All state is stored on the websocket client and read safely by the video and audio worker threads. The worker, writer and writer-thread-pool threads should all stop immediately after closing the stream, as they are using the event lock of the worker thread for their wait calls (delayed segment availability), which wasn't the case previously. This means there's no unnecessary dependency on dash_manifest anymore for sleep_until which makes the threads stall.

$ streamlink -l debug 'https://video.ibm.com/embed/1524' best
[cli][debug] OS:         Linux-5.15.1-1-git-x86_64-with-glibc2.33
[cli][debug] Python:     3.9.7
[cli][debug] Streamlink: 2.4.0+80.gf67fdf8
[cli][debug] Requests(2.26.0), Socks(1.7.1), Websocket(1.2.1)
[cli][debug] Arguments:
[cli][debug]  url=https://video.ibm.com/embed/1524
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=mpv
[cli][info] Found matching plugin ustreamtv for URL https://video.ibm.com/embed/1524
[plugins.ustreamtv][debug] Connecting to UStream API: media_id=1524, application=channel, referrer=https://video.ibm.com/embed/1524, cluster=live
[plugins.ustreamtv][debug] Waiting for stream data (for at most 6 seconds)...
[plugins.ustreamtv][debug] Processing 'moduleInfo' - 'cdnConfig'
[plugins.ustreamtv][debug] Processing 'moduleInfo' - 'stream'
[cli][info] Available streams: 252p+a86k (worst), 252p+a124k, 360p+a86k, 360p+a124k, 486p+a86k, 486p+a124k, 1080p+a86k, 1080p+a124k (best)
[cli][info] Opening stream: 1080p+a124k (muxed-stream)
[stream.ffmpegmux][debug] Opening ustreamtv substream
[plugins.ustreamtv][debug] Stream opened, keeping websocket connection alive
[plugins.ustreamtv][debug] Adding video segment 1636462505 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462506 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462507 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462508 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462509 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462510 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462511 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462512 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462513 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462514 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462515 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462516 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462517 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462518 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462519 to queue
[stream.ffmpegmux][debug] Opening ustreamtv substream
[plugins.ustreamtv][debug] Adding audio segment 1636462505 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462506 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462507 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462508 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462509 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462510 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462511 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462512 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462513 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462514 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462515 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462516 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462517 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462518 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462519 to queue
[utils.named_pipe][info] Creating pipe streamlinkpipe-30722-1-7586
[utils.named_pipe][info] Creating pipe streamlinkpipe-30722-2-7068
[stream.ffmpegmux][debug] ffmpeg command: ffmpeg -nostats -y -i /tmp/streamlinkpipe-30722-1-7586 -i /tmp/streamlinkpipe-30722-2-7068 -c:v copy -c:a copy -map 0 -map 1 -f matroska pipe:1
[stream.ffmpegmux][debug] Starting copy to pipe: /tmp/streamlinkpipe-30722-1-7586
[stream.ffmpegmux][debug] Starting copy to pipe: /tmp/streamlinkpipe-30722-2-7068
[cli][debug] Pre-buffering 8192 bytes
[plugins.ustreamtv][debug] Processing 'moduleInfo' - 'stream'
[plugins.ustreamtv][debug] Download of video segment 1636462505 complete
[plugins.ustreamtv][debug] Download of audio segment 1636462505 complete
[plugins.ustreamtv][debug] Download of audio segment 1636462505 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462507 (3.2s)
[plugins.ustreamtv][debug] Download of audio segment 1636462506 complete
[plugins.ustreamtv][debug] Download of video segment 1636462505 complete
[cli][info] Starting player: mpv
[cli.output][debug] Opening subprocess: mpv --force-media-title=https://video.ibm.com/embed/1524 -
[cli][debug] Writing stream to output
[plugins.ustreamtv][debug] Waiting for video segment: 1636462507 (2.2s)
[plugins.ustreamtv][debug] Download of video segment 1636462506 complete
[plugins.ustreamtv][debug] Processing 'moduleInfo' - 'stream'
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462508 (4.4s)
[plugins.ustreamtv][debug] Download of audio segment 1636462507 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462508 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462507 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462509 (4.4s)
[plugins.ustreamtv][debug] Download of audio segment 1636462508 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462509 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462508 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462510 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462509 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462510 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462509 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462511 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462510 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462511 (3.9s)
[plugins.ustreamtv][debug] Download of video segment 1636462510 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462512 (4.1s)
[plugins.ustreamtv][debug] Download of audio segment 1636462511 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462512 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462511 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462513 (4.0s)
[plugins.ustreamtv][debug] Download of audio segment 1636462512 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462513 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462512 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462514 (4.8s)
[plugins.ustreamtv][debug] Download of audio segment 1636462513 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462514 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462513 complete
[plugins.ustreamtv][debug] Processing 'moduleInfo' - 'stream'
[plugins.ustreamtv][debug] Adding video segment 1636462520 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462521 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462522 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462523 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462524 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462525 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462526 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462527 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462528 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462529 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462520 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462521 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462522 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462523 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462524 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462525 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462526 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462527 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462528 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462529 to queue
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462515 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462514 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462515 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462514 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462516 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462515 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462516 (3.5s)
[plugins.ustreamtv][debug] Download of video segment 1636462515 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462517 (4.4s)
[plugins.ustreamtv][debug] Download of audio segment 1636462516 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462517 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462516 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462518 (4.8s)
[plugins.ustreamtv][debug] Download of audio segment 1636462517 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462518 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462517 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462519 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462518 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462519 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462518 complete
[plugins.ustreamtv][debug] Download of audio segment 1636462519 complete
[plugins.ustreamtv][debug] Download of video segment 1636462519 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462521 (2.6s)
[plugins.ustreamtv][debug] Download of audio segment 1636462520 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462521 (1.4s)
[plugins.ustreamtv][debug] Download of video segment 1636462520 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462522 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462521 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462522 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462521 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462523 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462522 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462523 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462522 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462524 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462523 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462524 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462523 complete
[plugins.ustreamtv][debug] Processing 'moduleInfo' - 'stream'
[plugins.ustreamtv][debug] Adding video segment 1636462530 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462531 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462532 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462533 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462534 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462535 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462536 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462537 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462538 to queue
[plugins.ustreamtv][debug] Adding video segment 1636462539 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462530 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462531 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462532 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462533 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462534 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462535 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462536 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462537 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462538 to queue
[plugins.ustreamtv][debug] Adding audio segment 1636462539 to queue
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462525 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462524 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462525 (4.1s)
[plugins.ustreamtv][debug] Download of video segment 1636462524 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462526 (4.5s)
[plugins.ustreamtv][debug] Download of audio segment 1636462525 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462526 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462525 complete
[plugins.ustreamtv][debug] Waiting for audio segment: 1636462527 (4.4s)
[plugins.ustreamtv][debug] Download of audio segment 1636462526 complete
[plugins.ustreamtv][debug] Waiting for video segment: 1636462527 (4.0s)
[plugins.ustreamtv][debug] Download of video segment 1636462526 complete
[cli][info] Player closed
[stream.ffmpegmux][debug] Closing ffmpeg thread
[stream.segmented][debug] Closing worker thread
[stream.segmented][debug] Closing writer thread
[stream.ffmpegmux][error] Pipe copy aborted: /tmp/streamlinkpipe-30722-1-7586
[stream.ffmpegmux][debug] Pipe copy complete: /tmp/streamlinkpipe-30722-1-7586
[plugin.api.websocket][debug] Closed: wss://r3575994-1-1524-channel-ws-live.ums.ustream.tv:1935/1/ustream
[stream.segmented][debug] Closing worker thread
[stream.segmented][debug] Closing writer thread
[stream.ffmpegmux][debug] Closed all the substreams
[cli][info] Stream ended
[stream.ffmpegmux][debug] Pipe copy complete: /tmp/streamlinkpipe-30722-2-7068
[cli][info] Closing currently open stream...

@bastimeyer bastimeyer added the plugin enhancement A new feature for a working Plugin label Nov 10, 2021
"args": [{str: object}],
})
_schema_stream_formats = validate.Schema({
"streams": [validate.any(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://video.ibm.com/nasahdtv

[plugins.ustreamtv][error]
Unable to validate result: Unable to validate key 'streams':
Unable to validate key 'contentType': 'text/vtt' does not equal 'video/mp4'
or Unable to validate key 'contentType': 'text/vtt' does not equal 'audio/mp4'

[plugins.ustreamtv][debug] Processing 'moduleInfo' - 'stream'
error: No playable streams found on this URL: https://video.ibm.com/nasahdtv

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I didn't check streams with subtitles. I'll take a look at this tomorrow. Shouldn't be too much work. One more validation schema, one more queue and stream for the muxed output, and no initialization segment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a stream with actual subtitles? The ones on the nasahdtv channel exist, but there's no/invalid content, so muxing the subtitle stream doesn't work. The language property is set to unknown, so maybe this needs to be filtered out.

This is the content of a WebVTT segment:

WEBVTT

I've updated the branch with new changes, but without filtering out "invalid" subtitles

@back-to
Copy link
Collaborator

back-to commented Nov 10, 2021

two VOD URLs which work with the current Streamlink version


https://video.ibm.com/recorded/131129777

[plugin.api.websocket][error] cannot join current thread

http://www.ustream.tv/recorded/112470631

Unable to validate key 'streams':
Unable to validate key 'contentType': 'audio/mp4' does not equal 'video/mp4' or Key 'language' not found in

{'codec': 'mp4a.40.2', 'segmentUrl': '1/chunk_%_%.m4a', 'sourceStreamVersion': 1, 'bitrate': 148,
'transcoded': False, 'contentType': 'audio/mp4', 'initUrl': '1/chunk_%_%.m4ah'}

@bastimeyer bastimeyer force-pushed the plugins/ustreamtv/rewrite branch from f67fdf8 to 1358b1e Compare November 11, 2021 11:04
@bastimeyer
Copy link
Member Author

video.ibm.com/recorded/131129777

This changes the cluster property and then needs to reconnect. I haven't tested the reconnect suff yet.

[plugins.ustreamtv][debug] Processing 'reject' - 'cluster'
[plugins.ustreamtv][info] Switching cluster to: omega


www.ustream.tv/recorded/112470631

Looks like I have to make the language property on the audio format tuple optional. Should I just remove it? It's currently not being used.

@bastimeyer bastimeyer force-pushed the plugins/ustreamtv/rewrite branch 2 times, most recently from be7b7b7 to 1bb3214 Compare November 11, 2021 19:12
@bastimeyer
Copy link
Member Author

The reconnect on cluster/referrer change should now be working. I didn't add any tests for the new reconnect method because it's very hard setting up the tests correctly and covering all statements, and I don't want to do this now. Should be working fine though.

Regarding the ustreamtv VODs with a cluster reconnection, sometimes stream format info is not sent in time and the stream times out. I already increased the timeout value from 6 to 10 seconds, but due to the reconnection this isn't enough sometimes. What's weird is that there are media_info/streams commands sent by the server, but they don't include any data.

@back-to
Copy link
Collaborator

back-to commented Nov 11, 2021

with all subtitles on by default, the player might not start or take forever

https://video.ibm.com/recorded/131122343
ffmpeg.exe -nostats -y
-i \\.\pipe\streamlinkpipe-10132-1-9384
-i \\.\pipe\streamlinkpipe-10132-2-2565
-i \\.\pipe\streamlinkpipe-10132-3-7115
-i \\.\pipe\streamlinkpipe-10132-4-9588
-i \\.\pipe\streamlinkpipe-10132-5-601
-i \\.\pipe\streamlinkpipe-10132-6-1525

-c:v copy -c:a copy -map 0 -map 1 -map 2 -map 3 -map 4 -map 5
-metadata:s:s:0 
language=en -metadata:s:s:1 language=zh
-metadata:s:s:2 language=ja -metadata:s:s:3 language=ko -f matroska pipe:1

@bastimeyer
Copy link
Member Author

the player might not start or take forever

Yes, but that has nothing to do with the number of subtitles but with the subtitles themselves if they don't contain any data, as I've said before.

I could add the following diff to select only the subtitles matching the locale settings while --mux-subtitles is set, but that wouldn't fix the issue, so I'd rather remove subtitles entirely if this can't be fixed.

diff --git a/src/streamlink/plugins/ustreamtv.py b/src/streamlink/plugins/ustreamtv.py
index bca8fee2..6e8c5c45 100644
--- a/src/streamlink/plugins/ustreamtv.py
+++ b/src/streamlink/plugins/ustreamtv.py
@@ -496,10 +496,11 @@ class UStreamTV(Plugin):
             sensitive=True,
             metavar="PASSWORD",
             help="A password to access password protected UStream.tv channels."
-        )
+        ),
+        PluginArgument("mux-subtitles", is_global=True)
     )
 
-    STREAM_READY_TIMEOUT = 10
+    STREAM_READY_TIMEOUT = 15
 
     def _get_media_app(self):
         video_id = self.match.group("video_id")
@@ -554,12 +555,14 @@ class UStreamTV(Plugin):
             wsclient.close()
             return
 
-        options = dict(
-            subtitles={
+        options = {}
+        if self.get_option("mux-subtitles"):
+            locale = self.session.localization
+            options.update(subtitles={
                 subtitle.language: UStreamTVStream(self.session, "subtitle", wsclient, subtitle)
                 for subtitle in wsclient.stream_formats_subtitle
-            }
-        )
+                if locale.equivalent(language=subtitle.language, country=subtitle.country)
+            })
 
         if not wsclient.stream_formats_audio:
             for video in wsclient.stream_formats_video:

@bastimeyer bastimeyer force-pushed the plugins/ustreamtv/rewrite branch 2 times, most recently from af2d9c9 to efc839e Compare November 12, 2021 08:29
@bastimeyer
Copy link
Member Author

Let's remove subtitles (for now). I don't want to unnecessarily delay this PR as it's the last barrier to removing all the flash stuff.

The only issue left now are the occasional timeouts on the initial websocket client handshake, when the server doesn't send the supported stream formats in time. I've increased the timeout value from 6 to 15 seconds in order to fix this problem, but that's not a 100% guarantee. Still better than 6 seconds though, which is problematic when reconnecting the websocket.

We could add a --websocket-handshake-timeout parameter for configuring this timeout value, as it's a pattern that's not unique to ustreamtv. The nicolive plugin also needs to wait for data to arrive from the websocket until it can figure out the streams. But that could be done afterwards. Thoughts?

Other than that, what's been changed and what's working now which wasn't working when I first submitted the PR:

  • subtitles and formats which don't match the schemas are now ignored
  • the language property on audio formats is now optional
  • reconnecting to the websocket now works (added as a second commit), in case of ustreamtv for example when the requested cluster is wrong
  • worker threads now initialize their dedicated segment queue instead of hardcoding a video+audio queue

One other thing that I observed is that VODs require more time to initialize because the first video segment takes longer to load than audio segments, but they are requested at the same time, so it must be a server issue.

- replace flvconcat with ffmpegmux
- add typed namedtuples for stream formats and stream segments
- implement WebsocketClient
  - simplify message handling and remove state polling
  - use validation schemas to parse messages
  - parse stream formats once
  - add subscribable thread-safe segment queues (deques)
- rewrite UStreamTVStream{,Reader,Worker,Writer}
- rename stream shortname from "uhs" to "ustreamtv"
- simplify segment waiting logic and immediately stop worker and writer
  threads when the stream gets closed
- find channel ID via XPath
- simplify stream initialization
@bastimeyer bastimeyer force-pushed the plugins/ustreamtv/rewrite branch from efc839e to f2f31de Compare November 12, 2021 09:34
@back-to back-to merged commit 06f6e55 into streamlink:master Nov 12, 2021
@bastimeyer bastimeyer deleted the plugins/ustreamtv/rewrite branch November 12, 2021 15:27
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Nov 13, 2021
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Nov 17, 2021
based on streamlink#4164

- replace flvconcat with ffmpegmux
- add typed namedtuples for stream formats and stream segments
- implement WebsocketClient
  - simplify message handling and remove state polling
  - use validation schemas to parse messages
  - parse stream formats once
  - add subscribable thread-safe segment queues (deques)
- rewrite UStreamTVStream{,Reader,Worker,Writer}
- rename stream shortname from "uhs" to "ustreamtv"
- simplify segment waiting logic and immediately stop worker and writer
  threads when the stream gets closed
- find channel ID via XPath
- simplify stream initialization
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Nov 19, 2021
based on streamlink#4164

- replace flvconcat with ffmpegmux
- add typed namedtuples for stream formats and stream segments
- implement WebsocketClient
  - simplify message handling and remove state polling
  - use validation schemas to parse messages
  - parse stream formats once
  - add subscribable thread-safe segment queues (deques)
- rewrite UStreamTVStream{,Reader,Worker,Writer}
- rename stream shortname from "uhs" to "ustreamtv"
- simplify segment waiting logic and immediately stop worker and writer
  threads when the stream gets closed
- find channel ID via XPath
- simplify stream initialization
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Nov 22, 2021
based on streamlink#4164

- replace flvconcat with ffmpegmux
- add typed namedtuples for stream formats and stream segments
- implement WebsocketClient
  - simplify message handling and remove state polling
  - use validation schemas to parse messages
  - parse stream formats once
  - add subscribable thread-safe segment queues (deques)
- rewrite UStreamTVStream{,Reader,Worker,Writer}
- rename stream shortname from "uhs" to "ustreamtv"
- simplify segment waiting logic and immediately stop worker and writer
  threads when the stream gets closed
- find channel ID via XPath
- simplify stream initialization
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Nov 22, 2021
based on streamlink#4164

- replace flvconcat with ffmpegmux
- add typed namedtuples for stream formats and stream segments
- implement WebsocketClient
  - simplify message handling and remove state polling
  - use validation schemas to parse messages
  - parse stream formats once
  - add subscribable thread-safe segment queues (deques)
- rewrite UStreamTVStream{,Reader,Worker,Writer}
- rename stream shortname from "uhs" to "ustreamtv"
- simplify segment waiting logic and immediately stop worker and writer
  threads when the stream gets closed
- find channel ID via XPath
- simplify stream initialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin enhancement A new feature for a working Plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants