elringus / imgit

Transform images, video and YouTube links to HTML optimized for web vitals
https://imgit.dev
MIT License
21 stars 1 forks source link

Remote image being processed as a video #8

Closed Fryuni closed 10 months ago

Fryuni commented 10 months ago

I got this on my markdown:

![xkcd about workflow](https://imgs.xkcd.com/comics/workflow.png)

Imgit tries to invoke ffmpeg and convert it to av1, which throws this error:

21:00:09 [ERROR] [vite] [imgit] Command failed: ffmpeg -y -loglevel error -i "/home/lotus/Workspace/blog/public/imgit/fetched/imgs.xkcd.com-comics-workflow.png" -c:v libaom-av1 -still-picture 1 -crf 23 -cpu-used 5 -an -filter_complex "[0:v]scale=iw*1:-1" "/home/lotus/Workspace/blog/public/imgit/encoded/imgs.xkcd.com-comics-workflow.png@main.avif"
Unrecognized option 'still-picture'.
Error splitting the argument list: Option not found

ffmpeg info:

ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.3.0 (GCC)
  configuration: --disable-static --prefix=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0 --target_os=linux --arch=x86_64 --pkg-config=pkg-config --enable-gpl --enable-version3 --disable-nonfree --enable-shared --enable-pic --disable-small --enable-runtime-cpudetect --disable-gray --enable-swscale-alpha --enable-hardcoded-tables --enable-safe-bitstream-reader --enable-pthreads --disable-w32threads --disable-os2threads --enable-network --enable-pixelutils --datadir=/nix/store/5zl2754g2r43yp553634fzbligcvj172-ffmpeg-6.0-data/share/ffmpeg --enable-ffmpeg --disable-ffplay --enable-ffprobe --bindir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-bin/bin --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avutil --enable-postproc --enable-swresample --enable-swscale --libdir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-lib/lib --incdir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-dev/include --enable-doc --enable-htmlpages --enable-manpages --mandir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-man/share/man --enable-podpages --enable-txtpages --docdir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-doc/share/doc/ffmpeg --enable-alsa --enable-bzlib --disable-libcelt --disable-cuda --disable-cuda-llvm --enable-libdav1d --disable-libfdk-aac --disable-libflite --enable-fontconfig --enable-libfreetype --disable-frei0r --disable-libfribidi --disable-libgme --enable-gnutls --disable-libgsm --disable-ladspa --enable-libmp3lame --disable-libaom --enable-libass --disable-libbluray --disable-libbs2b --disable-libdc1394 --enable-libdrm --enable-iconv --disable-libjack --disable-libmfx --disable-libmodplug --disable-libmysofa --enable-libopus --disable-librsvg --enable-libsrt --enable-libssh --disable-libtensorflow --enable-libtheora --enable-libv4l2 --enable-v4l2-m2m --enable-vaapi --enable-vdpau --enable-libvorbis --disable-libvmaf --enable-libvpx --disable-libwebp --disable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-libxcb-shape --disable-libxml2 --enable-lzma --enable-cuvid --enable-nvdec --enable-nvenc --disable-openal --disable-opencl --disable-libopencore-amrnb --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --enable-libpulse --disable-librav1e --enable-libsvtav1 --disable-librtmp --enable-sdl2 --enable-libsoxr --enable-libspeex --disable-libvidstab --disable-libvo-amrwbenc --enable-libx264 --enable-libx265 --disable-libxavs --enable-libxvid --disable-libzmq --enable-libzimg --enable-zlib --disable-vulkan --disable-libglslang --disable-libsmbclient --disable-debug --enable-optimizations --disable-extra-warnings --disable-stripping
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Hyper fast Audio and Video encoder
elringus commented 10 months ago

I don't think it's trying to convert it to a video (the output file is .avif), but rather your build of ffmpeg is either missing libaom or it's an older version, which doesn't support still-picture option (hence the "Unrecognized option 'still-picture'" error).

elringus commented 10 months ago

To check if libaom is enabled, you can try ffmpeg -buildconf; it should list --enable-libaom in the output. Unfortunately, there doesn't seem to be a way to check actual version of a lib with ffmpeg. You can try manually encoding an image with the still-picture option, to check if it supports it, eg: ffmpeg -i ./img.png -c:v libaom-av1 -still-picture 1 img.avif. I've tested with ffmpeg installed on Ubuntu 13.2.0 via apt, seem to work ok.

Fryuni commented 10 months ago

Got it. Probably due to how Nix builds it. I'll try to figure it out. It works on a separate machine with the same code. Thanks!