termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

[Bug]: sound not working except for termux-media-player

Open edoardomazzella opened this issue 1 year ago • 10 comments

Problem description

Using Termux with xfce desktop environment installed (no distro), as per Termux wiki, I am not able to play sound from any of the installed packages (Firefox, vlc) except for termux-media-player using the terminal.

Steps to reproduce the behavior.

Install termux and termux API, upgrade packages install tigervnc and xfce Install Firefox or any available media player (cantara, vlc) and try to play a file audio.

What is the expected behavior?

I can hear sound when using Firefox and media players

System information

  • Termux application version: 0.118.0
  • Android OS version: 14
  • Device model: samsung tab s9 ultra

edoardomazzella avatar May 21 '24 12:05 edoardomazzella

Check if pulseaudio is installed: pulseaudio/stable,now 17.0-1 aarch64 [installed,automatic]. If so, this plays sound and video (via X11):

~/downloads $ mplayer /storage/7B27-F244/Videos_Ext_SD/Watch_me/NASA-Voyager-Jupiter.mp4 MPlayer 1.5-17.0.2 (C) 2000-2022 MPlayer Team Playing /storage/7B27-F244/Videos_Ext_SD/Watch_me/NASA-Voyager-Jupiter.mp4. libavformat version 60.16.100 (external) libavformat file format detected. [mov,mp4,m4a,3gp,3g2,mj2 @ 0x74d1c22f20]Protocol name not provided, cannot determine if input is local or a network protocol, buffers and access patterns cannot be configured optimally without knowing the protocol [lavf] stream 0: video (h264), -vid 0 [lavf] stream 1: audio (aac), -aid 0, -alang und VIDEO: [H264] 480x360 24bpp 25.000 fps 66.1 kbps ( 8.1 kbyte/s) [VO_XV] It seems there is no Xvideo support for your video card available. [VO_XV] Run 'xvinfo' to verify its Xv support and read [VO_XV] DOCS/HTML/en/video.html#xv! [VO_XV] See 'mplayer -vo help' for other (non-xv) video out drivers. [VO_XV] Try -vo x11. ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family libavcodec version 60.31.102 (external) Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264) ========================================================================== Clip info: major_brand: mp42 minor_version: 0 compatible_brands: isommp42 encoder: Google Load subtitles in /storage/7B27-F244/Videos_Ext_SD/Watch_me/ ========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUDIO: 44100 Hz, 2 ch, floatle, 96.0 kbit/3.40% (ratio: 12000->352800) Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio)) ========================================================================== AO: [pulse] 44100Hz 2ch floatle (4 bytes per sample) Starting playback... Movie-Aspect is 1.33:1 - prescaling to correct movie aspect. VO: [x11] 480x360 => 480x360 Planar YV12 [swscaler @ 0x74cfc65a88]No accelerated colorspace conversion found from yuv420p to bgra. [swscaler @ 0x74cfc65a88]using unscaled yuv420p -> bgra special converter A: 28.3 V: 28.3 A-V: 0.000 ct: 0.001 0/ 0

Manamama avatar May 29 '24 18:05 Manamama

Take a look at this issue reported about pulseaudio not working on OneUI 6.1. https://github.com/termux/termux-packages/issues/19623

mzen17 avatar May 30 '24 15:05 mzen17

Likely these tips. I have just tested vlcplayer and firefox in X11 and both have sound via pulseaudio, as well. My preload is empty tho: ~ $ echo $PRELOAD

~ $ , while the rest:

PATH: /data/data/com.termux/files/usr/google-cloud-sdk/bin:/data/data/com.termux/files/home/.opam/default/bin:/data/data/com.termux/files/usr/bin:/system/bin/:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/home/.local/bin

LD_LIBRARY_PATH: /data/data/com.termux/files/usr/lib:/data/data/com.termux/files/usr/lib/jvm/java-17-openjdk/lib/:

CC: clang CXX: clang++ CFLAGS: CXXFLAGS: LDFLAGS: CPPFLAGS: PREFIX is: /data/data/com.termux/files/usr LD_LIBRARY_PATH is: LD_PRELOAD is: LLVM_CONFIG is: C_INCLUDE_PATH is:

Manamama avatar May 30 '24 16:05 Manamama

i am on Android 14,using Debian with xfce in proot-distro, i installed all required packages in termux and in proot-distro, i do all required steps, but when i runned the gui everything works exept pulseaudio. pulseaudio worked in termux (Native GUI in termux), and worked in ubuntu proot-distro, but not worked in Debian

mhdtyb avatar Jun 06 '24 16:06 mhdtyb

i can confirm as per @mhdtyb - after some updates:

Termux:

play wiersze1.mp3

wiersze1.mp3:

 File Size: 108k      Bit Rate: 128k
  Encoding: MPEG audio
  Channels: 2 @ 16-bit
Samplerate: 48000Hz
Replaygain: off
  Duration: 00:00:06.77

In:0.00% 00:00:00.00 [00:00:06.77] Out:0...

But prooted Debian:

root@localhost:~/downloads_Termux# play wiersze1.mp3
play FAIL ao: Could not open device: error 5
play FAIL sox: Sorry, there is no default audio device configured
root@localhost:~/downloads_Termux#

even after running pulseaudio there.

Manamama avatar Jun 10 '24 01:06 Manamama

Pulseaudio can be used only in Termux because only such version is patched to be able play sound on Android.

sylirre avatar Jun 10 '24 07:06 sylirre

Hello here is a command that will fix this for proot distro, but run it in Termux directly, not your proot environment:

echo -e 'LD_PRELOAD=/system/lib64/libskcodec.so\npulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1' | tee -a ../usr/etc/bash.bashrc

Using that command shortened from a command posted on another gh issues link shared in this thread: https://xdaforums.com/t/guide-no-root-how-to-install-debian-or-ubuntu-environments-on-android-in-termux-using-proot-distro.4570275/post-89567377

We were able to get Samsung devices like the Tab S9 to play audio in Debian Proot. Proof is on the XDA link

01101010110 avatar Jun 22 '24 15:06 01101010110

Hello here is a command that will fix this for proot distro, but run it in Termux directly, not your proot environment:

echo -e 'LD_PRELOAD=/system/lib64/libskcodec.so\npulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1' | tee -a ../usr/etc/bash.bashrc

Using that command shortened from a command posted on another gh issues link shared in this thread: https://xdaforums.com/t/guide-no-root-how-to-install-debian-or-ubuntu-environments-on-android-in-termux-using-proot-distro.4570275/post-89567377

We were able to get Samsung devices like the Tab S9 to play audio in Debian Proot. Proof is on the XDA link

i already know that we can do that but i want the developer to make as the default config in previous updates

mhdtyb avatar Jun 22 '24 15:06 mhdtyb

There is also this ugly trick ;):

play_file() {
    local file_path="$PWD/$1"
    termux-media-player play "/data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/debian$file_path"
}

Of course, after aliasing or linking:

root@localhost:~# which termux-media-player
/data/data/com.termux/files/usr/bin//termux-media-player
root@localhost:~#

Manamama avatar Jun 22 '24 16:06 Manamama

Well, the only thing that worked for me (One UI 6.1.1) was changing from OpenSL ES to AAudio as suggested here https://github.com/termux/termux-packages/issues/19623#issuecomment-2123168051

(no need for the rest of the black magic like installing espeak though :stuck_out_tongue: )

francesquini avatar Oct 02 '24 19:10 francesquini