Unverified Commit 4211063d authored by Ulysses Zhan's avatar Ulysses Zhan
Browse files

megacmd: fix build with ffmpeg; add option to build with freeimage

parent 3b413092
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
--- a/sdk/src/gfx/freeimage.cpp
+++ b/sdk/src/gfx/freeimage.cpp
@@ -216,11 +216,13 @@ bool GfxProviderFreeImage::readbitmapFreeimage(const LocalPath& imagePath, int s
 
 #ifdef HAVE_FFMPEG
 
+#if LIBAVCODEC_VERSION_MAJOR < 60
 #ifdef AV_CODEC_CAP_TRUNCATED
 #define CAP_TRUNCATED AV_CODEC_CAP_TRUNCATED
 #else
 #define CAP_TRUNCATED CODEC_CAP_TRUNCATED
 #endif
+#endif
 
 const char *GfxProviderFreeImage::supportedformatsFfmpeg()
 {
@@ -323,10 +325,12 @@ bool GfxProviderFreeImage::readbitmapFfmpeg(const LocalPath& imagePath, int size
 
     // Force seeking to key frames
     formatContext->seek2any = false;
+#if LIBAVCODEC_VERSION_MAJOR < 60
     if (decoder->capabilities & CAP_TRUNCATED)
     {
         codecContext->flags |= CAP_TRUNCATED;
     }
+#endif
 
     AVPixelFormat sourcePixelFormat = static_cast<AVPixelFormat>(codecParm->format);
     AVPixelFormat targetPixelFormat = AV_PIX_FMT_BGR24; //raw data expected by freeimage is in this format
+14 −8
Original line number Diff line number Diff line
@@ -6,9 +6,8 @@
  cryptopp,
  curl,
  fetchFromGitHub,
  # build fails with latest ffmpeg, see https://github.com/meganz/MEGAcmd/issues/523.
  # to be re-enabled when patch available
  # ffmpeg,
  ffmpeg,
  freeimage,
  gcc-unwrapped,
  icu,
  libmediainfo,
@@ -20,6 +19,7 @@
  pkg-config,
  readline,
  sqlite,
  withFreeImage ? false, # default to false because freeimage is insecure
}:

let
@@ -47,7 +47,7 @@ stdenv.mkDerivation {
    c-ares
    cryptopp
    curl
    # ffmpeg
    ffmpeg
    icu
    gcc-unwrapped
    libmediainfo
@@ -58,7 +58,7 @@ stdenv.mkDerivation {
    pcre-cpp
    readline
    sqlite
  ];
  ] ++ lib.optionals withFreeImage [ freeimage ];

  configureFlags = [
    "--disable-curl-checks"
@@ -66,8 +66,7 @@ stdenv.mkDerivation {
    "--with-cares"
    "--with-cryptopp"
    "--with-curl"
    # "--with-ffmpeg"
    "--without-freeimage" # disabled as freeimage is insecure
    "--with-ffmpeg"
    "--with-icu"
    "--with-libmediainfo"
    "--with-libuv"
@@ -76,6 +75,10 @@ stdenv.mkDerivation {
    "--with-readline"
    "--with-sodium"
    "--with-termcap"
  ] ++ (if withFreeImage then [ "--with-freeimage" ] else [ "--without-freeimage" ]);

  patches = [
    ./fix-ffmpeg.patch # https://github.com/meganz/sdk/issues/2635#issuecomment-1495405085
  ];

  meta = {
@@ -89,6 +92,9 @@ stdenv.mkDerivation {
      "i686-linux"
      "x86_64-linux"
    ];
    maintainers = with lib.maintainers; [ lunik1 ];
    maintainers = with lib.maintainers; [
      lunik1
      ulysseszhan
    ];
  };
}