srs icon indicating copy to clipboard operation
srs copied to clipboard

WebRtc录制Mp4时意外中断录制

Open ShuiFan0 opened this issue 3 years ago • 4 comments

WebRtc推流正常连接,mp4.tmp或mp4文件正常创建,如果正常生成mp4文件,则时长小于WebRtc推流连接时长

  1. SRS Version(版本): 4.0.251

  2. SRS Log(日志):

[2022-06-22 10:08:32.357][Trace][1445][48u84345] Hybrid cpu=2.00%,24MB, cid=10,4, timer=62,9,42, clock=0,47,1,0,1,0,0,0,0, free=1, objs=(pkt:108,raw:45,fua:62,msg:174,oth:1,buf:76)
[2022-06-22 10:08:32.357][Trace][1445][48u84345] RTC: Server conns=1, rpkts=(1,rtp:1,stun:1,rtcp:1), spkts=(1,rtp:0,stun:1,rtcp:1), rtcp=(pli:1,twcc:1,rr:1), snk=(1,a:1,v:1,h:1), fid=(id:1,fid:1,ffid:0,addr:1,faddr:1)
[2022-06-22 10:08:32.462][Trace][1445][23i5h673] 38B video sh,  codec(7, profile=Baseline, level=4.1, 480x640, 0kbps, 0.0fps, 0.0s)
[2022-06-22 10:08:32.462][Trace][1445][23i5h673] set ts=4088061409, header=31979, lost=31980


