如何从pts和time_base或duration中获取视频或rtmp流中帧的时间戳?非常感谢!
import av
def init_input(file_name):
global a
container = av.open(file_name)
a = container.duration
return container.decode(video=0)
url = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
stream1 = init_input(url)
for frame1 in stream1:
print(frame1.pts)
print(frame1.time_base)PS: frame.time与实际时间不正确
发布于 2018-09-06 07:40:13
在写这篇文章的时候,这个bug是GitHub上的just fixed。
如果您需要与当前发布的PyAV (即在PyPI上)配合使用,则可以在视频Stream上使用time_base
import av
url = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"
container = av.open(url, options={'rtsp_transport': 'tcp'})
stream = container.streams.video[0]
for frame in container.decode(stream):
print(float(frame.pts * stream.time_base))https://stackoverflow.com/questions/52164286
复制相似问题