ossrs/srs

Streaming the camera to the SRS3.0 server and generating HLS involves a process where the duration (dur) gradually increases over time until the generated ts files no longer contain video information.

ZiJinMountain opened this issue · 5 comments

The process of generating HLS involves the duration (dur) slowly increasing over time until the generated ts files have no video information. Previously, the hls_fragment was set to 10 seconds and hls_window to 60, but it didn't work. After increasing the values, it was able to generate a segment. However, the dur value is very unstable and doesn't gradually increase as configured (around 20 seconds). When it reaches around 40 seconds, the ts files are generated without video, and eventually, the dur value becomes extremely large, causing the ts files to be dropped. Please help identify the issue with this.

Version: 3.0.25

Configuration file:

listen              1935;
max_connections     1000;
srs_log_tank        file;
srs_log_file        ./objs/srs.log;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             /usr/local/nginx/html;
}
stats {
    network         0;
    disk            sda sdb xvda xvdb;
}


vhost __defaultVhost__ {
    gop_cache       off;
    queue_length    1;
    min_latency     on;
    mr {
        enabled     off;
    }
    mw_latency      100;
    tcp_nodelay     on;
    hls {
        enabled         on;
        hls_fragment    20;
        hls_window      600;
        hls_path        /usr/local/nginx/html;
        hls_m3u8_file   [app]/[stream].m3u8;
        hls_ts_file     [app]/[stream]-[seq].ts;
    }
    http_remux {
        enabled     off;
        mount       [vhost]/[app]/[stream].flv;
        hstrs       on;
    }
}
[root@localhost trunk]# 

LOG printing:

[root@localhost trunk]# tail -f  ./objs/srs.log
[2018-01-22 01:47:37.543][Trace][9311][106] source url=/live/livestream, ip=10.43.154.41, cache=0, is_edge=0, source_id=-1[-1]
[2018-01-22 01:47:37.555][Trace][9311][106] hls: win=600.00, frag=20.00, prefix=, path=/usr/local/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=0
[2018-01-22 01:47:37.555][Trace][9311][106] ignore disabled exec for vhost=__defaultVhost__
[2018-01-22 01:47:37.555][Trace][9311][106] set TCP_NODELAY 0=>1
[2018-01-22 01:47:37.555][Trace][9311][106] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=1, rtcid=0
[2018-01-22 01:47:37.557][Trace][9311][106] got metadata, width=1280, height=720, vcodec=7, acodec=10
[2018-01-22 01:47:37.558][Trace][9311][106] protocol in.buffer=0, in.ack=0, out.ack=2500000, in.chunk=128, out.chunk=60000
[2018-01-22 01:47:37.558][Trace][9311][106] 43B video sh,  codec(7, profile=Main, level=3.1, 1280x720, 0kbps, 0.0fps, 0.0s)
[2018-01-22 01:47:37.558][Trace][9311][106] 4B audio sh, codec(10, profile=LC, 1channels, 0kbps, 32000HZ), flv(16bits, 2channels, 44100HZ)
[2018-01-22 01:47:46.614][Trace][9311][106] -> HLS time=10000, sno=1, ts=livestream-0.ts, dur=17.75, dva=0p
[2018-01-22 01:47:56.608][Trace][9311][106] -> HLS time=20001, sno=1, ts=livestream-0.ts, dur=27.74, dva=0p
[2018-01-22 01:48:02.555][Trace][9311][106] <- CPB time=19053, okbps=1,0,0, ikbps=1903,0,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:48:06.617][Trace][9311][106] -> HLS time=30001, sno=1, ts=livestream-0.ts, dur=37.77, dva=0p
[2018-01-22 01:48:12.555][Trace][9311][106] <- CPB time=29053, okbps=0,0,0, ikbps=1889,1889,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:48:16.599][Trace][9311][106] -> HLS time=40001, sno=2, ts=livestream-1.ts, dur=24.92, dva=0p
[2018-01-22 01:48:22.555][Trace][9311][106] <- CPB time=39053, okbps=0,0,0, ikbps=1899,1889,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:48:26.615][Trace][9311][106] -> HLS time=50002, sno=2, ts=livestream-1.ts, dur=34.95, dva=0p
[2018-01-22 01:48:32.555][Trace][9311][106] <- CPB time=49054, okbps=0,0,0, ikbps=1890,1889,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:48:36.640][Trace][9311][106] -> HLS time=60002, sno=3, ts=livestream-2.ts, dur=28.31, dva=0p
[2018-01-22 01:48:42.555][Trace][9311][106] <- CPB time=59054, okbps=0,0,0, ikbps=1895,1901,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:48:46.620][Trace][9311][106] -> HLS time=70002, sno=4, ts=livestream-3.ts, dur=31.77, dva=0p
[2018-01-22 01:48:52.555][Trace][9311][106] <- CPB time=69054, okbps=0,0,0, ikbps=1889,1901,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:48:56.608][Trace][9311][106] -> HLS time=80002, sno=5, ts=livestream-4.ts, dur=31.48, dva=0p
[2018-01-22 01:49:02.555][Trace][9311][106] <- CPB time=79054, okbps=0,0,0, ikbps=1892,1901,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:49:06.617][Trace][9311][106] -> HLS time=90002, sno=6, ts=livestream-5.ts, dur=33.99, dva=0p
[2018-01-22 01:49:12.555][Trace][9311][106] <- CPB time=89054, okbps=0,0,0, ikbps=1888,1873,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:49:16.641][Trace][9311][106] -> HLS time=100003, sno=7, ts=livestream-6.ts, dur=38.59, dva=0p
[2018-01-22 01:49:22.555][Trace][9311][106] <- CPB time=99055, okbps=0,0,0, ikbps=1892,1873,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:49:26.619][Trace][9311][106] -> HLS time=110003, sno=11, ts=livestream-10.ts, dur=38.60, dva=0p
[2018-01-22 01:49:32.555][Trace][9311][106] <- CPB time=109055, okbps=0,0,0, ikbps=1889,1873,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:49:36.607][Trace][9311][106] -> HLS time=120003, sno=120, ts=livestream-119.ts, dur=41.23, dva=0p
[2018-01-22 01:49:42.555][Trace][9311][106] <- CPB time=119055, okbps=0,0,0, ikbps=1891,1901,0, mr=0/350, p1stpt=20000, pnt=5000
[2018-01-22 01:49:46.622][Trace][9311][106] -> HLS time=130006, sno=338, ts=livestream-337.ts, dur=43.97, dva=0p

