from imageio_ffmpeg import read_frames, write_frames
import cv2
input_file = 'http://195.196.36.242/mjpg/video.mjpg'
output_file = 'rtsp.mp4'
reader = read_frames(input_file)
meta = reader.__next__()
writer = write_frames(output_file,
size = meta['size'], fps = meta['fps'],
input_params = ['-y', ],
output_params = ['-vf', 'scale = 720 : -2', ] )
writer.send(None)
i = 0
text = 'stifix'
font = cv2.FONT_HERSHEY_SIMPLEX
org = (00, 185)
fontScale = 1
color = (0, 0, 128)
thickness = 2
for frame in reader:
img = np.frombuffer(frame, np.uint8).reshape(meta['size'][1],
meta['size'][0], -1)
#put_text = cv2.putText(img, text, org, font, fontScale, color, thickness, cv2.LINE_AA, False) # not work
put_text = np.ascontiguousarray(cv2.putText(img, text, org, font, fontScale, color, thickness, cv2.LINE_AA, False) ) # not work
writer.send(put_text)
if i == 9: # 100 = 6 secs
break
i += 1
writer.close()
objective
write text to video, e.g. using cv2.putText
code
result
no error occured
but output video have no text written
expected result
video output have text written
best regards