Open RoyaltyLJW opened 9 months ago
What's more, memory leak happen in the code below due to opencv operation
def generator_mode(input_list):
input_path,threads = input_list
start = time.time()
graph = bmf.graph()
video = graph.decode({
'input_path': input_path,
"log_level":"quiet",
"dec_params": {"threads": threads},
})['video'].start() # this will return a packet generator
for pkt in video:
# convert frame to a nd array
if pkt.is_(bmf.VideoFrame):
vf = pkt.get(bmf.VideoFrame)
v_frame = vf.frame().plane(2).numpy()
a = cv2.blur(v_frame, (7, 7) ,borderType=cv2.BORDER_REFLECT_101).astype(np.float32)
else:
break
use = time.time() - start
return use
The memory leak is likely caused by uncontrolled output speed in asynchronous decoding, resulting in memory growth. You may consider using bmf.bmf_sync.process
as an alternative or switch to the graph mode to avoid this issue.
Thank you very much for the feedback. We will look into those issues in the coming days.
Hi, when I run the code below in a 4 CPU machine,Aborted (core dumped) happen. Error rate is 6/10. (Run 10 times and error occur 6 times). But in a 16 CPU machine, it doesn't happen. I observed that when executing on the 4cpu machine, the cpu usage is almost 100%. Maybe it is the reason. Apart from adding more CPU, is there any way to avoid this problem?
the environment version is below:
stdout of error:
Running command