Changeset 79f00c5 in Klonkt


Ignore:
Timestamp:
07/30/2026 08:02:16 AM (6 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
15f1cb5
Parents:
9ed940e
Message:

De posters gebruiken de ffmpeg die Klonkt al meebrengt

Robins opmerking: Klonkt shipt al een static build. Klopt, en ik keek erlangs:
ffmpeg-static staat in package.json en VideoCoverService en AudioTranscoder
gebruiken hem al. De poster-spawn was de enige plek die een kale ffmpeg van
PATH verwachtte, en daarmee was de hele installeer-discussie overbodig.

Nu doet de gebundelde binary het werk, als soft dependency zoals de
transcoder: afwezig blijft stil, FFMPEG_PATH blijft als override voor wie een
nieuwere wil. Posters werken dus overal zodra de vloot deze code draait,
zonder ook maar iets te installeren.

Changed files:
src/routes/activitypub.js

  • de poster-spawn importeert ffmpeg-static en valt terug op FFMPEG_PATH

remarks: 338 tests groen.

-robo
Co-Authored-By: Claude Opus 5 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/activitypub.js

    r9ed940e r79f00c5  
    317317    // fall back to extracting a frame natively.
    318318    if (mime.startsWith('video/')) {
    319       import('child_process').then(({ execFile }) => {
     319      // The bundled static build (ffmpeg-static) does the work, exactly like
     320      // VideoCoverService and AudioTranscoder already do: Klonkt SHIPS its
     321      // ffmpeg (Robins opmerking, 30-7), so nothing needs installing on any
     322      // machine. Soft dependency + best-effort: absent stays silent, and
     323      // FFMPEG_PATH can still override for an operator who wants a newer one.
     324      Promise.all([import('child_process'), import('ffmpeg-static')]).then(([{ execFile }, ff]) => {
     325        const bin = process.env.FFMPEG_PATH || ff.default;
     326        if (!bin) return;
    320327        const poster = req.file.path + '.poster.jpg';
    321         // FFMPEG_PATH lets a static build in ~/bin do the work without a
    322         // system install; unset means "whatever is on PATH", and neither is
    323         // an error when absent.
    324         execFile(process.env.FFMPEG_PATH || 'ffmpeg', ['-y', '-ss', '1', '-i', req.file.path, '-frames:v', '1', '-vf', "scale='min(640,iw)':-2", poster],
     328        execFile(bin, ['-hide_banner', '-loglevel', 'error', '-y', '-ss', '1', '-i', req.file.path, '-frames:v', '1', '-vf', "scale='min(640,iw)':-2", poster],
    325329          { timeout: 30000 }, (e) => { if (e && e.code !== 'ENOENT') console.warn('[media] poster failed:', e.message); });
    326330      }).catch(() => { /* never blocks the upload */ });
Note: See TracChangeset for help on using the changeset viewer.