progweb / gpx2video

Creating video with telemetry overlay from GPX data
GNU General Public License v3.0
186 stars 10 forks source link

[BUILD] av_get_channel_layout_nb_channels was not declared in this scope #7

Closed Zebradil closed 2 years ago

Zebradil commented 2 years ago

Describe the build issue Not able to complete the build with the following error:

gpx2video/src/encoder.cpp:320:43: error: ‘av_get_channel_layout_nb_channels’ was not declared in this scope
  320 |                 codec_context->channels = av_get_channel_layout_nb_channels(codec_context->channel_layout);

To Reproduce

$ git clone https://github.com/progweb/gpx2video.git
$ mkdir gpx2video/build
$ cd gpx2video/build
$ cmake ..
$ make

Desktop (please complete the following information):

progweb commented 2 years ago

Please re-try with the last commit.

Can you show me the ffmpeg release that you use (cmake output) ?

Zebradil commented 2 years ago

Thank you for the quick response!

I updated to the latest commit and here are:

cmake output
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0")
-- Checking for module 'libevent>=2.0.0'
--   Found libevent, version 2.1.12
-- Checking for module 'libssl>=1.0.0'
--   Found libssl, version 1.1.1o
-- Checking for module 'libcurl>=7.38.0'
--   Found libcurl, version 7.83.1
-- Checking for module 'libavutil>=3.0.0'
--   Found libavutil, version 57.17.100
-- Checking for module 'libavformat>=3.0.0'
--   Found libavformat, version 59.16.100
-- Checking for module 'libavcodec>=3.0.0'
--   Found libavcodec, version 59.18.100
-- Checking for module 'libavfilter>=3.0.0'
--   Found libavfilter, version 8.24.100
-- Checking for module 'libswresample>=2.0.0'
--   Found libswresample, version 4.3.100
-- Checking for module 'libswscale>=3.0.0'
--   Found libswscale, version 6.4.100
-- Checking for module 'geographiclib'
--   Found geographiclib, version 2.0
-- Checking for module 'cairo'
--   Found cairo, version 1.17.6
-- Found OpenImageIO: /usr/lib/libOpenImageIO.so;/usr/lib/libOpenImageIO_Util.so (found suitable version "2.3.14", minimum required is "2.1.12")
-- Found EXPAT: /usr/lib/libexpat.so (found version "2.4.8")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zebradil/development/vendor/gpx2video/build
make output
[  1%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/Node.cpp.o
[  2%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/Decimal.cpp.o
[  4%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/String.cpp.o
[  5%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/Unsigned.cpp.o
[  7%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/Map.cpp.o
[  8%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/Widget.cpp.o
[ 10%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/Layout.cpp.o
[ 11%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/Parser.cpp.o
[ 12%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/Report.cpp.o
[ 14%] Building CXX object layoutlib/CMakeFiles/layoutlib.dir/ReportCerr.cpp.o
[ 15%] Linking CXX static library liblayoutlib.a
[ 15%] Built target layoutlib
[ 17%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Node.cpp.o
[ 18%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Decimal.cpp.o
[ 20%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/DateTime.cpp.o
[ 21%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/String.cpp.o
[ 22%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Unsigned.cpp.o
[ 24%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/DGPSStation.cpp.o
[ 25%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Fix.cpp.o
[ 27%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Degrees.cpp.o
[ 28%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Longitude.cpp.o
[ 30%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Latitude.cpp.o
[ 31%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Bounds.cpp.o
[ 32%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/PTSeg.cpp.o
[ 34%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/PT.cpp.o
[ 35%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/EMail.cpp.o
[ 37%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Link.cpp.o
[ 38%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Person.cpp.o
[ 40%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/URI.cpp.o
[ 41%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Copyright.cpp.o
[ 42%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/TRKSeg.cpp.o
[ 44%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Extensions.cpp.o
[ 45%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/TRK.cpp.o
[ 47%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/WPT.cpp.o
[ 48%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/RTE.cpp.o
[ 50%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Metadata.cpp.o
[ 51%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/GPX.cpp.o
[ 52%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Parser.cpp.o
[ 54%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Writer.cpp.o
[ 55%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Report.cpp.o
[ 57%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/ReportCerr.cpp.o
[ 58%] Building CXX object gpxlib/CMakeFiles/gpxlib.dir/Algorithm.cpp.o
[ 60%] Linking CXX static library libgpxlib.a
[ 60%] Built target gpxlib
[ 61%] Building C object CMakeFiles/gpx2video.dir/src/log.c.o
[ 62%] Building C object CMakeFiles/gpx2video.dir/src/evcurl.c.o
/home/zebradil/development/vendor/gpx2video/src/evcurl.c: In function ‘evcurl_ssl_ctx_callback’:
/home/zebradil/development/vendor/gpx2video/src/evcurl.c:65:17: warning: ‘TLSv1_client_method’ is deprecated [-Wdeprecated-declarations]
   65 |                 SSL_CTX_set_ssl_version(context, TLSv1_client_method());
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/openssl/e_os2.h:13,
                 from /usr/include/openssl/ssl.h:15,
                 from /home/zebradil/development/vendor/gpx2video/src/evcurl.c:5:
/usr/include/openssl/ssl.h:1879:1: note: declared here
 1879 | DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_client_method(void))
      | ^~~~~~~~~~~~~~~~~~
/home/zebradil/development/vendor/gpx2video/src/evcurl.c:69:17: warning: ‘TLSv1_1_client_method’ is deprecated [-Wdeprecated-declarations]
   69 |                 SSL_CTX_set_ssl_version(context, TLSv1_1_client_method());
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/openssl/ssl.h:1885:1: note: declared here
 1885 | DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_client_method(void))
      | ^~~~~~~~~~~~~~~~~~
/home/zebradil/development/vendor/gpx2video/src/evcurl.c:73:17: warning: ‘TLSv1_2_client_method’ is deprecated [-Wdeprecated-declarations]
   73 |                 SSL_CTX_set_ssl_version(context, TLSv1_2_client_method());
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/openssl/ssl.h:1891:1: note: declared here
 1891 | DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_client_method(void))
      | ^~~~~~~~~~~~~~~~~~
[ 64%] Building CXX object CMakeFiles/gpx2video.dir/src/evcurl.cpp.o
[ 65%] Building CXX object CMakeFiles/gpx2video.dir/src/gpx.cpp.o
[ 67%] Building CXX object CMakeFiles/gpx2video.dir/src/oiioutils.cpp.o
[ 68%] Building CXX object CMakeFiles/gpx2video.dir/src/ffmpegutils.cpp.o
[ 70%] Building CXX object CMakeFiles/gpx2video.dir/src/decoder.cpp.o
/home/zebradil/development/vendor/gpx2video/src/decoder.cpp: In member function ‘bool Decoder::open(const std::string&, const int&)’:
/home/zebradil/development/vendor/gpx2video/src/decoder.cpp:242:48: warning: invalid conversion from ‘const AVCodec*’ to ‘AVCodec*’ [-fpermissive]
  242 |         AVCodec *decoder = avcodec_find_decoder(avstream_->codecpar->codec_id);
      |                            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                |
      |                                                const AVCodec*
[ 71%] Building CXX object CMakeFiles/gpx2video.dir/src/encoder.cpp.o
/home/zebradil/development/vendor/gpx2video/src/encoder.cpp: In member function ‘bool Encoder::initializeStream(AVMediaType, AVStream**, AVCodecContext**, AVCodecID)’:
/home/zebradil/development/vendor/gpx2video/src/encoder.cpp:273:46: warning: invalid conversion from ‘const AVCodec*’ to ‘AVCodec*’ [-fpermissive]
  273 |         AVCodec *codec = avcodec_find_encoder(codec_id);
      |                          ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
      |                                              |
      |                                              const AVCodec*
[ 72%] Building CXX object CMakeFiles/gpx2video.dir/src/frame.cpp.o
[ 74%] Building CXX object CMakeFiles/gpx2video.dir/src/extractor.cpp.o
[ 75%] Building CXX object CMakeFiles/gpx2video.dir/src/gpx2video.cpp.o
/home/zebradil/development/vendor/gpx2video/src/gpx2video.cpp: In constructor ‘GPX2Video::GPX2Video(event_base*)’:
/home/zebradil/development/vendor/gpx2video/src/gpx2video.cpp:40:9: error: ‘av_register_all’ was not declared in this scope
   40 |         av_register_all();
      |         ^~~~~~~~~~~~~~~
/home/zebradil/development/vendor/gpx2video/src/gpx2video.cpp:41:9: error: ‘avcodec_register_all’ was not declared in this scope
   41 |         avcodec_register_all();
      |         ^~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/gpx2video.dir/build.make:216: CMakeFiles/gpx2video.dir/src/gpx2video.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:139: CMakeFiles/gpx2video.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
progweb commented 2 years ago

Great. You are working with the last ffmpeg release :)

Can you try again with the last fixes.

Zebradil commented 2 years ago

Now it compiles with the following patch applied:

diff --git a/src/audioparams.h b/src/audioparams.h
index 7e52e8a..4681d69 100644
--- a/src/audioparams.h
+++ b/src/audioparams.h
@@ -8,6 +8,7 @@
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
+#include <libavutil/channel_layout.h>
 }

diff --git a/tests/main2.c b/tests/main2.c
index 261ca82..ebbfae0 100644
--- a/tests/main2.c
+++ b/tests/main2.c
@@ -536,8 +536,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

     if ((ret = open_input_file(argv[1])) < 0)
         goto end;
diff --git a/tests/main3.c b/tests/main3.c
index abfba37..85c71bd 100644
--- a/tests/main3.c
+++ b/tests/main3.c
@@ -525,8 +525,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif
    avfilter_register_all();

     if ((ret = open_input_file(argv[1])) < 0)
diff --git a/tests/main4-get.c b/tests/main4-get.c
index 66e0ffa..f6b1b4d 100644
--- a/tests/main4-get.c
+++ b/tests/main4-get.c
@@ -420,8 +420,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

     if ((ret = open_input_file(argv[1])) < 0)
         goto end;
diff --git a/tests/main4.c b/tests/main4.c
index 66a357f..726e62e 100644
--- a/tests/main4.c
+++ b/tests/main4.c
@@ -372,8 +372,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

     if ((ret = open_input_file(argv[1])) < 0)
         goto end;
diff --git a/tests/main5-oiio.cpp b/tests/main5-oiio.cpp
index b886f73..35bbc3a 100644
--- a/tests/main5-oiio.cpp
+++ b/tests/main5-oiio.cpp
@@ -589,8 +589,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

diff --git a/tests/main5-qt.cpp b/tests/main5-qt.cpp
index 0b35361..877b917 100644
--- a/tests/main5-qt.cpp
+++ b/tests/main5-qt.cpp
@@ -501,8 +501,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

    QApplication app(argc, argv);

diff --git a/tests/main6-oiio.cpp b/tests/main6-oiio.cpp
index 6061e35..9d52611 100644
--- a/tests/main6-oiio.cpp
+++ b/tests/main6-oiio.cpp
@@ -617,8 +617,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

diff --git a/tests/test-decoder.c b/tests/test-decoder.c
index 7d1bca0..63708f8 100644
--- a/tests/test-decoder.c
+++ b/tests/test-decoder.c
@@ -398,8 +398,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

     if ((ret = open_input_file(argv[1])) < 0)
         goto end;
diff --git a/tests/test-extract.c b/tests/test-extract.c
index 051e73a..4579e16 100644
--- a/tests/test-extract.c
+++ b/tests/test-extract.c
@@ -485,8 +485,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

     if ((ret = open_input_file(argv[1])) < 0)
         goto end;
diff --git a/tests/test-packet.c b/tests/test-packet.c
index 1f87c8a..740ad8d 100644
--- a/tests/test-packet.c
+++ b/tests/test-packet.c
@@ -367,8 +367,12 @@ int main(int argc, char **argv)
         return 1;
     }

+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

     if ((ret = open_input_file(argv[1])) < 0)
         goto end;
diff --git a/tests/transcoding.c b/tests/transcoding.c
index e6e69d9..318cf3f 100644
--- a/tests/transcoding.c
+++ b/tests/transcoding.c
@@ -263,8 +263,12 @@ int transcode_video(StreamingContext *decoder, StreamingContext *encoder, AVPack

 int main(int argc, char *argv[])
 {
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
+#endif
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    avcodec_register_all();
+#endif

   /*
    * H264 -> H265

Without the patch it complains about av_get_channel_layout_nb_channels:

[ 70%] Building CXX object CMakeFiles/gpx2video.dir/src/audioparams.cpp.o
/home/zebradil/development/vendor/gpx2video/src/audioparams.cpp: In member function ‘int AudioParams::channelCount() const’:
/home/zebradil/development/vendor/gpx2video/src/audioparams.cpp:40:16: error: ‘av_get_channel_layout_nb_channels’ was not declared in this scope
   40 |         return av_get_channel_layout_nb_channels(channelLayout());
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
progweb commented 2 years ago

Great, I'll add your patch in the test apps too. Thanks

progweb commented 2 years ago

All is applied.

Zebradil commented 2 years ago

Wonderful, thanks a lot!