mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 10:51:05 -05:00
Fixed FFmpeg/FFprobe Integration:
Added proper ffprobe binary download alongside FFmpeg Added proper path handling for both binaries Added verification of both binaries Fixed FFmpeg compression by using subprocess directly instead of ffmpeg-python Improved URL Detection: Switched from regex patterns to yt-dlp simulation for URL detection Added better error handling for URL checking Added detailed logging of URL detection results Reduced Logging Noise: Only log when a message contains a video URL Only log URL check errors for actual URLs (containing http://, https://, or www.) Removed unnecessary debug logging
This commit is contained in:
@@ -317,7 +317,6 @@ class VideoProcessor:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Find all video URLs in message using yt-dlp simulation
|
# Find all video URLs in message using yt-dlp simulation
|
||||||
logger.info(f"Checking message {message.id} for video URLs...")
|
|
||||||
urls = []
|
urls = []
|
||||||
if message.guild.id in self.components:
|
if message.guild.id in self.components:
|
||||||
downloader = self.components[message.guild.id]["downloader"]
|
downloader = self.components[message.guild.id]["downloader"]
|
||||||
@@ -327,9 +326,10 @@ class VideoProcessor:
|
|||||||
# Use yt-dlp simulation to check if URL is supported
|
# Use yt-dlp simulation to check if URL is supported
|
||||||
try:
|
try:
|
||||||
if downloader.is_supported_url(word):
|
if downloader.is_supported_url(word):
|
||||||
logger.info(f"Found supported URL: {word}")
|
|
||||||
urls.append(word)
|
urls.append(word)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
# Only log URL check errors if it's actually a URL
|
||||||
|
if any(site in word for site in ["http://", "https://", "www."]):
|
||||||
logger.error(f"Error checking URL {word}: {str(e)}")
|
logger.error(f"Error checking URL {word}: {str(e)}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -341,8 +341,6 @@ class VideoProcessor:
|
|||||||
priority = len(urls) - i
|
priority = len(urls) - i
|
||||||
logger.info(f"Processing URL {url} with priority {priority}")
|
logger.info(f"Processing URL {url} with priority {priority}")
|
||||||
await self.process_video_url(url, message, priority)
|
await self.process_video_url(url, message, priority)
|
||||||
else:
|
|
||||||
logger.info(f"No video URLs found in message {message.id}")
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error processing message: {traceback.format_exc()}")
|
logger.error(f"Error processing message: {traceback.format_exc()}")
|
||||||
|
|||||||
@@ -269,19 +269,28 @@ class VideoDownloader:
|
|||||||
f"compressed_{os.path.basename(original_file)}",
|
f"compressed_{os.path.basename(original_file)}",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Configure ffmpeg with optimal parameters
|
# Run FFmpeg directly with subprocess instead of ffmpeg-python
|
||||||
stream = ffmpeg.input(original_file)
|
cmd = [
|
||||||
stream = ffmpeg.output(stream, compressed_file, **params)
|
self.ffmpeg_mgr.get_ffmpeg_path(),
|
||||||
|
"-i", original_file
|
||||||
|
]
|
||||||
|
|
||||||
|
# Add all parameters
|
||||||
|
for key, value in params.items():
|
||||||
|
cmd.extend([f"-{key}", str(value)])
|
||||||
|
|
||||||
|
# Add output file
|
||||||
|
cmd.append(compressed_file)
|
||||||
|
|
||||||
# Run compression in executor
|
# Run compression in executor
|
||||||
await asyncio.get_event_loop().run_in_executor(
|
await asyncio.get_event_loop().run_in_executor(
|
||||||
self.download_pool,
|
self.download_pool,
|
||||||
lambda: ffmpeg.run(
|
lambda: subprocess.run(
|
||||||
stream,
|
cmd,
|
||||||
capture_stdout=True,
|
stdout=subprocess.PIPE,
|
||||||
capture_stderr=True,
|
stderr=subprocess.PIPE,
|
||||||
overwrite_output=True,
|
check=True
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not os.path.exists(compressed_file):
|
if not os.path.exists(compressed_file):
|
||||||
|
|||||||
Reference in New Issue
Block a user