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: The DVR file becomes corrupt when the frames per second (fps) is very low. The recorded FLV video, which is streamed using WebRTC and has a frame rate of only 1 frame every 2-3 seconds, fails to play. #3122

Open
ziyue7575 opened this issue Jul 25, 2022 · 5 comments
Assignees
Labels
TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC.
Milestone

Comments

@ziyue7575
Copy link

ziyue7575 commented Jul 25, 2022

The video streaming part sometimes has a frame rate of around 1 frame per 1.2 seconds, and sometimes only 1 frame is pushed every 2-3 seconds. This part, where only 1 frame is pushed every 2-3 seconds, will fail to play.

Description

Description
The video stream is only pushed at a rate of 1 frame every 2-3 seconds. It can be recorded and played in real-time using WebRTC, but the recorded video fails to play. When pushed for 5 minutes, it only plays for a moment.

1. SRS Version: 4.0.212

1. SRS Log:

Attachment

1. SRS Config (Configuration):

 listen              13425;
max_connections     1000;
daemon              on;
srs_log_tank        file;

http_server {
    enabled         on;
    listen          13423;
**# Configure an empty directory to disable usage**
    dir             ./objs/nginx/html;
}

http_api {
    enabled         on;
    listen          1985;
    raw_api {
        enabled on;
        allow_reload on;
        allow_query on;
        allow_update on;
    }
}
stats {
    network         0;
}
rtc_server {
    enabled on;
    listen 13427; # UDP port
    # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#config-candidate
    # candidate $CANDIDATE;
    candidate 192.168.3.90;
}

vhost __defaultVhost__ {
    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;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    http_hooks {
        enabled on;
**on_unpublish http://cc-web-1:8090/web/srs/actionSrs; # Callback for ucare, disconnect other streams for this push**
    }
}
vhost saveVhost {
    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;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    dvr {
        enabled on;
        dvr_path /usr/local/stuff/srs/srs.oschina-4.0release/trunk/objs/nginx/html/dvrfile/saveVhost/[app]/[stream]/[timestamp].flv;
        dvr_plan segment;
**dvr_duration 3600; # 1 hour per video**
        dvr_wait_keyframe on;
        dvr_apply all;
    }
    http_hooks {
        enabled on;
**on_unpublish http://cc-web-1:8090/web/srs/actionSrs; # Callback for ucare, disconnect other streams for this publishing
        on_dvr http://cc-web-1:8090/web/srs/actionSrs; # Callback for ucare, disconnect other streams for this publishing**
    }
}

vhost test {
    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;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].mp4;
    }
    dvr {
        enabled on;
        dvr_path /usr/local/stuff/srs/srs.oschina-4.0release/trunk/objs/nginx/html/dvrfile/test/[app]/[stream]/[timestamp].mp4;
        dvr_plan segment;
**dvr_duration 3600; # 1 hour per video**
        dvr_wait_keyframe on;
        dvr_apply all;
    }
    http_hooks {
        enabled on;
    }
}
 

Replay (重现)

When pushing the video, 1 frame is pushed every 2-3 seconds, and the recorded video cannot be played.

Expect (Expected Behavior)

Hope that even with such slow buffering, it can still be recorded and played back normally.

TRANS_BY_GPT3

@ziyue7575
Copy link
Author

ziyue7575 commented Jul 25, 2022

srs_err.log
log

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Aug 7, 2022

Are you using WebRTC for streaming? Is the recorded content normal? Are there any instances of fast-forwarding or slow playback?

TRANS_BY_GPT3

@winlinvip winlinvip changed the title srs保存的视频时长错误 WebRTC:录制的视频内容时长只有一半 Aug 7, 2022
@winlinvip winlinvip self-assigned this Aug 7, 2022
@winlinvip winlinvip added the WebRTC WebRTC, RTC2RTMP or RTMP2RTC. label Aug 7, 2022
@winlinvip winlinvip added this to the 5.0 milestone Aug 7, 2022
@ziyue7575
Copy link
Author

