How to convert timestamp in human readable form.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to convert timestamp in human readable form.

Shubham Shrivastava
timestamp: 178452710056
stream_time: 178452710056
running_time: 178452710056
offset: 18446744073709551615
offset_end: 18446744073709551615



this type of output i got from

      gst_structure_get_clock_time (s,"timestamp",&timestamp);
        g_print("timestamp: %llu \n", timestamp);
         // g_print ("timestamp------------ %s",&timestamp);
        gst_structure_get_clock_time (s,"stream-time",&stream_time);
        g_print("stream_time: %llu \n", stream_time);
        gst_structure_get_clock_time (s,"running-time",&running_time);
        g_print("running_time: %llu \n", running_time);
        gst_structure_get_uint64(s, "offset", &offset);
        g_print("offset: %llu \n", offset);
        gst_structure_get_uint64(s, "offset-end", &offset_end);
        g_print("offset_end: %llu \n", offset_end);


So to convert  it to human readable form when i did it like this

    strptime("178452710056", "%s", &tm);
    strftime(buf, sizeof(buf), "%d %h %H:%M %Y", &tm);

It shows wrong date and time.

Plz suggest.


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to convert timestamp in human readable form.

Antonio Ospite-2
On Sat, 7 Jul 2018 11:50:57 +0530
Shubham Shrivastava <[hidden email]> wrote:

> timestamp: 178452710056
[...]
>
> this type of output i got from
>
>       gst_structure_get_clock_time (s,"timestamp",&timestamp);
[...]
>    strptime("178452710056", "%s", &tm);

Two issues here:

1. the returned timestamp is relative to the structure field lifetime,
   it does not refer to the system time.
2. GstClockTime expresses time in nanoseconds, not seconds.

Try using
https://developer.gnome.org/glib/stable/glib-Date-and-Time-Functions.html#g-get-real-time
and take care to convert units (g_get_real_time returns microseconds).

Ciao,
   Antonio

--
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to convert timestamp in human readable form.

Matteo Valdina
Hi,
Give a look to the GST_TIME_FORMAT.


This is a simple way to print a GstClockTime to something readable. 

Best
Matteo

On Sat, Jul 7, 2018, 04:32 Antonio Ospite <[hidden email]> wrote:
On Sat, 7 Jul 2018 11:50:57 +0530
Shubham Shrivastava <[hidden email]> wrote:

> timestamp: 178452710056
[...]
>
> this type of output i got from
>
>       gst_structure_get_clock_time (s,"timestamp",&timestamp);
[...]
>    strptime("178452710056", "%s", &tm);

Two issues here:

1. the returned timestamp is relative to the structure field lifetime,
   it does not refer to the system time.
2. GstClockTime expresses time in nanoseconds, not seconds.

Try using
https://developer.gnome.org/glib/stable/glib-Date-and-Time-Functions.html#g-get-real-time
and take care to convert units (g_get_real_time returns microseconds).

Ciao,
   Antonio

--
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel