【问题标题】:Reading RTCP packets from an IP camera using FFMPEG使用 FFMPEG 从 IP 摄像机读取 RTCP 数据包
【发布时间】:2013-12-14 10:58:12
【问题描述】:

我正在使用 ffmpeg C 库。我需要拦截来自摄像头的 RTCP 数据包,以便从发件人报告中获取时间戳。 ffmpeg 中是否有任何方法或结构可以为我提供此信息?我完全被卡住了,但我无法解决这个问题。

任何帮助将不胜感激。提前致谢,

【问题讨论】:

    标签: c ffmpeg rtsp rtp


    【解决方案1】:

    我在ffmpeg(3.4.6版)上做了一些实验。

    AVFormatContext* ifmt_ctx = avformat_alloc_context();
    AVStream * st = xx; // select stream
    double timebase = av_q2d(st->time_base);
    streamStartTime  = ifmt_ctx->start_time_realtime; // this is ntp time , i.e. stream build time 
    

    然后,在ntp时间上加上相对时间,就可以得到每一帧的绝对时间

    streamStartTime + (1000000 * pkt->pts * time_base) // AVPacket * pkt
    

    【讨论】:

      【解决方案2】:

      最后我不得不像这样侵入 ffmpeg 库:

      // Patch for retrieving inner ffmpeg private data
      RTSPState* rtsp_state = (RTSPState*) context->priv_data;
      RTSPStream* rtsp_stream = rtsp_state->rtsp_streams[0];
      RTPDemuxContext* rtp_demux_context = (RTPDemuxContext*) rtsp_stream->transport_priv;
      
      // Decode the NTP time from the 64 bit structure
      uint64_t ntp_time = rtp_demux_context->last_rtcp_reception_time;
      uint32_t seconds = (uint32_t) ((ntp_time >> 32) & 0xffffffff);
      uint32_t fraction  = (uint32_t) (ntp_time & 0xffffffff);
      double useconds = ((double) fraction / 0xffffffff);
      

      我终于得到了时间戳信息。

      【讨论】:

      • 您为此修补了哪个文件?你介意分享补丁吗?提前致谢。
      • 嗨阿伦。这是很久以前的事了。我花了很多钱来解决这个问题。很多黑客,但它的工作。祝你好运!
      • 我希望它被库本身作为 API 公开。不过,谢谢。
      猜你喜欢
      • 2018-01-23
      • 1970-01-01
      • 2014-05-04
      • 1970-01-01
      • 2016-03-14
      • 2016-12-17
      • 2011-07-28
      • 2011-12-06
      • 1970-01-01
      相关资源
      最近更新 更多