gpt4 book ai didi

How to get keyframes of a video without using ffprobe?(如何在不使用ffbe的情况下获取视频的关键帧?)

转载 作者:bug小助手 更新时间:2023-10-25 17:26:39 24 4
gpt4 key购买 nike



I am trying to get the i-frames of a video using opencv.
I have read that the header of a keyframe should look like this: b'\x00\x00\x01\xb0', but the problem I am facing is that I can not seem to find the header of the frame if I just do something like this:

我正在尝试使用OpenCV获取视频的I帧。我读到关键帧的标题应该是这样的:B‘\x00\x00\x01\xb0’,但我面临的问题是,如果我只是这样做,似乎找不到帧的标题:


while True:
ret, frame = vid.read()
if ret == False:
break
print(bytes(frame))

I did not find anything that can locate keyframes only ffprobe and I am trying to find something else to use, if there is a library of something please let me know!

我没有找到任何可以定位关键帧的东西,我正在尝试找到其他的东西来使用,如果有什么东西的库,请让我知道!


Got back something that starts like this:

我得到了一些像这样开始的东西:


b'YK<YK<YK<YK<YK<YK<YK<YK<YK<YK<YK<YK<YK<YK<YK<YK<YL:YL:YM9YM9YM9YM9YM9YM9YM9YM9YM9YM9YM9YM9ZN:ZN:ZN:[O;[O;[O;[O;[O;[N<[N<[M>[M>[L?[L?[L?[L?[L?[L?YN>YN>VN;VN;UM:UM:TJ<TJ<TJ<TJ<SH?SH?SH?QF=QF=QF=PE:OD9ND6MC5LB4I?1E:1C8/B42B42@14?03?03?03@14?03<02<026,.4*,3)+0&(-#%,"$)\x1f!\'\x1d\x1f%\x1b\x1d#\x19\x1b"\x18\x1a#\x19\x1b!\x19\x1b$\x1c\x1e% \x1f&!  \x1e\x1a\x1d\x1b\x17\x1a\x18\x14\x16\x14\x10\x0f\r\t\x0b\t\x05\x07\x05\x01\x07\x05\x01\x06\x04\x00\x05\x03\x00\x04\x02\x00\x03\x01\x00\x03\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 ......

更多回答

Use pyav Module there is a mehtod you can use. pyav.org/docs/develop/api/…

使用PYAV模块有一种方法可以使用。Pyav.org/docs/Developer/api/…

"can not seem to find the header of the frame" -- you're definitely not going to find it in the already decoded pixel buffer that vid.read() returns.

“似乎找不到帧的头”--您肯定不会在vid.read()返回的已经解码的像素缓冲区中找到它。

优秀答案推荐

I Like pyav for more flexible things like U want.

我喜欢更灵活的东西,比如你想要的东西。


you got raw frame data because its already Decoded, so there are no nal unit Headers anymore.

你得到了原始的帧数据,因为它已经被解码了,所以不再有NAL单元头。


import av

container = av.open(path_to_video)

for frame in container.decode(video=0):
if frame.key_frame:
frame_bytes = bytes(frame)

更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com