繁体   English   中英

ffmpeg RTSP over TCP,RTP 时间戳始终为零

[英]ffmpeg RTSP over TCP, RTP timestamps are always zero

我正在尝试从 RTP 数据包中获取时间戳。 当我使用 Wireshark 扫描数据包时,我得到以下输出: rtp_packet我看到时间戳在几个数据包之后增加了。 我遇到的问题如下:当我从 C 中的 RTPDemuxContext->timestamp (rtp_demux_context->timestamp) 读取时间戳值时,对于多个摄像机,该值始终为零,但对于大多数摄像机,代码运行良好。 您能帮助找出相机中的错误或 ffmpeg 中的错误吗?

有我的代码:

double ntp_timestamp(AVFormatContext* pFormatCtx, uint32_t* last_rtcp_ts, double* base_time) {
RTSPState* rtsp_state = (RTSPState*) pFormatCtx->priv_data;
RTSPStream* rtsp_stream = rtsp_state->rtsp_streams[0];
RTPDemuxContext* rtp_demux_context = (RTPDemuxContext*) rtsp_stream->transport_priv;

uint32_t new_rtcp_ts = rtp_demux_context->last_rtcp_timestamp;

uint64_t last_ntp_time = 0;

if (new_rtcp_ts != *last_rtcp_ts) {
    *last_rtcp_ts = new_rtcp_ts;
    last_ntp_time = rtp_demux_context->last_rtcp_ntp_time;
    uint32_t seconds = ((last_ntp_time >> 32) & 0xffffffff) - 2208988800;
    uint32_t fraction  = (last_ntp_time & 0xffffffff);
    double useconds = ((double) fraction / 0xffffffff);
    *base_time = seconds + useconds;
}
uint32_t d_ts = rtp_demux_context->timestamp - *last_rtcp_ts;
return *base_time + d_ts / 90000.0;

}

可能是因为您从RTP时间戳seconds减去了2208988800吗? 我怀疑这可能是原因。 我处于类似情况,但发现打开相机电源后时间戳开始增加。

可能是 rtsp 服务器不发送任何 rtcp 发件人报告。 您可以通过wireshake检查服务器是否发送rtcp发件人报告。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM