简体   繁体   English

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

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

I'm trying to get timestamps from RTP packet.我正在尝试从 RTP 数据包中获取时间戳。 When I scan packets with Wireshark I get following output: rtp_packet I see that timestamps have incremented after several packets.当我使用 Wireshark 扫描数据包时,我得到以下输出: rtp_packet我看到时间戳在几个数据包之后增加了。 Issue that I have as following: when I read timestamp value from RTPDemuxContext->timestamp (rtp_demux_context->timestamp) in C, the value is always zero for several cameras, but for the majority of cameras the code works well.我遇到的问题如下:当我从 C 中的 RTPDemuxContext->timestamp (rtp_demux_context->timestamp) 读取时间戳值时,对于多个摄像机,该值始终为零,但对于大多数摄像机,代码运行良好。 Can you help to figure out is there are bug in cameras or bug in ffmpeg?您能帮助找出相机中的错误或 ffmpeg 中的错误吗?

There is my code:有我的代码:

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;

} }

could it be because you subtracted 2208988800 from the RTP timestamp seconds ? 可能是因为您从RTP时间戳seconds减去了2208988800吗? I suspect this may be the cause. 我怀疑这可能是原因。 I was in a similar situation but found out that the timestamp starts incrementing after the camera is turned on. 我处于类似情况,但发现打开相机电源后时间戳开始增加。

May be the rtsp server don't send any rtcp sender report.可能是 rtsp 服务器不发送任何 rtcp 发件人报告。 you can check if server send rtcp sender report by wireshake.您可以通过wireshake检查服务器是否发送rtcp发件人报告。

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

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