Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLS: Crashed on Raspberry Pi 3 when access FLV #2783

Open
zn123 opened this issue Dec 10, 2021 · 8 comments
Open

HLS: Crashed on Raspberry Pi 3 when access FLV #2783

zn123 opened this issue Dec 10, 2021 · 8 comments
Assignees
Labels
Bug It might be a bug. HLS For HLS, MPEG-DASH or CMAF. TransByAI Translated by AI/GPT.

Comments

@zn123
Copy link

zn123 commented Dec 10, 2021

Note: Before asking a question, please read the FAQ (Please read FAQ before filing an issue) #2716

Description
When configuring HLS parameters and streaming with Raspberry Pi 3, SRS crashes after a few packets.

1. SRS Version: 4.0release

1. SRS Log:

srs end

[2021-12-10 20:03:03.314][Trace][31203][4z3841i0] new source, stream_url=/live/livestream
[2021-12-10 20:03:03.314][Trace][31203][4z3841i0] source url=/live/livestream, ip=127.0.0.1, cache=1, is_edge=0, source_id=/
[2021-12-10 20:03:03.414][Trace][31203][4z3841i0] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=0ms, dts_directly=1
[2021-12-10 20:03:03.414][Trace][31203][4z3841i0] ignore disabled exec for vhost=__defaultVhost__
[2021-12-10 20:03:03.415][Trace][31203][4z3841i0] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2021-12-10 20:03:03.466][Trace][31203][4z3841i0] got metadata, width=960, height=540, vcodec=7, acodec=10
[2021-12-10 20:03:03.466][Trace][31203][4z3841i0] 52B video sh,  codec(7, profile=High, level=3.1, 960x540, 0kbps, 0.0fps, 0.0s)
[2021-12-10 20:03:03.466][Trace][31203][4z3841i0] 7B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)
[2021-12-10 20:03:05.065][Trace][31203][p709kfe3] Hybrid cpu=4.00%,12MB
[2021-12-10 20:03:10.064][Trace][31203][p709kfe3] Hybrid cpu=5.00%,13MB
[2021-12-10 20:03:11.991][Trace][31203][d0916406] HTTP #0 192.168.3.205:54169 GET http://192.168.3.232:8080/live/livestream.flv, content-length=-1
[2021-12-10 20:03:11.991][Warn][31203][d0916406][2] http miss file=./objs/nginx/html/live/livestream.flv, pattern=/, upath=/live/livestream.flv
[2021-12-10 20:03:12.003][Trace][31203][d0916406] TCP: before dispose resource(HttpStream)(0x2a445b0), conns=2, zombies=0, ign=0, inz=0, ind=0
[2021-12-10 20:03:12.003][Warn][31203][d0916406][104] client disconnect peer. ret=1007
[2021-12-10 20:03:12.003][Trace][31203][84192ha6] TCP: clear zombies=1 resources, conns=2, removing=0, unsubs=0
[2021-12-10 20:03:12.003][Trace][31203][d0916406] TCP: disposing #0 resource(HttpStream)(0x2a445b0), conns=2, disposing=1, zombies=0
Segmentation fault

Push end

frame=  179 fps= 25 q=-1.0 size=    1224kB time=00:00:07.04 bitrate=1424.1kbits/frame=  192 fps= 25 q=-1.0 size=    1291kB time=00:00:07.56 bitrate=1399.2kbits/frame=  204 fps= 25 q=-1.0 size=    1357kB time=00:00:08.05 bitrate=1379.5kbits/frame=  217 fps= 25 q=-1.0 size=    1411kB time=00:00:08.56 bitrate=1350.2kbits/frame=  229 fps= 25 q=-1.0 size=    1473kB time=00:00:09.07 bitrate=1329.2kbits/frame=  242 fps= 25 q=-1.0 size=    1544kB time=00:00:09.56 bitrate=1321.7kbits/av_interleaved_write_frame(): Broken pipe
[flv @ 0x18e1010] Failed to update header with correct duration.
[flv @ 0x18e1010] Failed to update header with correct filesize.
Error writing trailer of rtmp://127.0.0.1/live/livestream: Broken pipe
frame=  250 fps= 25 q=-1.0 Lsize=    1588kB time=00:00:09.88 bitrate=1316.8kbits/s speed=   1x    
video:1423kB audio:156kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.600417%
Conversion failed!

1. The configuration of SRS is as follows (Config):

listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
vhost __defaultVhost__ {
    hls {
        enabled         on;
        hls_fragment    10;
        hls_window      60;
        hls_path        ./objs/nginx/html;
        hls_m3u8_file   [app]/[stream].m3u8;
        hls_ts_file     [app]/[stream]-[seq].ts;
    }
}

Other

./configure
./configure   --srt=on --https=on --cherrypy=on 

All have been tested, the phenomenon is the same.
Without adding the hls segment in the configuration file, only supporting rtmp is normal.

File generation is normal.

pi@raspberrypi:~/src/srs/trunk $ ls -l ./objs/nginx/html/live
total 2164
-rw-r--r-- 1 pi pi 1746520 Dec 10 20:03 livestream-0.ts.tmp
-rw-r--r-- 1 pi pi   35344 Dec 10 19:57 livestream-32.ts
-rw-r--r-- 1 pi pi   33464 Dec 10 19:57 livestream-33.ts
-rw-r--r-- 1 pi pi   26696 Dec 10 19:57 livestream-34.ts
-rw-r--r-- 1 pi pi   33840 Dec 10 19:57 livestream-35.ts
-rw-r--r-- 1 pi pi   32336 Dec 10 19:57 livestream-36.ts
-rw-r--r-- 1 pi pi   34404 Dec 10 19:57 livestream-37.ts
-rw-r--r-- 1 pi pi   34216 Dec 10 19:57 livestream-38.ts
-rw-r--r-- 1 pi pi   36284 Dec 10 19:57 livestream-39.ts
-rw-r--r-- 1 pi pi   47940 Dec 10 19:57 livestream-40.ts
-rw-r--r-- 1 pi pi  123704 Dec 10 19:57 livestream-41.ts.tmp
-rw-r--r-- 1 pi pi     122 Dec 10 19:46 livestream.html
-rw-r--r-- 1 pi pi     434 Dec 10 19:57 livestream.m3u8
pi@raspberrypi:~/src/srs/trunk $ 

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Dec 10, 2021

Coredump please upload attachments and binaries, or provide bt stack information.

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Dec 10, 2021
@winlinvip winlinvip added the Bug It might be a bug. label Dec 10, 2021
@zn123
Copy link
Author

zn123 commented Dec 13, 2021

core_dump.zip
@winlinvip Thank you

TRANS_BY_GPT3

@zn123
Copy link
Author

zn123 commented Dec 14, 2021

Top

TRANS_BY_GPT3

@zn123
Copy link
Author

zn123 commented Dec 23, 2021

Raspberry Pi 4 is also like this.
Depressed.
It should be caused by the streaming parameters of the client ffmpeg, -vcodec copy -acodec copy, which leads to the crash of SRS.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Dec 23, 2021

Please provide the BT file. I don't have a Raspberry Pi environment, so I can't view it.

Please search on Baidu how to view the BT file for Core.

TRANS_BY_GPT3

@zhanglm666
Copy link

zhanglm666 commented Jun 2, 2023

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/arm/armv6/strlen.S:26
26      ../sysdeps/arm/armv6/strlen.S: No such file or directory.
(gdb) bt
#0  strlen () at ../sysdeps/arm/armv6/strlen.S:26
#1  0x76c423f0 in __vfprintf_internal (s=0x76712650, s@entry=0x76c7b454 <__offtime+972>, 
    format=format@entry=0x50e900 "-> HLS time=%dms, sno=%d, ts=%s, dur=%dms, dva=%dp", ap=..., ap@entry=..., 
    mode_flags=mode_flags@entry=1987127320) at vfprintf-internal.c:1688
#2  0x76c5436c in __vsnprintf_internal (
    string=0x75ffb1 "-> HLS time=10012876ms, sno=0, ts= increase, please open mix_correct.\nfps, 0.0s)\nels, 44100HZ)\napp]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=0ms, dts_directly=1\n--stat=on --http"..., 
    maxlen=<optimized out>, format=0x50e900 "-> HLS time=%dms, sno=%d, ts=%s, dur=%dms, dva=%dp", args=..., 
    mode_flags=mode_flags@entry=0) at vsnprintf.c:114
#3  0x76c543d0 in ___vsnprintf (string=<optimized out>, maxlen=<optimized out>, format=<optimized out>, args=...)
    at vsnprintf.c:124
#4  0x0015a964 in SrsFileLog::trace (this=0x75ff60, tag=0x0, context_id=..., 
    fmt=0x50e900 "-> HLS time=%dms, sno=%d, ts=%s, dur=%dms, dva=%dp") at src/app/srs_app_log.cpp:134
#5  0x00147894 in SrsHls::hls_show_mux_log (this=0x92bbe0) at src/app/srs_app_hls.cpp:1358
#6  0x0014765c in SrsHls::on_video (this=0x92bbe0, shared_video=0x76712b28, format=0x92a658) at src/app/srs_app_hls.cpp:1342
#7  0x0012ef2c in SrsOriginHub::on_video (this=0x92aa60, shared_video=0x76712b28, is_sequence_header=false)
    at src/app/srs_app_source.cpp:1065
