How can I put text on video using opencv in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I put text on video using opencv in python?

How can I put text on video using opencv in python?

18th Sep 2018, 12:26 PM
ali.gh
ali.gh - avatar
9 Answers
+ 1
cv2.putText(frame,text,location,font,font size,font color, font weight, line)
19th Sep 2018, 9:11 PM
JME
0
Jason Edelson and how can I save it?
19th Sep 2018, 9:15 PM
ali.gh
ali.gh - avatar
0
cv2.VideoWriter(filename, fourcc, fps, frameSize) Example- out = cv2.VideoWriter('output.avi', -1, 20.0, (1920,1080)) out.write(frame) make sure you write the frame after editing it not before remember to release after your done writing out.release()
19th Sep 2018, 9:31 PM
JME
0
Jason Edelson thanks a lot😉 my last question is why my output video has no sound? how can I solve it?
19th Sep 2018, 9:47 PM
ali.gh
ali.gh - avatar
0
opencv doesn't support audio, you'll have to use a separate library like ffpyplayer from ffpyplayer.player import MediaPlayer player= MediaPlayer(video path) audioframe, val = player.get_frame()
19th Sep 2018, 9:55 PM
JME
0
Jason Edelson Do you know any library wich support video and audio and put text on that?
19th Sep 2018, 9:57 PM
ali.gh
ali.gh - avatar
0
Not that I know of, if you find one let me know
19th Sep 2018, 10:00 PM
JME
0
Jason Edelson ok yYou helped me a lot😉 Thanks😉☺
19th Sep 2018, 10:00 PM
ali.gh
ali.gh - avatar
0
Jason Edelson I find a way. converting text to image using PIL then put it on video using moviepy. it is too slow😔 Do you have an idea for speed up?
21st Sep 2018, 1:07 PM
ali.gh
ali.gh - avatar