Hi Livekit Community, Just a small question at my...
# server-api
m
Hi Livekit Community, Just a small question at my side. The timestamp_us value (https://docs.livekit.io/reference/python/v1/livekit/rtc/video_stream.html#livekit.rtc.video_stream.VideoFrameEvent.timestamp_us), how do I convert it to a normal ISO format? I first thought it would be a Unix epoch time, but that is clearly not the case. The value I got today: 847764003000 Any help is much appreciated! 🙏
r
Maybe whatever is streaming has a clock set to 1996? Your value
847764003000
represents 847,764,003,000 microseconds since Unix epoch. To convert this to ISO format in Python:
Copy code
import datetime  
  
timestamp_us = 847764003000  
# Convert microseconds to seconds  
timestamp_seconds = timestamp_us / 1_000_000  
# Create datetime object and format as ISO  
iso_time = datetime.datetime.fromtimestamp(timestamp_seconds, tz=datetime.timezone.utc).isoformat()
This would give you approximately
1996-11-28T15:00:03+00:00
for your example value.
m
I am streaming from my pc, which just has the current time. I also tried from my cellphone, which also has the current time...