Claude Opus 4.8
Deploy PagsDark — site 24/7 (sem túnel, perf otimizada, OAuth e login Google corrigidos)
e0454ce Download src/ffmpeg.js from pagsdark/web: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/spaces/pagsdark/web/resolve/main/src/ffmpeg.js
- Command line
-
hf download hf://spaces/pagsdark/web/src/ffmpeg.js
-
curl -L -o ffmpeg.js https://huggingface.co/spaces/pagsdark/web/resolve/main/src/ffmpeg.js
1.55 kB
| // Aponta o fluent-ffmpeg para os binarios estaticos (sem precisar instalar nada). | |
| import ffmpeg from 'fluent-ffmpeg'; | |
| import ffmpegStatic from 'ffmpeg-static'; | |
| import ffprobeStatic from 'ffprobe-static'; | |
| ffmpeg.setFfmpegPath(ffmpegStatic); | |
| ffmpeg.setFfprobePath(ffprobeStatic.path); | |
| export { ffmpeg }; | |
| // Gera um poster leve (1 frame, JPG ~320px de largura) para usar como thumbnail | |
| // no navegador, em vez de carregar dezenas de <video> ao mesmo tempo (trava o PC). | |
| export function makeThumbnail(videoFile, outPath, seconds = 0.5) { | |
| return new Promise((resolve, reject) => { | |
| ffmpeg(videoFile) | |
| .inputOptions(['-ss', String(seconds)]) // seek rapido antes de decodificar | |
| .outputOptions([ | |
| '-frames:v', '1', | |
| '-vf', 'scale=320:-2:force_original_aspect_ratio=decrease', | |
| '-q:v', '4', | |
| ]) | |
| .on('end', () => resolve(outPath)) | |
| .on('error', (err) => reject(err)) | |
| .save(outPath); | |
| }); | |
| } | |
| // Le metadados (duracao, largura, altura) de um arquivo de video. | |
| export function probe(file) { | |
| return new Promise((resolve, reject) => { | |
| ffmpeg.ffprobe(file, (err, data) => { | |
| if (err) return reject(err); | |
| const streams = data.streams || []; | |
| const stream = streams.find((s) => s.codec_type === 'video') || {}; | |
| resolve({ | |
| duration: Number(data.format?.duration || stream.duration || 0), | |
| width: Number(stream.width || 0), | |
| height: Number(stream.height || 0), | |
| hasAudio: streams.some((s) => s.codec_type === 'audio'), | |
| }); | |
| }); | |
| }); | |
| } | |