gstreamer至Kinesis Video Stream速率限制

时间:2019-04-22 19:29:26

标签: video-streaming amazon-kinesis gstreamer-1.0

我正在尝试将mkv文件(请参阅下面的属性)发送到Kinesis Video Stream。我想要每秒10-15帧的FPS。

> ffprobe testvideo02.mkv
...
Input #0, matroska,webm, from 'testvideo02.mkv':
  Metadata:
    ENCODER         : Lavf57.56.101
  Duration: 02:37:57.02, start: -0.007000, bitrate: 457 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(progressive), 488x360 [SAR 1:1 DAR 61:45], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Metadata:
      HANDLER_NAME    : VideoHandler
      DURATION        : 02:37:57.000000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 02:37:57.021000000

要将流推送到KVS,我使用amazon-kinesis-video-streams-producer-sdk-cpp中的GStreamer命令行。我使用了不同的键,这是我最终拥有的,并且不起作用:

gst-launch-1.0 filesrc location=testvideo02.mkv do-timestamp=TRUE \
    ! matroskademux ! decodebin \
    ! videorate drop-only=true ! video/x-raw,framerate=15/1,max-rate=15/1 \
    ! videoconvert \
    ! x264enc bframes=0 key-int-max=45 bitrate=2048 \
    ! video/x-h264,framerate=15/1 \
    ! kvssink stream-name=$STREAM_NAME framerate=15 \
    access-key=$AWS_ACCESS_KEY secret-key=$AWS_SECRET_KEY


[DEBUG][2019-04-22 19:22:44] Kinesis Video client and stream metrics
        >> Overall storage byte size: 134217728
        >> Available storage byte size: 133001418
        >> Allocated storage byte size: 1216310
        >> Total view allocation byte size: 86472
        >> Total streams frame rate (fps): 163
        >> Total streams transfer rate (bps): 25683152 (25081 Kbps)
        >> Current view duration (ms): 720
        >> Overall view duration (ms): 6000
        >> Current view byte size: 187371
        >> Overall view byte size: 1211851
        >> Current frame rate (fps): 163.493
        >> Current transfer rate (bps): 25683152 (25081 Kbps)
[DEBUG][2019-04-22 19:22:44] Curl post body write function for stream: bc-test1 and upload handle: 0 returned: {"EventType":"PERSISTED","FragmentTimecode":21600,"FragmentNumber":"91343852333182571337132286426569376608263492193"}

在另一台服务器的客户端(KVS使用者)上,我的FPS超过80。

问题:我如何获得15的FPS?

最糟糕的问题是:在用户端每1-1.5秒,我在数据接收中大约有1秒的“冻结”时间。之后,它会接收到该时间的全部数据并继续进行处理。无法理解根本原因。一些缓冲区?

1 个答案:

答案 0 :(得分:1)

如果您想像实时源一样流式传输文件,则可以在管道中添加“ identity sync = TRUE”元素。这意味着您将需要等待15分钟才能流式传输15分钟的文件。上载文件的最佳方法是在离线模式下配置kvssink插件,例如:

gst-launch-1.0 filesrc location=testvideo02.mkv do-timestamp=TRUE \
! matroskademux ! decodebin \
! videoconvert \
! x264enc bframes=0 key-int-max=45 bitrate=2048 \
! kvssink stream-name=$STREAM_NAME streaming-type=offline \
access-key=$AWS_ACCESS_KEY secret-key=$AWS_SECRET_KEY

看到高fps的原因是因为没有标识sync = TRUE元素,管道以全cpu速度运行,将帧倾倒到插件中。