Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build problem: ‘AV_CODEC_ID_AV1’ undeclared #3939

Closed
suezz opened this issue Apr 22, 2023 · 5 comments
Closed

build problem: ‘AV_CODEC_ID_AV1’ undeclared #3939

suezz opened this issue Apr 22, 2023 · 5 comments

Comments

@suezz
Copy link

suezz commented Apr 22, 2023

on debian strech 32

ninja: Entering directory `x'
[14/62] Compiling C object app/scrcpy.p/src_demuxer.c.o
FAILED: app/scrcpy.p/src_demuxer.c.o
cc -Iapp/scrcpy.p -Iapp -I../app -I../app/src -I/usr/include/i386-linux-gnu -I/usr/include/SDL2 -I/usr/include/libusb-1.0 -flto -fdiagnostics-color=always -DNDEBUG -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=c11 -O3 -D_REENTRANT -MD -MQ app/scrcpy.p/src_demuxer.c.o -MF app/scrcpy.p/src_demuxer.c.o.d -o app/scrcpy.p/src_demuxer.c.o -c ../app/src/demuxer.c
../app/src/demuxer.c: In function ‘sc_demuxer_to_avcodec_id’:
../app/src/demuxer.c:36:20: error: ‘AV_CODEC_ID_AV1’ undeclared (first use in this function)
return AV_CODEC_ID_AV1;
^~~~~~~~~~~~~~~
../app/src/demuxer.c:36:20: note: each undeclared identifier is reported only once for each function it appears in
[16/62] Compiling C object app/scrcpy.p/src_icon.c.o
ninja: build stopped: subcommand failed.

thanks for any suggestions

@rom1v
Copy link
Collaborator

rom1v commented Apr 22, 2023

Your FFmpeg is VERY old. What is the result of scrcpy --version?

Does it work with this additional diff?

diff --git a/app/src/compat.h b/app/src/compat.h
index 00cb72045..9209dd31c 100644
--- a/app/src/compat.h
+++ b/app/src/compat.h
@@ -25,6 +25,12 @@
 # define SCRCPY_LAVF_REQUIRES_REGISTER_ALL
 #endif
 
+// Not documented in ffmpeg/doc/APIchanges, but AV_CODEC_ID_AV1 was added has
+// been added by FFmpeg commit d42809f9835a4e9e5c7c63210abb09ad0ef19cfb
+// (included in tag n3.3).
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 89, 100)
+# define SCRCPY_LAVC_HAS_AV1
+#endif
 
 // In ffmpeg/doc/APIchanges:
 // 2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h
diff --git a/app/src/demuxer.c b/app/src/demuxer.c
index 5a613505d..4fcdd9ade 100644
--- a/app/src/demuxer.c
+++ b/app/src/demuxer.c
@@ -33,7 +33,12 @@ sc_demuxer_to_avcodec_id(uint32_t codec_id) {
         case SC_CODEC_ID_H265:
             return AV_CODEC_ID_HEVC;
         case SC_CODEC_ID_AV1:
+#ifdef SCRCPY_LAVC_HAS_AV1
             return AV_CODEC_ID_AV1;
+#else
+            LOGE("AV1 not supported by this FFmpeg version");
+            return AV_CODEC_ID_NONE;
+#endif
         case SC_CODEC_ID_OPUS:
             return AV_CODEC_ID_OPUS;
         case SC_CODEC_ID_AAC:

@suezz
Copy link
Author

suezz commented Apr 22, 2023

ffmpeg:
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100

with the additional diff I have same output

MESON:
The Meson build system
Version: 0.56.2
Build type: native build
Project name: scrcpy
Project version: 2.0
C compiler for the host machine: cc (gcc 6.3.0 "cc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516")
C linker for the host machine: cc ld.bfd 2.28
Host machine cpu family: x86
Host machine cpu: i686
Found pkg-config: /usr/bin/pkg-config (0.29)
Run-time dependency libavformat found: YES 57.56.101
Run-time dependency libavcodec found: YES 57.64.101
Run-time dependency libavutil found: YES 55.34.101
Run-time dependency libswresample found: YES 2.3.100
Run-time dependency sdl2 found: YES 2.0.5
Run-time dependency libavdevice found: YES 57.1.100
Run-time dependency libusb-1.0 found: YES 1.0.21
Checking for function "strdup" : YES
Checking for function "asprintf" : YES
Checking for function "vasprintf" : YES
Checking for function "nrand48" : YES
Checking for function "jrand48" : YES
Checking for function "reallocarray" : NO
Header <sys/socket.h> has symbol "SOCK_CLOEXEC" : YES
Configuring config.h using configuration
Build targets in project: 3

Found ninja-1.7.2 at /usr/bin/ninja
NOTICE: You are using Python 3.5 which is EOL. Starting with v0.57, Meson will require Python 3.6 or newer

NINJA:
ninja: Entering directory `x'
[15/62] Compiling C object app/scrcpy.p/src_demuxer.c.o
FAILED: app/scrcpy.p/src_demuxer.c.o
cc -Iapp/scrcpy.p -Iapp -I../app -I../app/src -I/usr/include/i386-linux-gnu -I/usr/include/SDL2 -I/usr/include/libusb-1.0 -flto -fdiagnostics-color=always -DNDEBUG -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=c11 -O3 -D_REENTRANT -MD -MQ app/scrcpy.p/src_demuxer.c.o -MF app/scrcpy.p/src_demuxer.c.o.d -o app/scrcpy.p/src_demuxer.c.o -c ../app/src/demuxer.c
../app/src/demuxer.c: In function ‘sc_demuxer_to_avcodec_id’:
../app/src/demuxer.c:40:20: error: ‘AV_CODEC_ID_AV1’ undeclared (first use in this function)
return AV_CODEC_ID_AV1;
^~~~~~~~~~~~~~~
../app/src/demuxer.c:40:20: note: each undeclared identifier is reported only once for each function it appears in
[17/62] Compiling C object app/scrcpy.p/src_file_pusher.c.o
ninja: build stopped: subcommand failed.

thanks!

@rom1v
Copy link
Collaborator

rom1v commented Apr 22, 2023

with the additional diff I have same output

Oops, I reversed the condition. I updated the diff in my previous comment, please re-test.

@suezz
Copy link
Author

suezz commented Apr 22, 2023

yes, now works :)
thank you!! and happy Sunday

rom1v added a commit that referenced this issue Apr 23, 2023
The constant AV_CODEC_ID_AV1 was introduced in FFmpeg 3.3. Add an ifdef
to support older versions.

Fixes #3939 <#3939>
@rom1v
Copy link
Collaborator

rom1v commented Apr 23, 2023

Pushed on dev branch: 0f3af2d

@rom1v rom1v closed this as completed Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants