• fileinfo.js: fast built-in viewer for media files (audio/image/video)

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Sun Nov 15 17:03:50 2026
    open https://gitlab.synchro.net/main/sbbs/-/work_items/1352

    ## Summary

    Add a stock JavaScript viewer module, `exec/fileinfo.js`, that identifies a media file from its content and prints its details by reading only the first and last few KB of the file. It would be configured as a viewable-file-type command (`?fileinfo %f`) in `ctrl/file.ini`, alongside the existing `?printfile %s` and `?archive list %f` viewers.

    ## Motivation

    The stock `ctrl/file.ini` has no viewer for audio, image, or video files. Sysops who want one configure an external program, e.g. `%@mp3info -x %~` for MP3 files. That approach has problems:

    - **Slow on VBR files.** `mp3info -x` appears to read every frame of a variable-bitrate MP3 to compute its length and bitrate. Viewing a 45 MB, 25-minute VBR file on a network share produced a long pause before any output.
    - **One program per format.** `mp3info` handles MP3 only; other formats each need their own tool.
    - **Not portable.** A Unix-style `file` utility would cover the "what is this file" case, but there is no version suitable for shipping with Synchronet for Windows (the available builds depend on a POSIX runtime layer and a separate magic database).
    - **Not shipped.** External viewers are binaries the sysop has to find and install for each platform.

    A JavaScript module needs no C/C++ change, behaves the same on Windows and \*nix, and ships in `exec/`.

    ## Proposed behavior

    - **Identify by content, not extension.** Check magic bytes, as `file` does, so a mislabeled file is still reported correctly.
    - **Audio.** MP3: MPEG version/layer, bitrate, sample rate, channel mode, and ID3v1/ID3v2 title, artist, album, and year. Also FLAC, Ogg, WAV, and M4A headers.
    - **Images.** Format and pixel dimensions for JPEG, PNG, GIF, and BMP.
    - **Video.** Container type, plus duration and dimensions where they are stored in the header (MP4/MOV, AVI). Other containers report type only.
    - **Bounded I/O.** Never scan the whole file, so viewing is fast regardless of file size or storage location.

    ### MP3 length

    A VBR file with a Xing/Info header gives an exact length from the frame count in that header. A VBR file without one would show a length estimated from the first frame's bitrate, marked as approximate.

    ## Configuration

    Add viewer entries for the media file extensions to the stock `ctrl/file.ini`, ahead of the catch-all `extension=*` entry (`?archive list %f`), which stays as it is.

    ## Suggested first cut

    MP3, FLAC, WAV, Ogg, and the four image formats. Video containers to follow.

    — *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)