Spaces:
Running
Running
Classify RTMPS filter timeouts as output failures
Browse filesKeep YouTube output timeouts on the ingest-recovery path instead of switching a healthy TikTok FLV source to HLS.
- relay.py +10 -1
- test_ingest_routes.py +9 -1
relay.py
CHANGED
|
@@ -103,7 +103,16 @@ def ffmpeg_output_failure(text):
|
|
| 103 |
'error opening output', 'error writing', 'broken pipe', 'netstream.publish',
|
| 104 |
'server error, publish')) or
|
| 105 |
(('[out#' in low or 'publish stream' in low) and
|
| 106 |
-
any(x in low for x in ('error', 'failed', 'rejected', 'denied', 'unable', 'broken pipe')))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
def redact_stderr(text):
|
|
|
|
| 103 |
'error opening output', 'error writing', 'broken pipe', 'netstream.publish',
|
| 104 |
'server error, publish')) or
|
| 105 |
(('[out#' in low or 'publish stream' in low) and
|
| 106 |
+
any(x in low for x in ('error', 'failed', 'rejected', 'denied', 'unable', 'broken pipe'))) or
|
| 107 |
+
# FFmpeg 7.1 can report an RTMPS write timeout through the output filter
|
| 108 |
+
# instead of [out#]. The exact production line was:
|
| 109 |
+
# [vf#0:0] Error sending frames to consumers: Connection timed out
|
| 110 |
+
# Missing this mark made sender_loop blame/switch a healthy TikTok FLV
|
| 111 |
+
# to HLS even though the failed side was YouTube. Keep the filter/output
|
| 112 |
+
# prefix requirement so an HTTP/HLS *input* timeout is not misclassified.
|
| 113 |
+
(('[out#' in low or '[vf#' in low or '[af#' in low) and
|
| 114 |
+
any(x in low for x in ('error sending frames to consumers',
|
| 115 |
+
'connection timed out', 'connection reset by peer'))))
|
| 116 |
|
| 117 |
|
| 118 |
def redact_stderr(text):
|
test_ingest_routes.py
CHANGED
|
@@ -62,9 +62,17 @@ class DiagnosticTests(unittest.TestCase):
|
|
| 62 |
|
| 63 |
def test_real_output_failures_still_classify(self):
|
| 64 |
for line in ('NetStream.Publish.BadName','[out#0/flv] Error opening output: End of file',
|
| 65 |
-
'Broken pipe','Failed to publish stream'
|
|
|
|
|
|
|
| 66 |
self.assertTrue(ffmpeg_output_failure(line))
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
def test_handshake_trace_is_opt_in_and_local_file_stays_normal(self):
|
| 69 |
s=Sender('/bin/true',lambda *a:None);s.mode_override='copy';s.trace_rtmp=True
|
| 70 |
with patch.dict(os.environ,{'YOUTUBE_FFMPEG_LOGLEVEL':'info'}):
|
|
|
|
| 62 |
|
| 63 |
def test_real_output_failures_still_classify(self):
|
| 64 |
for line in ('NetStream.Publish.BadName','[out#0/flv] Error opening output: End of file',
|
| 65 |
+
'Broken pipe','Failed to publish stream',
|
| 66 |
+
'[vf#0:0 @ 0x55] Error sending frames to consumers: Connection timed out',
|
| 67 |
+
'[af#0:0 @ 0x55] Error sending frames to consumers: Connection reset by peer'):
|
| 68 |
self.assertTrue(ffmpeg_output_failure(line))
|
| 69 |
|
| 70 |
+
def test_source_network_timeouts_are_not_output_failures(self):
|
| 71 |
+
# A TikTok HTTP/HLS read timeout must still follow the source-recovery path.
|
| 72 |
+
for line in ('[https @ 0x55] Connection timed out',
|
| 73 |
+
'[in#0/hls @ 0x55] Connection reset by peer'):
|
| 74 |
+
self.assertFalse(ffmpeg_output_failure(line))
|
| 75 |
+
|
| 76 |
def test_handshake_trace_is_opt_in_and_local_file_stays_normal(self):
|
| 77 |
s=Sender('/bin/true',lambda *a:None);s.mode_override='copy';s.trace_rtmp=True
|
| 78 |
with patch.dict(os.environ,{'YOUTUBE_FFMPEG_LOGLEVEL':'info'}):
|