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

DVR: When opening dvr_wait_keyframe, the recorded video duration is one keyframe interval longer than dvr_duration. #2725

Closed
xupeng1206 opened this issue Nov 9, 2021 · 1 comment
Assignees
Labels
DVR DVR to FLV or MP4. TransByAI Translated by AI/GPT. Won't fix We won't fix it.

Comments

@xupeng1206
Copy link

xupeng1206 commented Nov 9, 2021

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

Description

DVR: When opening dvr_wait_keyframe, the recorded video duration is longer than dvr_duration by the time interval of one keyframe.

  1. SRS version: 4.0release

  2. SRS log:

[2021-11-09 08:48:14.919][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,1, timer=58,0,0, clock=0,13,28,3,0,0,0,0,0, free=1
[2021-11-09 08:48:15.405][Trace][1][257x5351] RTMP client ip=172.18.0.1:55156, fd=12
[2021-11-09 08:48:15.411][Trace][1][257x5351] complex handshake success
[2021-11-09 08:48:15.411][Trace][1][257x5351] connect app, tcUrl=rtmp://localhost:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=localhost, port=1935, app=live, args=null
[2021-11-09 08:48:15.411][Trace][1][257x5351] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2021-11-09 08:48:15.415][Trace][1][257x5351] client identified, type=fmle-publish, vhost=localhost, app=live, stream=livestream1, param=, duration=0ms
[2021-11-09 08:48:15.418][Trace][1][257x5351] http: on_connect ok, client_id=257x5351, url=http://192.168.2.110:8085/api/srs/hooks/connect, request={"action":"on_connect","client_id":"257x5351","ip":"172.18.0.1","vhost":"__defaultVhost__","app":"live","stream":"livestream1","param":"","tcUrl":"rtmp://localhost:1935/live","pageUrl":""}, response=0
[2021-11-09 08:48:15.419][Trace][1][257x5351] connected stream, tcUrl=rtmp://localhost:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=livestream1, param=, args=null
[2021-11-09 08:48:15.419][Trace][1][257x5351] source url=/live/livestream1, ip=172.18.0.1, cache=0, is_edge=0, source_id=/99277976
[2021-11-09 08:48:15.423][Trace][1][257x5351] RTC bridge from RTMP, discard_aac=0, discard_bframe=1, merge_nalus=0
[2021-11-09 08:48:15.431][Trace][1][257x5351] dvr stream livestream1 to file ./objs/nginx/html/live/livestream1/08-48-15-1636447695423.mp4
[2021-11-09 08:48:15.431][Trace][1][257x5351] ignore disabled exec for vhost=__defaultVhost__
[2021-11-09 08:48:15.431][Trace][1][257x5351] set fd=12 TCP_NODELAY 0=>1
[2021-11-09 08:48:15.431][Trace][1][257x5351] start publish mr=0/350, p1stpt=20000, pnt=600000, tcp_nodelay=1
[2021-11-09 08:48:15.433][Trace][1][257x5351] got metadata, width=1280, height=720, vcodec=7
[2021-11-09 08:48:15.434][Trace][1][257x5351] 39B video sh,  codec(7, profile=Main, level=3.1, 1280x720, 0kbps, 0.0fps, 0.0s)
[2021-11-09 08:48:19.920][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=2,1, timer=59,0,0, clock=0,19,24,1,0,0,1,0,0, objs=(pkt:28,raw:1,fua:27,msg:39,oth:1,buf:1)
[2021-11-09 08:48:24.921][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=2,1, timer=59,0,0, clock=0,19,24,1,0,0,1,0,0, objs=(pkt:28,raw:1,fua:27,msg:39,oth:1,buf:1)
[2021-11-09 08:48:29.921][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=2,1, timer=59,0,0, clock=0,19,24,1,0,0,1,0,0, objs=(pkt:28,raw:1,fua:27,msg:39,oth:1,buf:1)
[2021-11-09 08:48:34.922][Trace][1][qjaw1278] Hybrid cpu=0.00%,15MB, cid=1,0, timer=59,0,0, clock=0,17,27,1,0,0,1,0,0, objs=(pkt:79,raw:1,fua:77,msg:109,oth:1,buf:1)
[2021-11-09 08:48:35.423][Trace][1][257x5351] <- CPB time=0, okbps=1,0,0, ikbps=689,0,0, mr=0/350, p1stpt=20000, pnt=600000
[2021-11-09 08:48:39.923][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,17,27,1,0,0,1,0,0, objs=(pkt:79,raw:1,fua:77,msg:109,oth:1,buf:1)
[2021-11-09 08:48:44.923][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=1,0, timer=59,0,0, clock=0,17,27,1,0,0,1,0,0, objs=(pkt:79,raw:1,fua:77,msg:109,oth:1,buf:1)
[2021-11-09 08:48:49.924][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,21,24,1,0,0,0,0,0, objs=(pkt:75,raw:3,fua:71,msg:105,oth:1,buf:1)
[2021-11-09 08:48:54.925][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,21,24,1,0,0,0,0,0, objs=(pkt:75,raw:3,fua:71,msg:105,oth:1,buf:1)
[2021-11-09 08:48:59.926][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,21,24,1,0,0,0,0,0, objs=(pkt:75,raw:3,fua:71,msg:105,oth:1,buf:1)
[2021-11-09 08:49:04.927][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:75,raw:1,fua:73,msg:105,oth:1,buf:1)
[2021-11-09 08:49:09.929][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:75,raw:1,fua:73,msg:105,oth:1,buf:1)
[2021-11-09 08:49:14.929][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=1,0, timer=58,0,0, clock=0,16,27,1,0,0,1,0,0, objs=(pkt:88,raw:2,fua:85,msg:118,oth:1,buf:1)
[2021-11-09 08:49:18.880][Trace][1][257x5351] dvr stream livestream1 to file ./objs/nginx/html/live/livestream1/08-49-18-1636447758873.mp4
[2021-11-09 08:49:18.885][Trace][1][257x5351] http hook on_dvr success. client_id=257x5351, url=http://192.168.2.110:8085/api/srs/hooks/dvr, request={"server_id":"vid-a045f7g","action":"on_dvr","client_id":"257x5351","ip":"172.18.0.1","vhost":"__defaultVhost__","app":"live","stream":"livestream1","param":"","cwd":"/usr/local/srs","file":"./objs/nginx/html/live/livestream1/08-48-15-1636447695423.mp4"}, response=0
[2021-11-09 08:49:19.931][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=1,0, timer=58,0,0, clock=0,16,27,1,0,0,1,0,0, objs=(pkt:88,raw:2,fua:85,msg:118,oth:1,buf:1)
[2021-11-09 08:49:24.933][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=1,0, timer=59,0,0, clock=0,17,28,1,0,0,0,0,0, objs=(pkt:78,raw:5,fua:72,msg:108,oth:1,buf:1)
[2021-11-09 08:49:29.935][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=1,0, timer=59,0,0, clock=0,17,28,1,0,0,0,0,0, objs=(pkt:78,raw:5,fua:72,msg:108,oth:1,buf:1)
[2021-11-09 08:49:34.936][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,17,28,1,0,0,0,0,0, objs=(pkt:78,raw:5,fua:72,msg:108,oth:1,buf:1)
[2021-11-09 08:49:39.936][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,16,28,1,0,0,0,0,0, objs=(pkt:75,raw:1,fua:74,msg:105,oth:1,buf:1)
[2021-11-09 08:49:44.937][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,16,28,1,0,0,0,0,0, objs=(pkt:75,raw:1,fua:74,msg:105,oth:1,buf:1)
[2021-11-09 08:49:49.938][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,16,28,1,0,0,0,0,0, objs=(pkt:75,raw:1,fua:74,msg:105,oth:1,buf:1)
[2021-11-09 08:49:54.939][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:81,raw:2,fua:78,msg:111,oth:1,buf:1)
[2021-11-09 08:49:59.939][Trace][1][qjaw1278] Hybrid cpu=0.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:81,raw:2,fua:78,msg:111,oth:1,buf:1)
[2021-11-09 08:50:04.940][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:81,raw:2,fua:78,msg:111,oth:1,buf:1)
[2021-11-09 08:50:09.940][Trace][1][qjaw1278] Hybrid cpu=1.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:75,raw:4,fua:70,msg:105,oth:1,buf:1)
[2021-11-09 08:50:14.941][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:75,raw:4,fua:70,msg:105,oth:1,buf:1)
[2021-11-09 08:50:19.942][Trace][1][qjaw1278] Hybrid cpu=2.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:75,raw:4,fua:70,msg:105,oth:1,buf:1)
[2021-11-09 08:50:20.904][Trace][1][257x5351] dvr stream livestream1 to file ./objs/nginx/html/live/livestream1/08-50-20-1636447820900.mp4
[2021-11-09 08:50:20.909][Trace][1][257x5351] http hook on_dvr success. client_id=257x5351, url=http://192.168.2.110:8085/api/srs/hooks/dvr, request={"server_id":"vid-a045f7g","action":"on_dvr","client_id":"257x5351","ip":"172.18.0.1","vhost":"__defaultVhost__","app":"live","stream":"livestream1","param":"","cwd":"/usr/local/srs","file":"./objs/nginx/html/live/livestream1/08-49-18-1636447758873.mp4"}, response=0
[2021-11-09 08:50:24.943][Trace][1][qjaw1278] Hybrid cpu=3.00%,15MB, cid=1,0, timer=59,0,0, clock=0,18,26,1,0,0,0,0,0, objs=(pkt:81,raw:2,fua:78,msg:111,oth:1,buf:1)

  1. SRS configuration:

# main config for srs.
# @see full.conf for detail config.

listen              1935;
max_connections     5000;
srs_log_tank        console;
daemon              off;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
stats {
    network         0;
    disk            sda sdb xvda xvdb;
}
rtc_server {
    enabled         on;
    # Listen at udp://8000
    listen          8000;
    #
    # The $CANDIDATE means fetch from env, if not configed, use * as default.
    #
    # The * means retrieving server IP automatically, from all network interfaces,
    # @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124
    candidate       $CANDIDATE;
}
vhost __defaultVhost__ {
    tcp_nodelay     on
    min_latency     on;

    hls {
        enabled         off;
    }
    http_remux {
        enabled     off;
        mount       [vhost]/[app]/[stream].flv;
    }
    rtc {
        enabled     on;
        bframe      discard;
    }

    play {
        gop_cache       off;
        queue_length    10;
        mw_latency      100;
    }

    publish {
        mr off;
        # mr_latency 100;
        normal_timeout 600000;
    }

    dvr {
        enabled         on;
        dvr_apply       all;
        dvr_plan        segment;
        dvr_path        ./objs/nginx/html/[app]/[stream]/[15]-[04]-[05]-[timestamp].mp4;
        dvr_duration    60;
        dvr_wait_keyframe       on;
        time_jitter             full;
    }

    http_hooks{
        enabled       on;
        # 172.18.0.3 => srs_hook container ip
        on_connect    http://192.168.2.110:8085/api/srs/hooks/connect;
        on_close      http://192.168.2.110:8085/api/srs/hooks/close;
        # on_publish    http://192.168.2.110:8085/api/srs/hooks/publish;
        # on_unpublish  http://192.168.2.110:8085/api/srs/hooks/unpublish;
        on_play       http://192.168.2.110:8085/api/srs/hooks/play;
        on_stop       http://192.168.2.110:8085/api/srs/hooks/stop;
        on_dvr        http://192.168.2.110:8085/api/srs/hooks/dvr;
        # on_hls        http://192.168.2.110:8085/api/srs/hooks/hls;
        # on_hls_notify http://192.168.2.110:8085/api/srs/hooks/hls_notify;
    }
}

image

File name: hour-minute-second-timestamp.mp4
The keyframe interval of the source video stream is 2 seconds.

Replay

How to replay bug?

Steps to reproduce the bug

Steps to replay the bug:

  1. Run the following command to stream using ffmpeg:
ffmpeg -fflags nobuffer -max_delay 0 -analyzeduration 500000 -rtsp_transport tcp -i rtsp://admin:admin123%40@192.168.2.119/unicast/c1/s1/live -c:v copy -an -flush_packets 1 -f flv -y rtmp://localhost:1935/live/livestream1

This will push the stream to the SRS server.

  1. Observe the dvr_path.

Expected behavior:

Make sure to maintain the markdown structure.

Expected generated file duration should match dvr_duration.

Make sure to maintain the markdown structure.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Nov 10, 2021

How do you think it's possible? There will definitely be an extra gop.

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Nov 10, 2021
@winlinvip winlinvip added DVR DVR to FLV or MP4. Won't fix We won't fix it. labels Nov 10, 2021
@winlinvip winlinvip changed the title DVR: Segment 在打开dvr_wait_keyframe时,录制的视频时长比dvr_duration多一个关键帧的时间间隔 DVR: When opening dvr_wait_keyframe, the recorded video duration is one keyframe interval longer than dvr_duration. Jul 29, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 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. Won't fix We won't fix it.
Projects
None yet
Development

No branches or pull requests

2 participants