pmrony commited on
Commit
098933b
·
verified ·
1 Parent(s): 0a25367

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -388,16 +388,16 @@ async def handle_media_upload(client, message):
388
 
389
  try:
390
  original_file = await message.download(progress=download_progress)
391
- clean_upload_file = original_file # ডিফল্টভাবে অরিজিনাল ফাইলই ক্লিন ফাইল
392
 
393
- # ১. ওয়াটারমার্ক (Watermark) করা - HD Quality
394
  if media_type == "video" and not is_large_video:
395
- await status_msg.edit_text("⏳ Watermarking video... (High Quality Processing)")
396
  watermarked_file = f"{original_file}_wm.mp4"
397
  cmd = [
398
  "ffmpeg", "-y", "-i", original_file,
399
  "-vf", "drawtext=text='@mxvdo':x=W-tw-20:y=H-th-20:fontsize=22:fontcolor=white@0.7:shadowcolor=black@0.8:shadowx=2:shadowy=2:enable='gte(t,5)'",
400
- "-c:v", "libx264", "-preset", "fast", "-threads", "2", "-crf", "22",
401
  "-pix_fmt", "yuv420p", "-c:a", "copy", "-movflags", "+faststart", watermarked_file
402
  ]
403
  process = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
@@ -433,7 +433,7 @@ async def handle_media_upload(client, message):
433
  await status_msg.delete()
434
  return
435
 
436
- # ৩. টেলিগ্রামে পাঠানোর জন্য ভিডিও ব্লার করা (যদি ব্লার অন থাকে)
437
  telegram_file = clean_upload_file
438
  if is_blur and not is_large_video:
439
  await status_msg.edit_text(f"⏳ Applying {blur_percent}% blur for Telegram broadcast...")
@@ -452,9 +452,9 @@ async def handle_media_upload(client, message):
452
  if media_type == "photo":
453
  cmd_blur = ["ffmpeg", "-y", "-i", clean_upload_file] + ff_filter + [blurred_file]
454
  elif media_type == "animation":
455
- cmd_blur = ["ffmpeg", "-y", "-i", clean_upload_file] + ff_filter + ["-c:v", "libx264", "-preset", "fast", "-threads", "2", "-pix_fmt", "yuv420p", blurred_file]
456
  else:
457
- cmd_blur = ["ffmpeg", "-y", "-i", clean_upload_file] + ff_filter + ["-c:v", "libx264", "-preset", "fast", "-threads", "2", "-crf", "22", "-pix_fmt", "yuv420p", "-c:a", "copy", "-movflags", "+faststart", blurred_file]
458
 
459
  process_blur = await asyncio.create_subprocess_exec(*cmd_blur, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
460
  await process_blur.communicate()
 
388
 
389
  try:
390
  original_file = await message.download(progress=download_progress)
391
+ clean_upload_file = original_file
392
 
393
+ # ১. ওয়াটারমার্ক (Watermark) করা - Balanced (Superfast + CRF 23)
394
  if media_type == "video" and not is_large_video:
395
+ await status_msg.edit_text("⏳ Watermarking video... (HD + Superfast Processing)")
396
  watermarked_file = f"{original_file}_wm.mp4"
397
  cmd = [
398
  "ffmpeg", "-y", "-i", original_file,
399
  "-vf", "drawtext=text='@mxvdo':x=W-tw-20:y=H-th-20:fontsize=22:fontcolor=white@0.7:shadowcolor=black@0.8:shadowx=2:shadowy=2:enable='gte(t,5)'",
400
+ "-c:v", "libx264", "-preset", "superfast", "-crf", "23",
401
  "-pix_fmt", "yuv420p", "-c:a", "copy", "-movflags", "+faststart", watermarked_file
402
  ]
403
  process = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
 
433
  await status_msg.delete()
434
  return
435
 
436
+ # ৩. টেলিগ্রামে পাঠানোর জন্য ভিডিও ব্লার করা
437
  telegram_file = clean_upload_file
438
  if is_blur and not is_large_video:
439
  await status_msg.edit_text(f"⏳ Applying {blur_percent}% blur for Telegram broadcast...")
 
452
  if media_type == "photo":
453
  cmd_blur = ["ffmpeg", "-y", "-i", clean_upload_file] + ff_filter + [blurred_file]
454
  elif media_type == "animation":
455
+ cmd_blur = ["ffmpeg", "-y", "-i", clean_upload_file] + ff_filter + ["-c:v", "libx264", "-preset", "superfast", "-pix_fmt", "yuv420p", blurred_file]
456
  else:
457
+ cmd_blur = ["ffmpeg", "-y", "-i", clean_upload_file] + ff_filter + ["-c:v", "libx264", "-preset", "superfast", "-crf", "23", "-pix_fmt", "yuv420p", "-c:a", "copy", "-movflags", "+faststart", blurred_file]
458
 
459
  process_blur = await asyncio.create_subprocess_exec(*cmd_blur, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
460
  await process_blur.communicate()