ffmpeg doesn't reconnect when capturing live connections
It begins with: ffmpeg -i https://listen.wruu.org/stream -t 3720 -reconnect true -reconnect_streamed true -reconnect_on_network_error true -timelimit 3720 -loglevel warning wruu_JoeFrank-20250130-2100.mp3 ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 14.2.0 (GCC) configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/doc/ffmpeg-7.1/html --mandir=/usr/man --disable-debug --enable-shared --disable-static --enable-gpl --enable-version3 --arch=x86_64 --disable-encoder=aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libcdio --enable-frei0r --enable-openal --enable-libopus --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libmp3lame --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libpulse --enable-libsmbclient --enable-libxml2 --enable-librsvg --enable-vulkan --enable-libdrm --enable-libaom --enable-libdav1d --enable-libshaderc --enable-gcrypt --enable-libplacebo --enable-lcms2 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 Splitting the commandline. Reading option '-i' ... matched as input url with argument 'https://listen.wruu.org/stream'. Reading option '-t' ... matched as option 't' (stop transcoding after specified duration) with argument '3720'. Reading option '-reconnect' ... matched as AVOption 'reconnect' with argument 'true'. Reading option '-reconnect_streamed' ... matched as AVOption 'reconnect_streamed' with argument 'true'. Reading option '-reconnect_on_network_error' ... matched as AVOption 'reconnect_on_network_error' with argument 'true'. Reading option '-timelimit' ... matched as option 'timelimit' (set max runtime in seconds in CPU user time) with argument '3720'. Reading option '-v' ... matched as option 'v' (set logging level) with argument '48'. Reading option 'wruu_JoeFrank-20250130-2100.mp3' ... matched as output url. Finished splitting the commandline. Parsing a group of options: global . Applying option timelimit (set max runtime in seconds in CPU user time) with argument 3720. Applying option v (set logging level) with argument 48. Successfully parsed a group of options. Parsing a group of options: input url https://listen.wruu.org/stream. Successfully parsed a group of options. Opening an input file: https://listen.wruu.org/stream. [AVFormatContext @ 0x36542540] Opening 'https://listen.wruu.org/stream' for reading [https @ 0x365388c0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy' size= 9984KiB time=00:10:48.15 bitrate= 126.2kbits/s speed=0.0019x [tcp @ 0x36542e00] Original list of addresses: [tcp @ 0x36542e00] Address 165.227.18.155 port 443 [tcp @ 0x36542e00] Interleaved list of addresses: [tcp @ 0x36542e00] Address 165.227.18.155 port 443 [tcp @ 0x36542e00] Starting connection attempt to 165.227.18.155 port 443 [tcp @ 0x36542e00] Successfully connected to 165.227.18.155 port 443 [https @ 0x365388c0] request: GET /stream HTTP/1.1 User-Agent: Lavf/61.7.100 Accept: */* Range: bytes=0- Connection: close Host: listen.wruu.org Icy-MetaData: 1 [mp3 @ 0x36542540] Format mp3 probed with size=4096 and score=51 [mp3 @ 0x36542540] Skipping 0 bytes of junk at 0. [mp3 @ 0x36542540] Before avformat_find_stream_info() pos: 0 bytes read:7569 seeks:0 nb_streams:1 [https @ 0x365388c0] Metadata update for StreamTitle: - WRUU-WRUU [mp3 @ 0x36542540] All info found [mp3 @ 0x36542540] After avformat_find_stream_info() pos: 31744 bytes read:32000 seeks:0 frames:50 Input #0, mp3, from 'https://listen.wruu.org/stream': Metadata: icy-br : 192 icy-channels : 2 icy-name : WRUU 2022 icy-pub : 1 icy-samplerate : 44100 StreamTitle : - WRUU-WRUU Duration: N/A, start: 0.000000, bitrate: 192 kb/s Stream #0:0, 50, 1/14112000: Audio: mp3 (mp3float), 44100 Hz, stereo, fltp, 192 kb/s Successfully opened the file. Parsing a group of options: output url wruu_JoeFrank-20250130-2100.mp3. Applying option t (stop transcoding after specified duration) with argument 3720. Successfully parsed a group of options. Opening an output file: wruu_JoeFrank-20250130-2100.mp3. [out#0/mp3 @ 0x36888b80] No explicit maps, mapping streams automatically... [aost#0:0/libmp3lame @ 0x36889c80] Created audio stream from input stream 0:0 [file @ 0x3689d1c0] Setting default whitelist 'file,crypto,data' Successfully opened the file. Stream mapping: Stream #0:0 -> #0:0 (mp3 (mp3float) -> mp3 (libmp3lame)) [aost#0:0/libmp3lame @ 0x36889c80] Starting thread... [af#0:0 @ 0x36546c00] Starting thread... [aist#0:0/mp3 @ 0x3655f340] [dec:mp3float @ 0x368786c0] Starting thread... [in#0/mp3 @ 0x36542280] Starting thread... Press [q] to stop, [?] for help detected 4 logical cores [graph_-1_in_0:0 @ 0x7fdb580022c0] Setting 'time_base' to value '1/44100' [graph_-1_in_0:0 @ 0x7fdb580022c0] Setting 'sample_rate' to value '44100' [graph_-1_in_0:0 @ 0x7fdb580022c0] Setting 'sample_fmt' to value 'fltp' [graph_-1_in_0:0 @ 0x7fdb580022c0] Setting 'channel_layout' to value 'stereo' [graph_-1_in_0:0 @ 0x7fdb580022c0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:stereo [format_out_#0:0 @ 0x7fdb58002c80] Setting 'sample_fmts' to value 's32p|fltp|s16p' [format_out_#0:0 @ 0x7fdb58002c80] Setting 'sample_rates' to value '44100|48000|32000|22050|24000|16000|11025|12000|8000' [format_out_#0:0 @ 0x7fdb58002c80] Setting 'channel_layouts' to value 'mono|stereo' [AVFilterGraph @ 0x7fdb58001000] query_formats: 5 queried, 9 merged, 3 already done, 0 delayed Output #0, mp3, to 'wruu_JoeFrank-20250130-2100.mp3': Metadata: icy-br : 192 icy-channels : 2 icy-name : WRUU 2022 icy-pub : 1 icy-samplerate : 44100 StreamTitle : - WRUU-WRUU TSSE : Lavf61.7.100 Stream #0:0, 0, 1/44100: Audio: mp3, 44100 Hz, stereo, fltp, delay 1105 Metadata: encoder : Lavc61.19.100 libmp3lame [out#0/mp3 @ 0x36888b80] Starting thread... Then there are thousands of entries like this: out#0/mp3 @ 0x36888b80] sq: send 0 ts 0.0261224 [out#0/mp3 @ 0x36888b80] sq: receive 0 ts 0.0261224 queue head -1 ts N/A [out#0/mp3 @ 0x36888b80] sq: send 0 ts 0.0522449 [out#0/mp3 @ 0x36888b80] sq: receive 0 ts 0.0522449 queue head -1 ts N/A [out#0/mp3 @ 0x36888b80] sq: send 0 ts 0.0783673 Then thousands that look like this: size= 54272KiB time=00:58:02.98 bitrate= 127.6kbits/s speed=0.679x No error is reported. ffmpeg is still running after its specified time.
no real clue, but http and https inputs seem to have zero f'ing useful countdown/timeout handling... nor "-t" counting. I was trying something similar, like so: $ while :; do ffmpeg -xerror -re -i https://stream.nightride.fm/datawave.mp3 -filter_complex "[0:a]avectorscope=s=640x518:r=24000/1001:mode=polar:scale=log,pad=1280:720[vs]; [0:a]showspectrum=mode=separate:color=intensity:scale=log:s=640x518[ss]; [0:a]showwaves=s=1280x202:mode=line:colors=0xffffff|0xffffff:n=2[sw]; [vs][ss]overlay=w[bg]; [bg][sw]overlay=0:H-h,drawtext=textfile=title.txt:reload=1:fontcolor=white:x=30:y=30:fontsize=36,fps=24000/1001[out]" -map "[out]" -map 0:a -af "aresample=48000:resampler=soxr,apad,adelay=190|190" -c:a ac3 -channel_coupling 1 -cpl_start_band 8 -b:a 112k -ac 2 -cutoff 21000 -c:v libx264 -preset veryslow -pix_fmt yuv420p -bf 4 -g 72 -b:v 512k -maxrate 5M -bufsize 5M -aq-strength 2 -x264-params "nal-hrd=vbr:ref=4:me=hex:me_range=1280:mbtree=0:aq-mode=1" -f mpegts -flush_packets 0 "udp://localhost:1234?pkt_size=1316" ; sleep 1 ; done [removed normal startup/runtime output..] then after a while, whenever the stream/network/etc hangs but doesn't close the tcp connection, we see shit like this - which, even with -xerror, requires sending ^c a few times to force close; it seems like some sort of easy failure to trap, but try as I might, can't find any useful hints/clues: [tls @ 0x600002100000] Error in the pull function.07:12:50.23 bitrate= 691.7kbits/s speed= 1x [tls @ 0x600002100000] IO error: Operation timed out [in#0/mp3 @ 0x60000330c000] Error during demuxing: Operation timed out [in#0/mp3 @ 0x60000330c000] Task finished with error code: -60 (Operation timed out) [in#0/mp3 @ 0x60000330c000] Terminating thread with return code -60 (Operation timed out) [mp3float @ 0x142f0ae70] invalid new backstep -1 ^C[vost#0:0/libx264 @ 0x142f084c0] Error submitting a packet to the muxer: Immediate exit requested Last message repeated 1 times [out#0/mpegts @ 0x600003a000c0] Error muxing a packet [out#0/mpegts @ 0x600003a000c0] Task finished with error code: -1414092869 (Immediate exit requested) [out#0/mpegts @ 0x600003a000c0] Terminating thread with return code -1414092869 (Immediate exit requested) ^C ^CReceived > 3 system signals, hard exiting On Thu, Jan 30, 2025 at 11:39 PM arthurpeabody <arthurpeabody@rickstewart.com> wrote:
It begins with:
ffmpeg -i https://listen.wruu.org/stream -t 3720 -reconnect true -reconnect_streamed true -reconnect_on_network_error true -timelimit 3720 -loglevel warning wruu_JoeFrank-20250130-2100.mp3 ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 14.2.0 (GCC) configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/doc/ffmpeg-7.1/html --mandir=/usr/man --disable-debug --enable-shared --disable-static --enable-gpl --enable-version3 --arch=x86_64 --disable-encoder=aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libcdio --enable-frei0r --enable-openal --enable-libopus --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libmp3lame --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libpulse --enable-libsmbclient --enable-libxml2 --enable-librsvg --enable-vulkan --enable-libdrm --enable-libaom --enable-libdav1d --enable-libshaderc --enable-gcrypt --enable-libplacebo --enable-lcms2 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 Splitting the commandline. Reading option '-i' ... matched as input url with argument 'https://listen.wruu.org/stream'. Reading option '-t' ... matched as option 't' (stop transcoding after specified duration) with argument '3720'. Reading option '-reconnect' ... matched as AVOption 'reconnect' with argument 'true'. Reading option '-reconnect_streamed' ... matched as AVOption 'reconnect_streamed' with argument 'true'. Reading option '-reconnect_on_network_error' ... matched as AVOption 'reconnect_on_network_error' with argument 'true'. Reading option '-timelimit' ... matched as option 'timelimit' (set max runtime in seconds in CPU user time) with argument '3720'. Reading option '-v' ... matched as option 'v' (set logging level) with argument '48'. Reading option 'wruu_JoeFrank-20250130-2100.mp3' ... matched as output url. Finished splitting the commandline. Parsing a group of options: global . Applying option timelimit (set max runtime in seconds in CPU user time) with argument 3720. Applying option v (set logging level) with argument 48. Successfully parsed a group of options. Parsing a group of options: input url https://listen.wruu.org/stream. Successfully parsed a group of options. Opening an input file: https://listen.wruu.org/stream. [AVFormatContext @ 0x36542540] Opening 'https://listen.wruu.org/stream' for reading [https @ 0x365388c0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy' size= 9984KiB time=00:10:48.15 bitrate= 126.2kbits/s speed=0.0019x [tcp @ 0x36542e00] Original list of addresses: [tcp @ 0x36542e00] Address 165.227.18.155 port 443 [tcp @ 0x36542e00] Interleaved list of addresses: [tcp @ 0x36542e00] Address 165.227.18.155 port 443 [tcp @ 0x36542e00] Starting connection attempt to 165.227.18.155 port 443 [tcp @ 0x36542e00] Successfully connected to 165.227.18.155 port 443 [https @ 0x365388c0] request: GET /stream HTTP/1.1 User-Agent: Lavf/61.7.100 Accept: */* Range: bytes=0- Connection: close Host: listen.wruu.org Icy-MetaData: 1
[mp3 @ 0x36542540] Format mp3 probed with size=4096 and score=51 [mp3 @ 0x36542540] Skipping 0 bytes of junk at 0. [mp3 @ 0x36542540] Before avformat_find_stream_info() pos: 0 bytes read:7569 seeks:0 nb_streams:1 [https @ 0x365388c0] Metadata update for StreamTitle: - WRUU-WRUU [mp3 @ 0x36542540] All info found [mp3 @ 0x36542540] After avformat_find_stream_info() pos: 31744 bytes read:32000 seeks:0 frames:50 Input #0, mp3, from 'https://listen.wruu.org/stream': Metadata: icy-br : 192 icy-channels : 2 icy-name : WRUU 2022 icy-pub : 1 icy-samplerate : 44100 StreamTitle : - WRUU-WRUU Duration: N/A, start: 0.000000, bitrate: 192 kb/s Stream #0:0, 50, 1/14112000: Audio: mp3 (mp3float), 44100 Hz, stereo, fltp, 192 kb/s Successfully opened the file. Parsing a group of options: output url wruu_JoeFrank-20250130-2100.mp3. Applying option t (stop transcoding after specified duration) with argument 3720. Successfully parsed a group of options. Opening an output file: wruu_JoeFrank-20250130-2100.mp3. [out#0/mp3 @ 0x36888b80] No explicit maps, mapping streams automatically... [aost#0:0/libmp3lame @ 0x36889c80] Created audio stream from input stream 0:0 [file @ 0x3689d1c0] Setting default whitelist 'file,crypto,data' Successfully opened the file. Stream mapping: Stream #0:0 -> #0:0 (mp3 (mp3float) -> mp3 (libmp3lame)) [aost#0:0/libmp3lame @ 0x36889c80] Starting thread... [af#0:0 @ 0x36546c00] Starting thread... [aist#0:0/mp3 @ 0x3655f340] [dec:mp3float @ 0x368786c0] Starting thread... [in#0/mp3 @ 0x36542280] Starting thread... Press [q] to stop, [?] for help detected 4 logical cores [graph_-1_in_0:0 @ 0x7fdb580022c0] Setting 'time_base' to value '1/44100' [graph_-1_in_0:0 @ 0x7fdb580022c0] Setting 'sample_rate' to value '44100' [graph_-1_in_0:0 @ 0x7fdb580022c0] Setting 'sample_fmt' to value 'fltp' [graph_-1_in_0:0 @ 0x7fdb580022c0] Setting 'channel_layout' to value 'stereo' [graph_-1_in_0:0 @ 0x7fdb580022c0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:stereo [format_out_#0:0 @ 0x7fdb58002c80] Setting 'sample_fmts' to value 's32p|fltp|s16p' [format_out_#0:0 @ 0x7fdb58002c80] Setting 'sample_rates' to value '44100|48000|32000|22050|24000|16000|11025|12000|8000' [format_out_#0:0 @ 0x7fdb58002c80] Setting 'channel_layouts' to value 'mono|stereo' [AVFilterGraph @ 0x7fdb58001000] query_formats: 5 queried, 9 merged, 3 already done, 0 delayed Output #0, mp3, to 'wruu_JoeFrank-20250130-2100.mp3': Metadata: icy-br : 192 icy-channels : 2 icy-name : WRUU 2022 icy-pub : 1 icy-samplerate : 44100 StreamTitle : - WRUU-WRUU TSSE : Lavf61.7.100 Stream #0:0, 0, 1/44100: Audio: mp3, 44100 Hz, stereo, fltp, delay 1105 Metadata: encoder : Lavc61.19.100 libmp3lame [out#0/mp3 @ 0x36888b80] Starting thread...
Then there are thousands of entries like this:
out#0/mp3 @ 0x36888b80] sq: send 0 ts 0.0261224 [out#0/mp3 @ 0x36888b80] sq: receive 0 ts 0.0261224 queue head -1 ts N/A [out#0/mp3 @ 0x36888b80] sq: send 0 ts 0.0522449 [out#0/mp3 @ 0x36888b80] sq: receive 0 ts 0.0522449 queue head -1 ts N/A [out#0/mp3 @ 0x36888b80] sq: send 0 ts 0.0783673
Then thousands that look like this:
size= 54272KiB time=00:58:02.98 bitrate= 127.6kbits/s speed=0.679x
No error is reported. ffmpeg is still running after its specified time.
_______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
participants (2)
-
Anton Kapela -
arthurpeabody