Change time zone in deepstream-test5 application

when i have enabled the show-clock in osd config. I am able to see the time in mp4 saved videos but it is in UTC, but i need to add 3 hours to it match it with different timezone. could you please tell me the file where i can make this change and how to do it?

Currently the nvdsosd element uses localtime() to display the clock.

If you wish to display a different time zone, consider disabling display-clock and then using display-text to display the specified time as text.

but text is a constant value, how much can i increment the time with frames ?

Like the function osd_sink_pad_buffer_probe in deepstream_test1_app.c, You can add time as text at every frame

As you have mentioned, it shows local time but for me it displays utc.

You misunderstood what I meant.

Use the following code to get the time in the specified time zone then convert text.

And use the text display feature of nvdsosd element.

std::string get_time_in_timezone(const std::string& timezone) {
    setenv("TZ", timezone.c_str(), 1);
    tzset();

    auto now = std::chrono::system_clock::now();
    std::time_t now_c = std::chrono::system_clock::to_time_t(now);

    std::tm* local_tm = std::localtime(&now_c);

    std::ostringstream oss;
    oss << std::put_time(local_tm, "%Y-%m-%d %H:%M:%S %Z");
    return oss.str();
}
  display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
  NvOSD_TextParams *txt_params  = &display_meta->text_params[0];
  display_meta->num_labels = 1;
  txt_params->display_text = g_malloc0 (MAX_DISPLAY_LEN);
  snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "%s", get_time_in_timezone("America/New_York").c_str());

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.