2

I'm trying to get a frame by rtsp and calculate its real-world timestamp. I previously used Live555 for this (presentationTime).

As far as I understand, ffmpeg does not provide such functionality, but provides the ability to read the relative time of each frame and the start time of the stream. In my case, the frame timestamps (pts) works correctly, but the stream start time (start_time_realtime) is always -9223372036854775808.

I'm trying to use simple example from this Q: https://stackoverflow.com/a/11054652/5355846

Value does not change. regardless of the position in the code

int main(int argc, char** argv) {
    // Open the initial context variables that are needed
    SwsContext *img_convert_ctx;
    AVFormatContext* format_ctx = avformat_alloc_context();
    AVCodecContext* codec_ctx = NULL;
    int video_stream_index;

    // Register everything
    av_register_all();
    avformat_network_init();

    //open RTSP
    if (avformat_open_input(&format_ctx, "path_to_rtsp_stream",
                            NULL, NULL) != 0) {
        return EXIT_FAILURE;
    }
    ...
}
while (av_read_frame(format_ctx, &packet) >= 0 && cnt < 1000) { //read ~ 1000 frames

        //// here!
        std::cout<< " ***** "
        << std::to_string(format_ctx->start_time_realtime) 
        << " | "<<format_ctx->start_time
        << " | "<<packet.pts 
        << " | "
        <<picture->best_effort_timestamp;

...
}

***** -9223372036854775808 | 0 | 4120 | 40801 Frame: 103

What am I doing wrong?

genpfault
  • 51,148
  • 11
  • 85
  • 139
chuchuchu
  • 21
  • 1

1 Answers1

0

-9223372036854775808 is AV_NOPTS_VALUE, meaning start_time_realtime is unknown to ffmpeg.

szatmary
  • 29,969
  • 8
  • 44
  • 57
  • thanks for the answer! I understand that. question: why? Source does not set this value? Or am I trying to get it wrong? – chuchuchu Jul 24 '19 at 06:01
  • Because that value was int included in the source stream. There was nothing to set it from. – szatmary Jul 24 '19 at 14:06