# Requirements of ffmpeg for OpenCV

**URL:** <https://forum.opencv.org/t/requirements-of-ffmpeg-for-opencv/20671>\
**Category:** Uncategorized\
**Tags:** ffmpeg, nix, videoio, build\
**Created:** [March 28, 2025, 9:28pm UTC](https://forum.opencv.org/t/requirements-of-ffmpeg-for-opencv/20671 "2025-03-28T21:28:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grimmauld](https://avatars.discourse-cdn.com/v4/letter/g/e274bd/32.png) [@Grimmauld](https://forum.opencv.org/u/Grimmauld)\
**Post date:** [March 28, 2025, 9:28pm UTC](https://forum.opencv.org/t/requirements-of-ffmpeg-for-opencv/20671/1 "2025-03-28T21:28:10Z")

</div>

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](https://github.com/NixOS/nixpkgs/blob/698214a32beb4f4c8e3942372c694f40848b360d/pkgs/development/libraries/opencv/4.x.nix#L384)

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 29, 2025, 11:38am UTC](https://forum.opencv.org/t/requirements-of-ffmpeg-for-opencv/20671/2 "2025-03-29T11:38:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [March 29, 2025, 11:55am UTC](https://forum.opencv.org/t/requirements-of-ffmpeg-for-opencv/20671/3 "2025-03-29T11:55:02Z")

</div>

this gets printed from cv::getBuildInformation() :

```auto

  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](https://github.com/opencv/opencv/blob/4.x/modules/videoio/src/cap_ffmpeg_impl.hpp) (used on windows)

actually, opencv does neither _depend_ on ffmpeg or gstreamer _at all_, it’s all convenience only

---

<div class="post-metadata">

**Author:** ![Grimmauld](https://avatars.discourse-cdn.com/v4/letter/g/e274bd/32.png) [@Grimmauld](https://forum.opencv.org/u/Grimmauld)\
**Post date:** [March 29, 2025, 8:28pm UTC](https://forum.opencv.org/t/requirements-of-ffmpeg-for-opencv/20671/4 "2025-03-29T20:28:49Z")

</div>

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:

```auto

   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!
