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
|
||||
|
||||
# Find all video URLs in message using yt-dlp simulation
|
||||
logger.info(f"Checking message {message.id} for video URLs...")
|
||||
urls = []
|
||||
if message.guild.id in self.components:
|
||||
downloader = self.components[message.guild.id]["downloader"]
|
||||
@@ -327,9 +326,10 @@ class VideoProcessor:
|
||||
# Use yt-dlp simulation to check if URL is supported
|
||||
try:
|
||||
if downloader.is_supported_url(word):
|
||||
logger.info(f"Found supported URL: {word}")
|
||||
urls.append(word)
|
||||
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)}")
|
||||
continue
|
||||
|
||||
@@ -341,8 +341,6 @@ class VideoProcessor:
|
||||
priority = len(urls) - i
|
||||
logger.info(f"Processing URL {url} with priority {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:
|
||||
logger.error(f"Error processing message: {traceback.format_exc()}")
|
||||
|
||||
@@ -269,19 +269,28 @@ class VideoDownloader:
|
||||
f"compressed_{os.path.basename(original_file)}",
|
||||
)
|
||||
|
||||
# Configure ffmpeg with optimal parameters
|
||||
stream = ffmpeg.input(original_file)
|
||||
stream = ffmpeg.output(stream, compressed_file, **params)
|
||||
# Run FFmpeg directly with subprocess instead of ffmpeg-python
|
||||
cmd = [
|
||||
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
|
||||
await asyncio.get_event_loop().run_in_executor(
|
||||
self.download_pool,
|
||||
lambda: ffmpeg.run(
|
||||
stream,
|
||||
capture_stdout=True,
|
||||
capture_stderr=True,
|
||||
overwrite_output=True,
|
||||
),
|
||||
lambda: subprocess.run(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=True
|
||||
)
|
||||
)
|
||||
|
||||
if not os.path.exists(compressed_file):
|
||||
|
||||
Reference in New Issue
Block a user