Spaces:
Sleeping
Sleeping
Devank Upadhyaya commited on
Commit ·
41410d8
1
Parent(s): 689d01c
Add ffmpeg and yt-dlp timeout
Browse filesFiles changed (2)
- Dockerfile+2-1
- tools.py+15-7
5 unmodified lines67891011121314155 unmodified lines# Set the working directory to /appWORKDIR /app# Install system dependencies required for MediaPipe and OpenCVRUN apt-get update && apt-get install -y \libgl1 \libglib2.0-0 \&& rm -rf /var/lib/apt/lists/*# Copy the final requirements file into the container5 unmodified lines6789101112131415165 unmodified lines# Set the working directory to /appWORKDIR /app# Install system dependencies required for MediaPipe, OpenCV, and video processingRUN apt-get update && apt-get install -y \libgl1 \libglib2.0-0 \ffmpeg \&& rm -rf /var/lib/apt/lists/*# Copy the final requirements file into the container
146 unmodified lines147148149150151152153154155156157158159160161146 unmodified linesfor fmt in format_options:cmd = ["yt-dlp", "-f", fmt, "--no-playlist", "--no-warnings", "-o", out_path, url]logger.debug(f"Trying yt-dlp format: {fmt}")result = subprocess.run(cmd, capture_output=True, text=True)if result.returncode == 0 and os.path.exists(out_path):logger.debug(f"Download succeeded: {fmt}")return out_pathlast_error = result.stderrfallback_template = out_path.replace(".mp4", ".%(ext)s")subprocess.run(["yt-dlp", "--no-playlist", "--no-warnings", "-o", fallback_template, url],capture_output=True, text=True)base = out_path.replace(".mp4", "")possible = [f"{base}.{ext}" for ext in ["mp4", "webm", "mkv", "avi", "mov"]]for p in possible:146 unmodified lines147148149150151152153154155156157158159160161162163164165166167168169146 unmodified linesfor fmt in format_options:cmd = ["yt-dlp", "-f", fmt, "--no-playlist", "--no-warnings", "-o", out_path, url]logger.debug(f"Trying yt-dlp format: {fmt}")try:result = subprocess.run(cmd, capture_output=True, text=True, timeout=60)if result.returncode == 0 and os.path.exists(out_path):logger.debug(f"Download succeeded: {fmt}")return out_pathlast_error = result.stderrexcept subprocess.TimeoutExpired as e:last_error = f"Timeout for format {fmt}: {e}"logger.error(last_error)fallback_template = out_path.replace(".mp4", ".%(ext)s")try:subprocess.run(["yt-dlp", "--no-playlist", "--no-warnings", "-o", fallback_template, url],capture_output=True, text=True, timeout=60)except subprocess.TimeoutExpired as e:logger.error(f"Fallback timeout: {e}")base = out_path.replace(".mp4", "")possible = [f"{base}.{ext}" for ext in ["mp4", "webm", "mkv", "avi", "mov"]]for p in possible:
Dockerfile+2-1
tools.py+15-7