FD- / RPiPlay

An open-source AirPlay mirroring server for the Raspberry Pi. Supports iOS 9 and up.
GNU General Public License v3.0
4.9k stars 354 forks source link

Glitchy audio on raspberry pi 4 #278

Open narFnarF opened 2 years ago

narFnarF commented 2 years ago

I installed RPiPlay on a fresh install of Raspbian. When I mirror from my iphone to the RPiPlay and watch a video, the visual plays smoothly, but the audio is super choppy.

Using:

I tried both analog audio and hdmi audio. Both are glitchy. Or sometimes, after a few disconnect/reconnect, audio stops completely.

Note: Shairport-sync works perfectly on the same device (audio plays without glitch)

zycon commented 2 years ago

Same story without audio

maximilianotaverna commented 2 years ago

I also have smooth video but bubbly glitchy audio on rpi3 & rpi4 using fresh install of raspbian lite

djayor commented 2 years ago

To get audio the HDMI cable should be connected in the HDMI 0, and executing in terminal this way: $ ./rpiplay -b auto -a hdmi

I have also glitchy audio in iPhone 6S+, and I think it's because Gstreamer it's not installed, even during the CMake I get the warning:

-- No package 'gstreamer-1.0' found -- No package 'gstreamer-sdp-1.0' found -- No package 'gstreamer-video-1.0' found -- No package 'gstreamer-app-1.0' found

Check if you have Gstreamer installed, and execute: $ ./rpiplay -b auto -a hdmi -vr gstreamer

maximilianotaverna commented 2 years ago

I have installed gstreamer using the following :

$ sudo apt-get update $ sudo apt-get upgrade
$ sudo apt-get install gstreamer1.0-tools
$ sudo apt-get install gstreamer1.0-plugins-good
$ sudo apt-get install gstreamer1.0-plugins-bad
$ sudo apt-get install gstreamer1.0-plugins-ugly
$ sudo apt-get install libglib2.0-dev
$ sudo apt-get install libgstreamer1.0-dev
$ sudo apt-get install libgstreamer-plugins-base1.0-dev

Note: in the make -j execution Im seeing..

[ 97%] Building C object renderers/CMakeFiles/renderers.dir/audio_renderer_rpi.c.o In file included from /home/pi/RPiPlay/renderers/fdk-aac/libAACdec/include/aacdecoder_lib.h:432, from /home/pi/RPiPlay/renderers/audio_renderer_rpi.c:33: /home/pi/RPiPlay/renderers/fdk-aac/libSYS/include/FDK_audio.h:757:29: warning: ‘FDKlibInfo_lookup’ defined but not used [-Wunused-function] static FDK_AUDIO_INLINE INT FDKlibInfo_lookup(const LIB_INFO* info, ^~~~~~~~~~~~~~~~~ /home/pi/RPiPlay/renderers/fdk-aac/libSYS/include/FDK_audio.h:745:1: warning: ‘FDKlibInfo_getCapabilities’ defined but not used [-Wunused-function] FDKlibInfo_getCapabilities(const LIB_INFO* info, FDK_MODULE_ID module_id) { ^~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/RPiPlay/renderers/fdk-aac/libSYS/include/FDK_audio.h:735:30: warning: ‘FDKinitLibInfo’ defined but not used [-Wunused-function] static FDK_AUDIO_INLINE void FDKinitLibInfo(LIB_INFO* info) { ^~~~~~~~~~~~~~ /home/pi/RPiPlay/renderers/video_renderer_gstreamer.c:33:17: warning: ‘check_plugins’ defined but not used [-Wunused-function] static gboolean check_plugins(void) ^~~~~~~~~~~~~ /home/pi/RPiPlay/renderers/audio_renderer_gstreamer.c:34:17: warning: ‘check_plugins’ defined but not used [-Wunused-function] static gboolean check_plugins(void) ^~~~~~~~~~~~~ [ 98%] Linking CXX static library librenderers.a

now that gstreamer was installed I ran

./rpiplay -b auto -a hdmi -vr gstreamer

and although it shows up in my mirroring list on iphone the pi still shows the terminal screen if I removed the -vr gstreamer then it works but bad audio. So I tried with -ar gstreamer so gstreamer would render audio however I have no audio output via hdmi

after the above issues I ran the below but still the same errors persist

sudo apt-get install -y gstreamer1.0-pulseaudio

Note: forgot to mention that after the 12% mark in the make process I also see ` /home/pi/RPiPlay/renderers/h264-bitstream/h264_sei.c: In function ‘read_debug_sei_payload’: /home/pi/RPiPlay/renderers/h264-bitstream/h264_sei.c:686:13: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] for ( i = 0; i < s->payloadSize; i++ ) ^~~ /home/pi/RPiPlay/renderers/h264-bitstream/h264_sei.c:687:80: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left); s->data[i] = bs_read_u8(b); printf("s->data[i]: %d \n", s->data[i]); ^ /home/pi/RPiPlay/renderers/h264-bitstream/h264_stream.c: In function ‘read_pic_parameter_set_rbsp’: /home/pi/RPiPlay/renderers/h264-bitstream/h264_stream.c:771:131: warning: suggest parentheses around comparison in operand of ‘|’ [-Wparentheses] have_more_data = pps->transform_8x8_mode_flag | pps->pic_scaling_matrix_present_flag | pps->second_chroma_qp_index_offset != 0;


/home/pi/RPiPlay/renderers/h264-bitstream/h264_stream.c: In function ‘write_pic_parameter_set_rbsp’:
/home/pi/RPiPlay/renderers/h264-bitstream/h264_stream.c:2100:131: warning: suggest parentheses around comparison in operand of ‘|’ [-Wparentheses]
         have_more_data = pps->transform_8x8_mode_flag | pps->pic_scaling_matrix_present_flag | pps->second_chroma_qp_index_offset != 0;
                                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/home/pi/RPiPlay/renderers/h264-bitstream/h264_stream.c: In function ‘read_debug_pic_parameter_set_rbsp’:
/home/pi/RPiPlay/renderers/h264-bitstream/h264_stream.c:3429:131: warning: suggest parentheses around comparison in operand of ‘|’ [-Wparentheses]
         have_more_data = pps->transform_8x8_mode_flag | pps->pic_scaling_matrix_present_flag | pps->second_chroma_qp_index_offset != 0;
                                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_create_component’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:301:12: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
    int32_t status;
            ^~~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_state_transition’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:462:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_teardown_tunnels’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:518:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_disable_tunnel’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:542:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_enable_tunnel’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:576:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_flush_tunnels’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:651:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_cleanup_components’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:706:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_change_component_state’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:745:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_disable_port’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:766:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_enable_port’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:782:18: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
    OMX_ERRORTYPE error;
                  ^~~~~
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c: In function ‘ilclient_get_port_index’:
/opt/vc/src/hello_pi/libs/ilclient/ilclient.c:1785:24: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
          OMX_ERRORTYPE error;
`

Also tested with full desktop version of raspbian and its the same..

wonder if it has to do with this line in the readme:

> ilclient and Broadcom's OpenMAX stack as present in /opt/vc in Raspbian.
maximilianotaverna commented 2 years ago

Im also now wondering if it has to do with this https://github.com/FD-/RPiPlay/issues/274

balonchiks commented 2 years ago

i am having the same issue with very choppy audio on RPi4 with the fresh install of Raspbian buster. audio is connected via analog interface and it is very choppy. if i start RPiplay with -l flag, audio is not choppy anymore, but the sound is very-very metalic-ish/distorted if i can say so.

has anyone been able to find a solution to this?

pallas commented 2 years ago

I had choppy audio until I switched to aoss, but I am also on an RPi 3B+ and not an RPi 4. Are you running rpiplay with any kind of nice? I'm running at -15, which also prevents other stuff from preëmpting it. Hopefully lifting out the AES context will also help, but that is WIP.

balonchiks commented 2 years ago

Thanks for you reply. I am not running any nice, just plain rpiplay, but will try it today. Meanwhile, can you please point me to how I can setup/run aoss please?

EDIT: tried with nice -15 - no difference both with and without -l flag

8bignic8 commented 2 years ago

when I installed it as shown in: https://github.com/FD-/RPiPlay/issues/296#issuecomment-981210609 and Opened it in: ~/RPiPlay/build with: ./rpiplay -b auto -n "AirPlay" -vr rpi -ar rpi -a hdmi -l

my choppy sound problem got away :)