问题描述
如果有人可以帮助我使用 FFmpeg 管道从 NumPy 数组生成 h264 块,是否有可能
这就是我现在正在做的:
过程 = ( ffmpeg .input('pipe:',format='rawvideo',pix_fmt='bgr24',s='{}x{}'.format(self._deeptwin.image_width,self._deeptwin.image_height)) .output(path,pix_fmt='yuv420p',vcodec='libx264',r=25) .overwrite_output() .run_async(pipe_stdin=True) )
for res in response:
st = datetime.datetime.Now()
print(f'{res.status} image {res.id} rendered at {datetime.datetime.Now()}')
img = np.frombuffer(res.image,dtype=np.uint8)
img = img.reshape((int(self._deeptwin.image_height * 1.5),self._deeptwin.image_width))
img = cv2.cvtColor(img,cv2.COLOR_YUV2BGR_I420)
for frame in img:
start = datetime.datetime.Now()
process.stdin.write(
frame
.astype(np.uint8)
.tobytes()
)
end = datetime.datetime.Now()
stop = datetime.datetime.Now()
print(f'{res.id} conversion done at {stop-st}')
process.stdin.close()
process.wait()
` 目前正在做的是生成一个 out.h264 文件。没问题,也能播放正确的视频。
但是,我需要实现的是:我想以下列方式生成h264帧块:1.h264,2.h264............n.h264
任何指导都会非常感谢和帮助。
提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)