ziyue7575 commented Aug 10, 2022

@winlinvip
When streaming with WebRTC, it can immediately play and generate a temporary video file. However, it takes 5-6 seconds to start recording with the above configuration. I changed the configuration to the following (pli_for_rtmp 0.5;) and after streaming, it can start recording in about 0.5 seconds. However, it can only save videos with 8 frames per second, and streams with 1 frame every 3 seconds still cannot be saved.

listen 1935;
max_connections 1000;
daemon on;
srs_log_tank file;
## Disable version check
query_latest_version off;
http_server {
    enabled on;
    listen 8080;
    dir ./objs/nginx/html;
}
http_api {
    enabled on;
    listen 1985;
    raw_api {
        enabled on;
        allow_reload on;
        allow_query on;
        allow_update on;
    }
}
## WebRtc Configuration
rtc_server {
    enabled on;
    listen 18000;
    candidate *;
    api_as_candidates off;
}
vhost saveVhost {
    tcp_nodelay on;
    # Enable Low Latency Mode
    min_latency on;
    play {
        # If minimum latency is required, set it to off;
        # If fast client startup is required, set it to on.
        gop_cache off;
        # Maximum real-time queue length (in seconds).
        queue_length 10;
        # atc                     on;
        # mix_correct             on;
        mw_latency      100;
    }
     publish {
        mr off;
    }
    # Play webrtc
    rtc {
        enabled     on;
        rtmp_to_rtc on;
        rtc_to_rtmp on;
        stun_timeout 5;
        stun_strict_check on;
        nack on;
        twcc on;
         pli_for_rtmp 0.5;
    }
    # Play flv
    http_remux {
        enabled on;
        mount [vhost]/[app]/[stream].flv;
    }
    dvr {
        enabled on;
        # The address cannot use relative address, otherwise the callback address will also be a relative address, and the callback interface cannot handle it.
        dvr_path /usr/local/stuff/srs413/trunk/objs/nginx/html/dvrfile/[vhost]/[app]/[stream]/[timestamp].flv;
        dvr_plan segment;
        dvr_duration 3600; # 1 hour per video
        dvr_wait_keyframe off;
        dvr_apply all;
    }
    http_hooks {
        enabled off;
    }
}

`TRANS_BY_GPT3`

@ziyue7575 ziyue7575 changed the title WebRTC:录制的视频内容时长只有一半 WebRTC:webrtc推流,2-3s才推送1帧的视频流录制的flv视频播放失败 Aug 11, 2022
@ziyue7575
Copy link
Author

ziyue7575 commented Aug 11, 2022

1660126459708.zip
This is a recorded video that was pushed for several minutes, but after the recording was completed, it cannot be played.

TRANS_BY_GPT3

@ziyue7575
Copy link
Author

ziyue7575 commented Aug 11, 2022

dvr setting time_jitter zero; The video can be recorded normally, but previously the webRTC streaming could be played immediately, now it takes almost 20 seconds to start playing, and the video also starts recording at this time.

TRANS_BY_GPT3

@winlinvip winlinvip changed the title WebRTC:webrtc推流,2-3s才推送1帧的视频流录制的flv视频播放失败 WebRTC:DVR file is corrupt when fps is very low. webrtc推流,2-3s才推送1帧的视频流录制的flv视频播放失败 Dec 25, 2022
@winlinvip winlinvip changed the title WebRTC:DVR file is corrupt when fps is very low. webrtc推流,2-3s才推送1帧的视频流录制的flv视频播放失败 WebRTC: The DVR file becomes corrupt when the frames per second (fps) is very low. The recorded FLV video, which is streamed using WebRTC and has a frame rate of only 1 frame every 2-3 seconds, fails to play. 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
TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC.
Projects
None yet
Development

No branches or pull requests

2 participants