TRANS_BY_GPT3

Hello, ZiJinMountain. May I ask where to download SRS3.0?

TRANS_BY_GPT3

@Liu-Tommy git checkout 3.0release, please note that SRS3 is currently in the development version.

TRANS_BY_GPT3

@ZiJinMountain, can you provide the source file for streaming? It could be an issue with the stream.

TRANS_BY_GPT3

This is because the audio is generated based on the number of AAC samples, so it will increase linearly. If the video is not increasing linearly, it will cause a significant difference between the audio and video streams. When receiving an audio and video, the slicing process starts, but if the timestamp difference is too large, the slice is discarded.

Re-push the stream, and the audio continues to increase linearly.

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x00000001003a2620 srs`SrsFragment::append(this=0x0000000100c019b0, dts=210930) at srs_app_fragment.cpp:47
    frame #1: 0x00000001001c7a0c srs`SrsHlsMuxer::flush_audio(this=0x0000000100a01ae0, cache=0x0000000100a01ac0) at srs_app_hls.cpp:582
    frame #2: 0x00000001001cd8da srs`SrsHlsController::reap_segment(this=0x0000000100a01aa0) at srs_app_hls.cpp:1032
    frame #3: 0x00000001001cd4ad srs`SrsHlsController::write_audio(this=0x0000000100a01aa0, frame=0x0000000101809600, pts=18983706) at srs_app_hls.cpp:953
    frame #4: 0x00000001001ce822 srs`SrsHls::on_audio(this=0x0000000100a01a30, shared_audio=0x0000000100b9c988, format=0x0000000100a021d0) at srs_app_hls.cpp:1221
    frame #5: 0x00000001001a0463 srs`SrsOriginHub::on_audio(this=0x0000000100a019c0, shared_audio=0x0000000100b9c988) at srs_app_source.cpp:969
    frame #6: 0x00000001001aff97 srs`SrsSource::on_audio_imp(this=0x0000000100a003a0, msg=0x0000000100b9c988) at srs_app_source.cpp:2139
    frame #7: 0x00000001001afa98 srs`SrsSource::on_audio(this=0x0000000100a003a0, shared_audio=0x0000000100804ca0) at srs_app_source.cpp:2089
    frame #8: 0x000000010019483a srs`SrsRtmpConn::process_publish_message(this=0x0000000100a02e70, source=0x0000000100a003a0, msg=0x0000000100804ca0) at srs_app_rtmp_conn.cpp:1030
    frame #9: 0x00000001001946e4 srs`SrsRtmpConn::handle_publish_message(this=0x0000000100a02e70, source=0x0000000100a003a0, msg=0x0000000100804ca0) at srs_app_rtmp_conn.cpp:1009
    frame #10: 0x000000010032ea4a srs`SrsPublishRecvThread::consume(this=0x0000000100b88c38, msg=0x0000000100804ca0) at srs_app_recv_thread.cpp:387
    frame #11: 0x000000010032c751 srs`SrsRecvThread::do_cycle(this=0x0000000100b88c40) at srs_app_recv_thread.cpp:145
    frame #12: 0x000000010032c5d0 srs`SrsRecvThread::cycle(this=0x0000000100b88c40) at srs_app_recv_thread.cpp:114
    frame #13: 0x00000001001f5408 srs`SrsSTCoroutine::cycle(this=0x0000000100900fb0) at srs_app_st.cpp:190
    frame #14: 0x00000001001f512e srs`SrsSTCoroutine::pfn(arg=0x0000000100900fb0) at srs_app_st.cpp:201
    frame #15: 0x00000001003bf908 srs`_st_thread_main at sched.c:337
    frame #16: 0x00000001003bef9c srs`st_thread_create(start=0x0000000000000000, arg=0x00000001009003e0, joinable=1, stk_size=12093292) at sched.c:616

