Reoo88 commited on
Commit
1e71f1c
·
verified ·
1 Parent(s): f4b8a91

Copy-first: reattach TikTok into the same FFmpeg on stall/format flap; never auto-transcode on dimension flap

Browse files
Files changed (1) hide show
  1. relay.py +10 -4
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
- mode=os.getenv('YOUTUBE_FLAP_FALLBACK_MODE','fixed720').strip().lower()
199
- if mode not in ('fixed1080','fixed720'):mode='fixed720'
200
- self.sticky_mode=mode
 
 
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
- self.log('system','تغيّرت أبعاد المصدر عدة مرات خلال 10 دقائق؛ التحول تلقائيًا إلى كانفس ثابت (%s) لمنع تكرار الانقطاع'%os.getenv('YOUTUBE_FLAP_FALLBACK_MODE','fixed720'))
 
 
 
 
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.