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

WebRtc recording interrupted unexpectedly while recording Mp4 #3073

Open
ShuiFan0 opened this issue Jun 22, 2022 · 5 comments
Open

WebRtc recording interrupted unexpectedly while recording Mp4 #3073

ShuiFan0 opened this issue Jun 22, 2022 · 5 comments
Assignees
Labels
DVR DVR to FLV or MP4. TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC.

Comments

@ShuiFan0
Copy link

ShuiFan0 commented Jun 22, 2022

WebRtc streaming connection is normal, mp4.tmp or mp4 file is successfully created. If the mp4 file is generated successfully, its duration will be shorter than the duration of the WebRtc streaming connection.

  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-second session timeout
    }
    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. When the rotation function is enabled on the mobile phone, the video recording is immediately interrupted after rotation.

Expect (Expected Behavior)

If the video cannot be recorded in one file, please create a new file for recording.

TRANS_BY_GPT3

@ShuiFan0
Copy link
Author

ShuiFan0 commented Jun 22, 2022

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
Copy link
Author

ShuiFan0 commented Jun 22, 2022

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

@winlinvip winlinvip self-assigned this Jun 25, 2022
@winlinvip winlinvip added WebRTC WebRTC, RTC2RTMP or RTMP2RTC. DVR DVR to FLV or MP4. labels Jun 25, 2022
@winlinvip
Copy link
Member

winlinvip commented Jun 25, 2022

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 #1577.

TRANS_BY_GPT3

@ShuiFan0
Copy link
Author

ShuiFan0 commented Jun 27, 2022

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

@drchzy
Copy link

drchzy commented Mar 12, 2023

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

@winlinvip winlinvip changed the title WebRtc录制Mp4时意外中断录制 WebRtc recording interrupted unexpectedly while recording Mp4 Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DVR DVR to FLV or MP4. TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC.
Projects
None yet
Development

No branches or pull requests

3 participants