[2022-06-22 10:08:37.358][Trace][1445][48u84345] Hybrid cpu=1.00%,24MB, cid=10,4, timer=62,9,42, clock=0,47,1,0,1,0,0,0,0, free=1, objs=(pkt:108,raw:45,fua:62,msg:174,oth:1,buf:76)
[2022-06-22 10:08:37.358][Trace][1445][48u84345] RTC: Server conns=1, rpkts=(110,rtp:108,stun:1,rtcp:1), spkts=(14,rtp:0,stun:1,rtcp:23), rtcp=(pli:1,twcc:9,rr:1), snk=(98,a:49,v:49,h:0), fid=(id:0,fid:110,ffid:0,addr:1,faddr:110)
[2022-06-22 10:08:38.603][Trace][1445][23i5h673] 38B video sh,  codec(7, profile=Baseline, level=4.1, 640x480, 0kbps, 0.0fps, 0.0s)
^[[33m[2022-06-22 10:08:38.603][Warn][1445][23i5h673][11] dvr: ignore video error code=3085 : write video : encode video : write sample : doesn't support avcc change
thread [1445][23i5h673]: on_video() [src/app/srs_app_dvr.cpp:649][errno=11]
thread [1445][23i5h673]: write_video() [src/app/srs_app_dvr.cpp:146][errno=11]
thread [1445][23i5h673]: encode_video() [src/app/srs_app_dvr.cpp:503][errno=11]
thread [1445][23i5h673]: copy_sequence_header() [src/kernel/srs_kernel_mp4.cpp:6042][errno=11]
^[[0m[2022-06-22 10:08:38.604][Trace][1445][23i5h673] set ts=4088582419, header=32441, lost=32442
[2022-06-22 10:08:38.989][Trace][1445][412u01p0] <- RTC RECV #12, udp 1253, pps 0/125, schedule 1253
  1. SRS Config(配置):

listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;

http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
    https {
        enabled on;
        listen 8088;
        key ./com.key;
        cert ./com_bundle.crt;
    }
}

http_api {
    enabled         on;
    listen          1985;
    https {
        enabled on;
        listen 1990;
        key ./com.key;
        cert ./com_bundle.crt;
    }
}
stats {
    network         0;
}
rtc_server {
    enabled         on;
    listen 8000; # UDP port
    # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#config-candidate
    candidate       $CANDIDATE;
}

vhost __defaultVhost__ {
    hls {
        enabled         on;
        hls_path        ./objs/nginx/html;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    rtc {
        enabled     on;
        # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtmp-to-rtc
        rtmp_to_rtc on;
        # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtc-to-rtmp
        rtc_to_rtmp on;
        
        stun_timeout 10;#//10秒会话超时
    }
    dvr {
        enabled		on;
	dvr_apply	all;
	dvr_path        /srs.dvr/[vhost]/[app]/[2006]/[01].[02]/[stream].[15].[04].[05].[999].mp4;
	time_jitter	full;
    }
    http_hooks{
        #enabled		on;
    }
}


Replay(重现)

  1. 手机端开启旋转功能,旋转后视频录制立刻中断

Expect(期望行为)

如果视频发生了无法录制在一个文件的情况,请重新创建一个新的文件进行录制

ShuiFan0 avatar Jun 22 '22 05:06 ShuiFan0

In addition, there are situations where the recording is interrupted due to an inability to determine the source of the problem.

^[[0m^[[33m[2022-06-22 09:15:02.575][Warn][1445][32s11lib][11] RTC: Drop for ssrc 4242485370 not found
^[[0m[2022-06-22 09:15:02.590][Trace][1445][98943745] 53B video sh,  codec(7, profile=Baseline, level=3, 640x360, 0kbps, 0.0fps, 0.0s)
[2022-06-22 09:15:02.590][Trace][1445][98943745] set ts=1128207784, header=32017, lost=32018
^[[33m[2022-06-22 09:15:02.594][Warn][1445][32s11lib][11] RTC: Drop for ssrc 4242485370 not found
^[[0m^[[33m[2022-06-22 09:15:02.606][Warn][1445][32s11lib][11] RTC: Drop for ssrc 1869789899 not found
^[[0m^[[33m[2022-06-22 09:15:02.831][Warn][1445][32s11lib][11] RTC: Drop for ssrc 1869789899 not found
^[[0m[2022-06-22 09:15:02.857][Trace][1445][ot964s28] 53B video sh,  codec(7, profile=Baseline, level=3, 640x360, 0kbps, 0.0fps, 0.0s)
^[[33m[2022-06-22 09:15:02.857][Warn][1445][ot964s28][11] dvr: ignore video error code=3085 : write video : encode video : write sample : doesn't support avcc change
thread [1445][ot964s28]: on_video() [src/app/srs_app_dvr.cpp:649][errno=11]
thread [1445][ot964s28]: write_video() [src/app/srs_app_dvr.cpp:146][errno=11]
thread [1445][ot964s28]: encode_video() [src/app/srs_app_dvr.cpp:503][errno=11]
thread [1445][ot964s28]: copy_sequence_header() [src/kernel/srs_kernel_mp4.cpp:6042][errno=11]
^[[0m[2022-06-22 09:15:02.857][Trace][1445][ot964s28] set ts=1128227944, header=32138, lost=32139
^[[33m[2022-06-22 09:15:02.859][Warn][1445][32s11lib][11] RTC: Drop for ssrc 4242485370 not found
^[[0m^[[33m[2022-06-22 09:15:02.859][Warn][1445][32s11lib][11] RTC: Drop for ssrc 1869789899 not found

Among them, there were numerous errors like RTC: Drop for ssrc. Due to their frequent occurrence, some of them were removed from the above log to avoid confusion.

I can confirm that there was no rotation occurring here (because I am using a PC browser).

TRANS_BY_GPT3

ShuiFan0 avatar Jun 22 '22 06:06 ShuiFan0

Here, I hope that if there is an error during video recording

  1. Save the existing data and stop recording the current file.

  2. Attempt to restart recording, and if recording can be started, save it to a file.

  3. (If recording fails, it is best to keep a failed file until recording is successfully restarted.)

TRANS_BY_GPT3

ShuiFan0 avatar Jun 22 '22 06:06 ShuiFan0

WebRTC recording is a challenge, this thing often changes sps/pps.

If HLS is working properly, you can consider using on_hls for recording. For more details, please refer to https://github.com/ossrs/srs/issues/1577.

TRANS_BY_GPT3

winlinvip avatar Jun 25 '22 12:06 winlinvip

WebRTC recording is a challenge, this thing often changes sps/pps.

If HLS is working properly, you can consider using on_hls for recording, please refer to #1577 for more details.

I haven't tried HLS yet, but I feel that the more complex it is, the more likely it is to have issues. I think it would be more stable to save WebRTC as webm, taking reference from open-source codes like Google Chrome browser.

TRANS_BY_GPT3

ShuiFan0 avatar Jun 27 '22 09:06 ShuiFan0

WebRTC recording is a challenge, this thing often changes sps/pps.

If HLS is working properly, you can consider using on_hls for recording, please refer to #1577 for more details.

Changing the resolution during webrtc recording does indeed cause the DVR recording to fail. I have looked into the recording documentation for HLS and configured hls_cleanup to be off, which prevents the deletion of ts files. However, it seems that the m3u8 file cannot save all the ts information completely and may delete old ones based on the configuration rules. I noticed that srs-cloud seems to be able to do this. How can I configure it to save the complete m3u8 file? I would like to use this to solve the recording issue.

TRANS_BY_GPT3

drchzy avatar Mar 12 '23 05:03 drchzy