Requirements of ffmpeg for OpenCV

Nix builds OpenCV against ffmpeg [1]. This is basically a linux build using system library functionality. However, ffmpeg by default pulls a lot of transient dependencies. This makes me ask: What exact features are expected from ffmpeg? Can a minimal ffmpeg with basically no external features work, or will that break some (transient) dependencies of OpenCV in unexpected ways? Pointers would be welcome, for example with which features the vendored ffmpeg is configured or what API calls are actually being made.

[1] nixpkgs/pkgs/development/libraries/opencv/4.x.nix at 698214a32beb4f4c8e3942372c694f40848b360d · NixOS/nixpkgs · GitHub

good question.

opencv uses ffmpeg primarily for reading/writing video files on local storage, reading video files and streams on the network.

afaik it’s not used for device access (I could be wrong but it would be news to me).
the audio/video filters of ffmpeg are probably not used, except maybe for color space conversion, and I think OpenCV itself does that.

for specific facts, you could grep the opencv source for ffmpeg api calls, or just the included headers.

this gets printed from cv::getBuildInformation() :


  Video I/O:
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (58.134.100)
      avformat:                  YES (58.76.100)
      avutil:                    YES (56.70.100)
      swscale:                   YES (5.9.100)
      avresample:                YES (4.0.0)
    GStreamer:                   NO
    DirectShow:                  YES
    Media Foundation:            YES
      DXVA:                      YES

you could also look at the prebuilt ffmpeg (used on windows)

actually, opencv does neither depend on ffmpeg or gstreamer at all, it’s all convenience only

Oh i am aware there is no hard dependency. My question was more, what
things can i get away dropping from packaging without impacting the
things users of nixpkgs can do with our packaged OpenCV. As such i don’t
want to remove features that are in use. The codecs look fine, following
codecs are enabled on our minimal ffmpeg:


   libavutil      59. 39.100 / 59. 39.100
   libavcodec     61. 19.101 / 61. 19.101
   libavformat    61.  7.100 / 61.  7.100
   libavdevice    61.  3.100 / 61.  3.100
   libavfilter    10.  4.100 / 10.  4.100
   libswscale      8.  3.100 /  8.  3.100
   libswresample   5.  3.100 /  5.  3.100
   libpostproc    58.  3.100 / 58.  3.100

Thanks for the quick heads-up and where to poke, i’ll investigate further!