If the stream is re-pushed, the video timestamp starts from 0.

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x00000001003a2620 srs`SrsFragment::append(this=0x0000000100c019b0, dts=320) at srs_app_fragment.cpp:47
    frame #1: 0x00000001001c7c20 srs`SrsHlsMuxer::flush_video(this=0x0000000100a01ae0, cache=0x0000000100a01ac0) at srs_app_hls.cpp:611
    frame #2: 0x00000001001cd736 srs`SrsHlsController::write_video(this=0x0000000100a01aa0, frame=0x0000000101807c00, dts=28800) at srs_app_hls.cpp:1000
    frame #3: 0x00000001001cec31 srs`SrsHls::on_video(this=0x0000000100a01a30, shared_video=0x0000000100b9c980, format=0x0000000100a021d0) at srs_app_hls.cpp:1265
    frame #4: 0x00000001001a1be2 srs`SrsOriginHub::on_video(this=0x0000000100a019c0, shared_video=0x0000000100b9c980, is_sequence_header=false) at srs_app_source.cpp:1056
    frame #5: 0x00000001001b0939 srs`SrsSource::on_video_imp(this=0x0000000100a003a0, msg=0x0000000100b9c980) at srs_app_source.cpp:2254
    frame #6: 0x00000001001b04a7 srs`SrsSource::on_video(this=0x0000000100a003a0, shared_video=0x0000000100900dd0) at srs_app_source.cpp:2209
    frame #7: 0x00000001001948c3 srs`SrsRtmpConn::process_publish_message(this=0x0000000100a02e70, source=0x0000000100a003a0, msg=0x0000000100900dd0) at srs_app_rtmp_conn.cpp:1037
    frame #8: 0x00000001001946e4 srs`SrsRtmpConn::handle_publish_message(this=0x0000000100a02e70, source=0x0000000100a003a0, msg=0x0000000100900dd0) at srs_app_rtmp_conn.cpp:1009
    frame #9: 0x000000010032ea4a srs`SrsPublishRecvThread::consume(this=0x0000000100b88c38, msg=0x0000000100900dd0) at srs_app_recv_thread.cpp:387
    frame #10: 0x000000010032c751 srs`SrsRecvThread::do_cycle(this=0x0000000100b88c40) at srs_app_recv_thread.cpp:145
    frame #11: 0x000000010032c5d0 srs`SrsRecvThread::cycle(this=0x0000000100b88c40) at srs_app_recv_thread.cpp:114
    frame #12: 0x00000001001f5408 srs`SrsSTCoroutine::cycle(this=0x0000000100900fb0) at srs_app_st.cpp:190
    frame #13: 0x00000001001f512e srs`SrsSTCoroutine::pfn(arg=0x0000000100900fb0) at srs_app_st.cpp:201
    frame #14: 0x00000001003bf908 srs`_st_thread_main at sched.c:337
    frame #15: 0x00000001003bef9c srs`st_thread_create(start=0x0000000000000000, arg=0x00000001009003e0, joinable=1, stk_size=12093292) at sched.c:616

If the duration of a segment exceeds the maximum of 30 seconds specified in the configuration, it will be discarded.

TRANS_BY_GPT3

The reason is that previous_audio_dts was not assigned correctly.

TRANS_BY_GPT3