Spaces:
Paused
Paused
File size: 4,215 Bytes
16ae242 302ebcd 8c2dbb7 16ae242 302ebcd 16ae242 8c2dbb7 f193001 99b0174 16ae242 f193001 16ae242 6badab8 99b0174 8c2dbb7 16ae242 8c2dbb7 16ae242 8c2dbb7 16ae242 8c2dbb7 6badab8 16ae242 8c2dbb7 f193001 da8fc44 d1f8dcc da8fc44 d1f8dcc a39df2c da8fc44 d1f8dcc a39df2c da8fc44 d1f8dcc da8fc44 16ae242 83fb215 16ae242 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | # ── Stage 1: compilação (imagem devel com headers CUDA) ───────
FROM nvidia/cuda:12.4.1-devel-ubuntu22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential nasm yasm bzip2 git wget \
libfdk-aac-dev libx264-dev libx265-dev libnuma-dev zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# nv-codec-headers (necessário para h264_nvenc / hevc_nvenc / cuvid)
RUN git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git /tmp/nv-codec-headers \
&& make -C /tmp/nv-codec-headers install \
&& rm -rf /tmp/nv-codec-headers
# Compila ffmpeg 7.1.1 — SEM --disable-everything.
# O --disable-everything desabilita a infraestrutura interna (mpegvideo,
# bwdif, etc.) e o configure silenciosamente ignora componentes que
# dependem dessa infra, mesmo com --enable-decoder/demuxer/filter explícitos.
# Compilando com todos os componentes padrão, garantimos suporte completo
# a VOB, MPG, TS, e qualquer formato, sem surpresas.
RUN wget -q -O /tmp/ffmpeg.tar.bz2 https://ffmpeg.org/releases/ffmpeg-7.1.1.tar.bz2 \
&& tar xf /tmp/ffmpeg.tar.bz2 -C /tmp \
&& rm /tmp/ffmpeg.tar.bz2 \
&& cd /tmp/ffmpeg-7.1.1 \
&& ./configure \
--prefix=/usr/local \
--enable-gpl \
--enable-nonfree \
--enable-libx264 \
--enable-libx265 \
--enable-libfdk-aac \
--enable-nvenc \
--enable-nvdec \
--enable-cuda \
--enable-cuvid \
--enable-zlib \
--extra-cflags="-O2 -pipe -I/usr/local/cuda/include" \
--extra-ldflags="-s -L/usr/local/cuda/lib64" \
--disable-doc \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
&& make -j"$(nproc)" \
&& make install \
&& rm -rf /tmp/ffmpeg-7.1.1
# ── Stage 2: imagem final (runtime leve) ──────────────────────
FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
# Só as libs de runtime necessárias
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip ca-certificates \
libfdk-aac2 libx264-163 libx265-199 libnuma1 zlib1g \
&& rm -rf /var/lib/apt/lists/*
# Copia apenas os binários compilados do stage 1
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=builder /usr/local/bin/ffprobe /usr/local/bin/ffprobe
# ── Validação rápida dos componentes essenciais ──
# Usa grep -qE com \s+ para ser tolerante ao formato de colunas do FFmpeg,
# que usa espaçamento variável. Falhas são WARNING (não matam o build),
# pois sem --disable-everything todos os componentes padrão vêm habilitados.
RUN ffmpeg -version | head -1; \
echo "--- encoders ---"; \
for c in libx264 libx265 h264_nvenc hevc_nvenc libfdk_aac; do \
ffmpeg -encoders 2>/dev/null | grep -qE "\\s${c}\\s" && echo " ✅ $c" || echo " ⚠️ $c NÃO encontrado"; \
done; \
echo "--- decoders ---"; \
for c in h264 hevc vp9 aac mp3 mpeg2video mpeg2_cuvid h264_cuvid hevc_cuvid; do \
ffmpeg -decoders 2>/dev/null | grep -qE "\\s${c}\\s" && echo " ✅ $c" || echo " ⚠️ $c NÃO encontrado"; \
done; \
echo "--- hwaccels ---"; \
ffmpeg -hwaccels 2>/dev/null | grep -qE "cuda" && echo " ✅ cuda hwaccel" || echo " ⚠️ cuda hwaccel NÃO encontrado"; \
ffmpeg -hwaccels 2>/dev/null | grep -qE "mpeg2_nvdec" && echo " ✅ mpeg2_nvdec" || echo " ⚠️ mpeg2_nvdec NÃO encontrado"; \
echo "--- filtros VOB ---"; \
for f in bwdif scale fps mpdecimate loudnorm overlay; do \
ffmpeg -filters 2>/dev/null | grep -qE "\\s${f}\\s" && echo " ✅ $f" || echo " ⚠️ $f NÃO encontrado"; \
done; \
echo "--- demuxers VOB ---"; \
ffmpeg -demuxers 2>/dev/null | grep -qE "\\smpeg\\s" && echo " ✅ mpeg demuxer (VOB)" || echo " ⚠️ mpeg demuxer NÃO encontrado"; \
echo "✅ Validação concluída"
WORKDIR /app
COPY app.py .
RUN pip3 install --no-cache-dir urllib3>=2.0.0 gradio>=5.0.0
EXPOSE 7860
ENV PYTHONUNBUFFERED=1
CMD ["python3", "app.py"]
|