#8  0x001360d8 in SrsLiveSource::on_video_imp (this=0x92bca8, msg=0x76712b28) at src/app/srs_app_source.cpp:2347
#9  0x00135c78 in SrsLiveSource::on_video (this=0x92bca8, shared_video=0x951418) at src/app/srs_app_source.cpp:2302
#10 0x00126aa4 in SrsRtmpConn::process_publish_message (this=0x7a9710, source=0x92bca8, msg=0x951418)
    at src/app/srs_app_rtmp_conn.cpp:1064
#11 0x00126870 in SrsRtmpConn::handle_publish_message (this=0x7a9710, source=0x92bca8, msg=0x951418)
    at src/app/srs_app_rtmp_conn.cpp:1036
#12 0x001d3934 in SrsPublishRecvThread::consume (this=0x9287a8, msg=0x951418) at src/app/srs_app_recv_thread.cpp:373
#13 0x001d2894 in SrsRecvThread::do_cycle (this=0x9287b8) at src/app/srs_app_recv_thread.cpp:131
#14 0x001d2698 in SrsRecvThread::cycle (this=0x9287b8) at src/app/srs_app_recv_thread.cpp:100
#15 0x00159f18 in SrsFastCoroutine::cycle (this=0x964538) at src/app/srs_app_st.cpp:272
#16 0x00159fb4 in SrsFastCoroutine::pfn (arg=0x964538) at src/app/srs_app_st.cpp:287
#17 0x0027b2e4 in _st_thread_main () at sched.c:363
#18 0x0027bda0 in st_thread_create (start=0x30, arg=0xf, joinable=2, stk_size=6) at sched.c:694
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

On the Raspberry Pi, when enabling the HLS configuration in SRS 4.0, the RTMP streaming client crashes after approximately 10 seconds. The following is the gdb backtrace information:
When commenting out the HLS section in the configuration file, it runs normally.
The normal configuration file is as follows:

lmp@lmp:~/srs/srs-server-4.0-r4/trunk $ cat conf/srs.conf
\# main config for srs.
\# @see full.conf for detail config.
listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank    console;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
vhost __defaultVhost__ {
\#    hls {
\#        enabled         on;
\#    }
}

TRANS_BY_GPT3

@winlinvip winlinvip changed the title 树莓派3 srs4 ffmpeg 推流,一配置 hls参数 几个包 srs就崩溃了 Raspberry Pi 3 SRS4 ffmpeg streaming, when configuring HLS parameters, SRS crashes after a few packets. Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
@winlinvip
Copy link
Member

The bug is introduced by formarting log with string:

void SrsHls::hls_show_mux_log()
    srs_trace("-> " SRS_CONSTS_LOG_HLS " time=%" PRId64 "ms, sno=%d, ts=%s, dur=%dms, dva=%dp",
              pprint->age(), controller->sequence_no(), controller->ts_url().c_str(),
              srsu2msi(controller->duration()), controller->deviation());

The only formating string is ts=%s, so it should be the root cause.

@winlinvip winlinvip changed the title Raspberry Pi 3 SRS4 ffmpeg streaming, when configuring HLS parameters, SRS crashes after a few packets. HLS: Crashed on Raspberry Pi 3 when access FLV May 8, 2024
@winlinvip
Copy link
Member

I notice the FLV was requested, but user didn't enable it:

[2021-12-10 20:03:11.991][Trace][31203][d0916406] HTTP #0 192.168.3.205:54169 GET http://192.168.3.232:8080/live/livestream.flv, content-length=-1
[2021-12-10 20:03:11.991][Warn][31203][d0916406][2] http miss file=./objs/nginx/html/live/livestream.flv, pattern=/, upath=/live/livestream.flv

[2021-12-10 20:03:12.003][Trace][31203][d0916406] TCP: before dispose resource(HttpStream)(0x2a445b0), conns=2, zombies=0, ign=0, inz=0, ind=0
[2021-12-10 20:03:12.003][Warn][31203][d0916406][104] client disconnect peer. ret=1007
[2021-12-10 20:03:12.003][Trace][31203][84192ha6] TCP: clear zombies=1 resources, conns=2, removing=0, unsubs=0
[2021-12-10 20:03:12.003][Trace][31203][d0916406] TCP: disposing #0 resource(HttpStream)(0x2a445b0), conns=2, disposing=1, zombies=0
Segmentation fault

May be caused by this problem, need to reproduce it.

@winlinvip winlinvip added the HLS For HLS, MPEG-DASH or CMAF. label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. HLS For HLS, MPEG-DASH or CMAF. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

3 participants