T
Termux•3w ago
qlufo

problem with installing ffmpeg with --enable-libxcb in termux

hello, is there any way to enable libxcb when installing ffmpeg on termux? i can't seem to directly enable this when installing ffmpeg in termux (pkg i ffmpeg), so i resort to rebuilding it from the git repo. but for some reason Error: libxcb is requested, but not found even though checking on the installed packages, there is libxcb!!! so i am currently stuck, if anyone have any fixes or ways for this i would appreciate it. thanks!
48 Replies
qlufo
qlufoOP•3w ago
There are some sources stating that --enable-libxcb set as true by default when installing ffmpeg even just plain make doesn't work
No description
TomIO
TomIO•3w ago
If you're trying to build ffmpeg on-device you're gonna have a bad time. It's a very complex package with a lot of compile time dependencies. Looks like we're not currently building ffmpeg with --enable-libxcb. We do have a libxb package, so let me make a pull request to enable it on our FFMPEG package. It looks like libxcb is only used by the x11grab input device type. Which seems to do a "direct" capture of the specified X11 display. Should probably work if enabled. I'll report back when the PR is open.
qlufo
qlufoOP•3w ago
indeed i am using ffmpeg as a "direct" capture in an x11 desktop environment. some might suggest to just use the android's build-in recorder, but its far convenient to just record it directly (and how usually i don't have access to keyboard or mouse peripherals, so it will look janky). i have a prior script that records the x11 using ffmpeg on my proot, it works really great! but i since moved to use termux directly instead of proot, and using the provided recordmydesktop package available in termux doesn't seem to be as smooth as ffmpeg thanks for the help, and I'll be waiting for the new update/fix to this
TomIO
TomIO•3w ago
The build script could use a little cleanup while I'm here... Give me like 15 minutes to do some build tests.
TomIO
TomIO•3w ago
Yep that worked.
No description
TomIO
TomIO•3w ago
Haven't tested the actual input type. If you'd like to test the package before it is merged I have left instructions in the PR.
qlufo
qlufoOP•3w ago
Awesome unfortunately as i test it... uhh...
No description
TomIO
TomIO•3w ago
What was the command you used for testing?
qlufo
qlufoOP•3w ago
oh yeah. apologies, but i forgot ffmpeg also has pulseaudio option for capturing the audio
No description
qlufo
qlufoOP•3w ago
here you go
ffmpeg -video_size 1280x720 -framerate 20 -f xcbgrab -i :0.0 -f pulse -i default -vf scale=854:480 -c:v h264_v4l2m2m -preset ultrafast -pix_fmt yuv420p -c:a aac -b:a 128k -async 1 "$HOME/Videos/recording_$(date '+%Y-%m-%d_%H-%M-%S').mp4"
ffmpeg -video_size 1280x720 -framerate 20 -f xcbgrab -i :0.0 -f pulse -i default -vf scale=854:480 -c:v h264_v4l2m2m -preset ultrafast -pix_fmt yuv420p -c:a aac -b:a 128k -async 1 "$HOME/Videos/recording_$(date '+%Y-%m-%d_%H-%M-%S').mp4"
TomIO
TomIO•3w ago
Please be aware that your local copy of the FFMPEG source repo is not going to reflect the flags we use for building the package. But yeah PulseAudio is also not currently enabled on our FFMPEG package, and would likely require additional patching to work properly. It's worth a try though. What does echo $DISPLAY return?
qlufo
qlufoOP•3w ago
:1 still even switching it to target :1 doesn't seem to work
TomIO
TomIO•3w ago
Same error?
qlufo
qlufoOP•3w ago
spits out the same error...
TomIO
TomIO•3w ago
Oh I think I see the problem. The input format is called x11grab not xcbgrab
qlufo
qlufoOP•3w ago
oh yeah i got this script with the help of the internet and tweak it a bit (lol) i used this script on proot, yes it did work great and functional. after moving it to termux, i searched the problem related to that on the internet apparently x11grab is deprecated on newer ffmpeg versions
TomIO
TomIO•3w ago
Not surprising.
qlufo
qlufoOP•3w ago
is there anything yet that i might've missed?
TomIO
TomIO•3w ago
-c:v h264_v4l2m2m doesn't seem to exist from what I can tell.
qlufo
qlufoOP•3w ago
ahh perhaps i should change my script a bit
TomIO
TomIO•3w ago
Using a video codec that exists wouldn't be a bad start. V4L2 would likely be a non-starter on Termux regardless as Android doesn't usually ship the Video for Linux v2 kernel module.
qlufo
qlufoOP•3w ago
Alright used libx264 sadly... same error 😞
TomIO
TomIO•3w ago
I'm no FFMPEG wizard unfortunately.
qlufo
qlufoOP•3w ago
i understand but it still questions me how it's not recognized here...
TomIO
TomIO•3w ago
Here's the example from the FFMPEG documentation.
ffmpeg -f x11grab -framerate 25 -video_size cif -i "$DISPLAY" out.mpg
ffmpeg -f x11grab -framerate 25 -video_size cif -i "$DISPLAY" out.mpg
Does that do anything?
qlufo
qlufoOP•3w ago
Alright ill try Oof same error Unknown input format
TomIO
TomIO•3w ago
What's ffmpeg -devices spit out?
qlufo
qlufoOP•3w ago
ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers
built with Android (12470979, +pgo, +bolt, +lto, +mlgo, based on r522817c) clang version 18.0.3 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262)
configuration: --arch=aarch64 --as=aarch64-linux-android-clang --cc=aarch64-linux-android-clang --cxx=aarch64-linux-android-clang++ --nm=llvm-nm --ar=llvm-ar --ranlib=llvm-ranlib --pkg-config=/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/pkg-config --strip=llvm-strip --cross-prefix=aarch64-linux-android- --disable-indevs --disable-outdevs --enable-indev=lavfi --disable-static --disable-symver --enable-cross-compile --enable-gnutls --enable-gpl --enable-version3 --enable-jni --enable-lcms2 --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libharfbuzz --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenmpt --enable-libopus --enable-librav1e --enable-librubberband --enable-libsoxr --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-mediacodec --enable-opencl --enable-shared --prefix=/data/data/com.termux/files/usr --target-os=android --extra-libs=-landroid-glob --disable-vulkan --enable-neon --disable-libfdk-aac
libavutil 59. 39.100 / 59. 39.100
libavcodec 61. 19.100 / 61. 19.100
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
Devices:
D. = Demuxing supported
.E = Muxing supported
---
D lavfi Libavfilter virtual input device
ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers
built with Android (12470979, +pgo, +bolt, +lto, +mlgo, based on r522817c) clang version 18.0.3 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262)
configuration: --arch=aarch64 --as=aarch64-linux-android-clang --cc=aarch64-linux-android-clang --cxx=aarch64-linux-android-clang++ --nm=llvm-nm --ar=llvm-ar --ranlib=llvm-ranlib --pkg-config=/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/pkg-config --strip=llvm-strip --cross-prefix=aarch64-linux-android- --disable-indevs --disable-outdevs --enable-indev=lavfi --disable-static --disable-symver --enable-cross-compile --enable-gnutls --enable-gpl --enable-version3 --enable-jni --enable-lcms2 --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libharfbuzz --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenmpt --enable-libopus --enable-librav1e --enable-librubberband --enable-libsoxr --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-mediacodec --enable-opencl --enable-shared --prefix=/data/data/com.termux/files/usr --target-os=android --extra-libs=-landroid-glob --disable-vulkan --enable-neon --disable-libfdk-aac
libavutil 59. 39.100 / 59. 39.100
libavcodec 61. 19.100 / 61. 19.100
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
Devices:
D. = Demuxing supported
.E = Muxing supported
---
D lavfi Libavfilter virtual input device
TomIO
TomIO•3w ago
Did you have to cut off the rest or is that all?
qlufo
qlufoOP•3w ago
Thats all
TomIO
TomIO•3w ago
That's a whole lot of not much.
qlufo
qlufoOP•3w ago
oh...
TomIO
TomIO•3w ago
Here's what I get on my PC's version of FFMPEG.
# [...] compiler options omitted for brevity
Devices:
D. = Demuxing supported
.E = Muxing supported
---
DE alsa ALSA audio output
DE fbdev Linux framebuffer
D iec61883 libiec61883 (new DV1394) A/V input device
D jack JACK Audio Connection Kit
D kmsgrab KMS screen capture
D lavfi Libavfilter virtual input device
E opengl OpenGL output
DE oss OSS (Open Sound System) playback
DE pulse Pulse audio output
E sdl,sdl2 SDL2 output device
DE video4linux2,v4l2 Video4Linux2 output device
D x11grab X11 screen capture, using XCB
E xv XV (XVideo) output device
# [...] compiler options omitted for brevity
Devices:
D. = Demuxing supported
.E = Muxing supported
---
DE alsa ALSA audio output
DE fbdev Linux framebuffer
D iec61883 libiec61883 (new DV1394) A/V input device
D jack JACK Audio Connection Kit
D kmsgrab KMS screen capture
D lavfi Libavfilter virtual input device
E opengl OpenGL output
DE oss OSS (Open Sound System) playback
DE pulse Pulse audio output
E sdl,sdl2 SDL2 output device
DE video4linux2,v4l2 Video4Linux2 output device
D x11grab X11 screen capture, using XCB
E xv XV (XVideo) output device
qlufo
qlufoOP•3w ago
Hmm so what can i do to resolve this?
TomIO
TomIO•3w ago
I'm gonna guess nothing. This is gonna need further troubleshooting by the looks of it.
qlufo
qlufoOP•3w ago
How about your own mobile device? (Termux) Since you explicitly said your PC one?
TomIO
TomIO•3w ago
Only getting lavfi on my phone.
qlufo
qlufoOP•3w ago
Huh so is it the package's problem?
TomIO
TomIO•3w ago
I'm guessing it's an Android limitation. All of these except lavfi (which is a "virtual" input device) use system devices located in /dev. Which, we don't get access to on Android.
TomIO
TomIO•3w ago
Proot fakes some devices and system calls.
qlufo
qlufoOP•3w ago
Ah so it doesnt really get the system devices. Just makes one No wonder to get audio working you need to do it outside proot
TomIO
TomIO•3w ago
It doesn't make one, it "fakes" one. e.g. it provides a shim -# https://en.wikipedia.org/wiki/Shim_(computing)
Shim (computing)
In computer programming, a shim is a library that transparently intercepts API calls and changes the arguments passed, handles the operation itself or redirects the operation elsewhere. Shims can be used to support an old API in a newer environment, or a new API in an older environment. Shims can also be used for running programs on different so...
qlufo
qlufoOP•3w ago
Is it possible to "fake" some in termux/replicate what proot did to some devices?
TomIO
TomIO•3w ago
I don't think so.
qlufo
qlufoOP•3w ago
Are there any future solutions (based on the new comment on the PR), or this is it?
TomIO
TomIO•3w ago
I'm not sure, and patching libavdevice would be out of my range of expertise.

Did you find this page helpful?