Spaces:
Running
Running
Copy-first: reattach TikTok into the same FFmpeg on stall/format flap; never auto-transcode on dimension flap
Browse files
relay.py
CHANGED
|
@@ -195,14 +195,20 @@ class Sender:
|
|
| 195 |
now=time.monotonic()
|
| 196 |
while flap and now-flap[0]>600:flap.popleft()
|
| 197 |
if len(flap)>=int(os.getenv('YOUTUBE_FLAP_LIMIT','4')):
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
| 201 |
return mode
|
| 202 |
def note_format_change(self):
|
| 203 |
self.flap.append(time.monotonic())
|
| 204 |
if len(self.flap)>=int(os.getenv('YOUTUBE_FLAP_LIMIT','4')):
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
@staticmethod
|
| 207 |
def copy_is_safe(declared,probed):
|
| 208 |
"""Stream copy is allowed only on positive proof of H.264, never on absence of evidence.
|
|
|
|
| 195 |
now=time.monotonic()
|
| 196 |
while flap and now-flap[0]>600:flap.popleft()
|
| 197 |
if len(flap)>=int(os.getenv('YOUTUBE_FLAP_LIMIT','4')):
|
| 198 |
+
fb=os.getenv('YOUTUBE_FLAP_FALLBACK_MODE','').strip().lower()
|
| 199 |
+
# copy-first: resolution flap must not switch to transcode unless operator set fixed*.
|
| 200 |
+
if fb in ('fixed1080','fixed720'):
|
| 201 |
+
self.sticky_mode=fb
|
| 202 |
+
mode=fb
|
| 203 |
return mode
|
| 204 |
def note_format_change(self):
|
| 205 |
self.flap.append(time.monotonic())
|
| 206 |
if len(self.flap)>=int(os.getenv('YOUTUBE_FLAP_LIMIT','4')):
|
| 207 |
+
fb=os.getenv('YOUTUBE_FLAP_FALLBACK_MODE','').strip().lower()
|
| 208 |
+
if fb in ('fixed1080','fixed720'):
|
| 209 |
+
self.log('system','تغيّرت أبعاد المصدر عدة مرات خلال 10 دقائق؛ التحول إلى كانفس ثابت (%s) بطلب المشغّل'%fb)
|
| 210 |
+
else:
|
| 211 |
+
self.log('system','تغيّرت أبعاد المصدر عدة مرات؛ نُبقي copy ونعيد توصيل تيك توك على نفس جلسة يوتيوب')
|
| 212 |
@staticmethod
|
| 213 |
def copy_is_safe(declared,probed):
|
| 214 |
"""Stream copy is allowed only on positive proof of H.264, never on absence of evidence.
|