如何将秒和毫秒转换为 python 中的纪元?将它们添加到另一个纪元时间戳是否正确?

How to convert seconds and miliseconds to epoch in python? Is it correct to add them to another epoch timestamp?

我有这个字符串:

"00:00:45.0010796"

这是视频中的时间(以秒为单位)。首先,如何将其转换为 python 中的纪元字符串?其次,假设我有这个字符串

"1512992049819"

这是视频开始的时间(但它也有年、月和日期信息)。在我将第一个字符串转换为纪元之后,如果我将它添加到第二个字符串(就像我添加任意两个数字一样),生成的纪元时间戳是否正确?

使用sub-strings即可轻松解决。

s1 = "00:00:45.0010796"
s2 = "1512992049819"

video_length = (int(s1[:2])*60*60 + int(s1[3:5])*60 + float(s1[6:]))*1000

print(int(s2)+video_length)