savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.4k stars 130 forks source link

Audio has intermittent pauses #2615

Closed simon1tan closed 2 years ago

simon1tan commented 2 years ago

Describe the bug Pulling in HLS audio but it has intermittent pauses. Plays fine in browser. CPU shows low usage

To Reproduce

s = input.hls("https://stream.radiofrance.fr/fip/fip.m3u8")
output(s)

# added these but no effect
video.frame.rate.set(0)
settings.frame.midi.channels.set(0)
settings.frame.video.width.set(0)
settings.frame.video.height.set(0)

Expected behavior Audio plays

Version details

Install method From github release

2022/09/12 15:17:20 >>> LOG START                                                                                                                                                                                                            
2022/09/12 15:17:19 [main:3] Liquidsoap 2.1.1                                                                                                                                                                                                
2022/09/12 15:17:19 [main:3] Using: bytes=[distributed with OCaml 4.02 or above] pcre=7.5.0 sedlex=3.0 menhirLib=20210929 curl=0.9.2 uri=4.2.0 memtrace=v0.2.2 mem_usage=0.0.3 dtools=0.4.4 duppy=0.9.2 cry=0.6.6 mm=0.8.1 xmlplaylist=0.1.5 
astfm=0.3.3 ogg=0.7.2 ogg.decoder=0.7.2 opus=0.2.2 opus.decoder=0.2.2 dynlink=[distributed with Ocaml] ffmpeg=1.1.5 ao=0.2.4 samplerate=0.1.6 taglib=0.3.9 ssl=0.5.9 camomile=1.0.2 portaudio=0.2.3 srt.constants=0.2.1 srt.types=0.2.1 srt.s
ubs=0.2.1 srt.stubs.locked=0.2.1 srt=0.2.1 winsvc=1.0.1                                                                                                                                                                                      
2022/09/12 15:17:19 [clock:3] Using builtin (low-precision) implementation for latency control                                                                                                                                               
2022/09/12 15:17:19 [frame:4] frame.audio.samplerate set to: 44100                                                                                                                                                                           
2022/09/12 15:17:19 [frame:4] frame.video.framerate set to: 0                                                                                                                                                                                
2022/09/12 15:17:20 [frame:4] frame.audio.channels set to: 2                                                                                                                                                                                 
2022/09/12 15:17:20 [frame:4] frame.video.default set to: false                                                                                                                                                                              
2022/09/12 15:17:20 [frame:4] frame.midi.channels set to: 0                                                                                                                                                                                  
2022/09/12 15:17:20 [frame:4] frame.video.width set to: 0                                                                                                                                                                                    
2022/09/12 15:17:20 [frame:4] frame.video.height set to: 0                                                                                                                                                                                   
2022/09/12 15:17:20 [frame:4] frame.audio.samplerate set to: 44100                                                                                                                                                                           
2022/09/12 15:17:20 [frame:3] Using 44100Hz audio, 0Hz video, 44100Hz main.                                                                                                                                                                  
2022/09/12 15:17:20 [frame:3] Video frame size set to: 0x0                                                                                                                                                                                   
2022/09/12 15:17:20 [frame:3] Frame size must be a multiple of 1 ticks = 1 audio samples = 0 video samples.                                                                                                                                  
2022/09/12 15:17:20 [frame:3] Targeting 'frame.duration': 0.04s = 1764 audio samples = 1764 ticks.                                                                                                                                           
2022/09/12 15:17:20 [frame:3] Frames last 0.04s = 1764 audio samples = 0 video samples = 1764 ticks.                                                                                                                                         
2022/09/12 15:17:20 [sandbox:3] Could not find binary bwrap, disabling sandboxing.                                                                                                                                                           
2022/09/12 15:17:20 [video.converter:3] Using preferred video converter: ffmpeg.                                                                                                                                                             
2022/09/12 15:17:20 [audio.converter:3] Using samplerate converter: libsamplerate.                                                                                                                                                           
2022/09/12 15:17:20 [clock:4] Currently 1 clock(s) allocated.                                                                                                                                                                                
2022/09/12 15:17:20 [clock.portaudio:4] Starting 2 source(s)...                                                                                                                                                                              
2022/09/12 15:17:20 [source:4] Source input.ffmpeg_0 gets up with content kind: {audio=pcm,video=any,midi=any}.                                                                                                                              
2022/09/12 15:17:20 [source:4] Source output.portaudio_0 gets up with content kind: {audio=pcm,video=any,midi=any}.                                                                                                                          
2022/09/12 15:17:20 [output.portaudio:4] Content type is {audio=pcm(stereo),video=none,midi=none}.                                                                                                                                           
2022/09/12 15:17:20 [threads:4] Created thread "clock_portaudio" (1 total).                                                                                                                                                                  
2022/09/12 15:17:20 [clock:4] Main phase starts.                                                                                                                                                                                             
2022/09/12 15:17:20 [threads:4] Created thread "generic queue #1" (1 total).                                                                                                                                                                 
2022/09/12 15:17:20 [threads:4] Created thread "generic queue #2" (2 total).                                                                                                                                                                 
2022/09/12 15:17:20 [threads:4] Created thread "non-blocking queue #1" (3 total).                                                                                                                                                            
2022/09/12 15:17:20 [threads:4] Created thread "non-blocking queue #2" (4 total).                                                                                                                                                            
2022/09/12 15:17:20 [clock.portaudio:3] Streaming loop starts in auto-sync mode                                                                                                                                                              
2022/09/12 15:17:20 [clock.portaudio:3] Delegating synchronisation to CPU clock                                                                                                                                                              
2022/09/12 15:17:20 [video.text:3] Using native implementation                                                                                                                                                                               
2022/09/12 15:17:21 [decoder.ffmpeg:4] ffmpeg recognizes "https://stream.radiofrance.fr/fip/fip.m3u8" as: audio: {codec: aac, 48000Hz, 2 channel(s)} and content-type: {audio=pcm(stereo),video=none,midi=none}.                             
2022/09/12 15:17:21 [clock.portaudio:3] Delegating synchronisation to active sources                                                                                                                                                         
2022/09/12 15:17:32 [main:3] Shutdown started!                                                                                                                                                                                               
2022/09/12 15:17:32 [main:3] Waiting for main threads to terminate...                                                                                                                                                                        
2022/09/12 15:17:32 [threads:4] Waiting for thread clock_portaudio to shutdown                                                                                                                                                               
2022/09/12 15:17:32 [clock.portaudio:3] Delegating synchronisation to CPU clock                                                                                                                                                              
2022/09/12 15:17:32 [source:4] Source output.portaudio gets down.                                                                                                                                                                            
2022/09/12 15:17:32 [source:4] Source input.ffmpeg_0 gets down.                                                                                                                                                                              
2022/09/12 15:17:32 [clock.portaudio:3] Streaming loop stopped.                                                                                                                                                                              
2022/09/12 15:17:32 [threads:4] Thread "clock_portaudio" terminated (0 remaining).                                                                                                                                                           
2022/09/12 15:17:32 [main:3] Main threads terminated.                                                                                                                                                                                        
2022/09/12 15:17:32 [threads:3] Shutting down scheduler...                                                                                                                                                                                   
2022/09/12 15:17:32 [threads:4] Thread "generic queue #1" terminated (3 remaining).                                                                                                                                                          
2022/09/12 15:17:32 [threads:4] Thread "generic queue #2" terminated (2 remaining).                                                                                                                                                          
2022/09/12 15:17:32 [threads:4] Thread "non-blocking queue #2" terminated (1 remaining).                                                                                                                                                     
2022/09/12 15:17:32 [threads:4] Thread "non-blocking queue #1" terminated (0 remaining).                                                                                                                                                     
2022/09/12 15:17:32 [threads:3] Scheduler shut down.                                                                                                                                                                                         
2022/09/12 15:17:32 [main:3] Cleaning downloaded files...                                                                                                                                                                                    
2022/09/12 15:17:32 [main:3] Freeing memory...                                                                                                                                                                                               
2022/09/12 15:17:32 >>> LOG END                                                                                                                                                                                                              
toots commented 2 years ago

Thanks for reporting. This has been reported/investigated before: https://github.com/savonet/liquidsoap/issues/2228#issuecomment-1047940554

It looks like the conclusion from that post still apply:

I might add a default buffer on the input.hls wrapper in the standard library to fix this for other users.