mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 02:41:06 -05:00
fix(ffmpeg): add fallback to absolute imports in __init__.py
This commit is contained in:
@@ -18,30 +18,59 @@ logging.basicConfig(
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
# Import components after logging is configured
|
||||
from .ffmpeg_manager import FFmpegManager
|
||||
from .video_analyzer import VideoAnalyzer
|
||||
from .gpu_detector import GPUDetector
|
||||
from .encoder_params import EncoderParams
|
||||
from .ffmpeg_downloader import FFmpegDownloader
|
||||
from .exceptions import (
|
||||
FFmpegError,
|
||||
DownloadError,
|
||||
VerificationError,
|
||||
EncodingError,
|
||||
AnalysisError,
|
||||
GPUError,
|
||||
HardwareAccelerationError,
|
||||
FFmpegNotFoundError,
|
||||
FFprobeError,
|
||||
CompressionError,
|
||||
FormatError,
|
||||
PermissionError,
|
||||
TimeoutError,
|
||||
ResourceError,
|
||||
QualityError,
|
||||
AudioError,
|
||||
BitrateError,
|
||||
)
|
||||
try:
|
||||
# Try relative imports first
|
||||
from .ffmpeg_manager import FFmpegManager
|
||||
from .video_analyzer import VideoAnalyzer
|
||||
from .gpu_detector import GPUDetector
|
||||
from .encoder_params import EncoderParams
|
||||
from .ffmpeg_downloader import FFmpegDownloader
|
||||
from .exceptions import (
|
||||
FFmpegError,
|
||||
DownloadError,
|
||||
VerificationError,
|
||||
EncodingError,
|
||||
AnalysisError,
|
||||
GPUError,
|
||||
HardwareAccelerationError,
|
||||
FFmpegNotFoundError,
|
||||
FFprobeError,
|
||||
CompressionError,
|
||||
FormatError,
|
||||
PermissionError,
|
||||
TimeoutError,
|
||||
ResourceError,
|
||||
QualityError,
|
||||
AudioError,
|
||||
BitrateError,
|
||||
)
|
||||
except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
from videoarchiver.ffmpeg.ffmpeg_manager import FFmpegManager
|
||||
from videoarchiver.ffmpeg.video_analyzer import VideoAnalyzer
|
||||
from videoarchiver.ffmpeg.gpu_detector import GPUDetector
|
||||
from videoarchiver.ffmpeg.encoder_params import EncoderParams
|
||||
from videoarchiver.ffmpeg.ffmpeg_downloader import FFmpegDownloader
|
||||
from videoarchiver.ffmpeg.exceptions import (
|
||||
FFmpegError,
|
||||
DownloadError,
|
||||
VerificationError,
|
||||
EncodingError,
|
||||
AnalysisError,
|
||||
GPUError,
|
||||
HardwareAccelerationError,
|
||||
FFmpegNotFoundError,
|
||||
FFprobeError,
|
||||
CompressionError,
|
||||
FormatError,
|
||||
PermissionError,
|
||||
TimeoutError,
|
||||
ResourceError,
|
||||
QualityError,
|
||||
AudioError,
|
||||
BitrateError,
|
||||
)
|
||||
|
||||
|
||||
class FFmpeg:
|
||||
"""Main FFmpeg interface"""
|
||||
@@ -150,6 +179,7 @@ class FFmpeg:
|
||||
logger.error(f"Failed to get FFmpeg version: {e}")
|
||||
raise FFmpegError(f"Failed to get FFmpeg version: {e}")
|
||||
|
||||
|
||||
# Initialize default instance
|
||||
try:
|
||||
ffmpeg = FFmpeg()
|
||||
@@ -158,6 +188,7 @@ except Exception as e:
|
||||
logger.error(f"Failed to initialize default FFmpeg instance: {e}")
|
||||
ffmpeg = None
|
||||
|
||||
|
||||
__all__ = [
|
||||
'FFmpeg',
|
||||
'ffmpeg',
|
||||
|
||||
Reference in New Issue
Block a user