diff --git a/Python/Watermark_to_a_video_with _a_given_font/README.md b/Python/Watermark_to_a_video_with _a_given_font/README.md new file mode 100644 index 00000000..3a635e0c --- /dev/null +++ b/Python/Watermark_to_a_video_with _a_given_font/README.md @@ -0,0 +1,16 @@ +## watermark a video with a given font +- This script built in Python, using this python script you can watermark a video. +- The OpenCV and Numpy Libraries are used to built this scripts. +## Requirements +- install OpenCv (use command:- "pip install opencv-python" to install OpenCv through Command Prompt) +- install ffpyplayer (use command:- "pip install ffpyplayer" to install ffpyplayer through Command Prompt) +## Working +![Image](images/input.png) +- The user enters : + - write the Path of the video with proper video extension and press Enter. + - enter the text that you want to mark on the video, press Enter. + - give two space seprated coordinate value(location where you want to mark the text). + - give 3 space seprated value for text colour(RGB, Ex- 155 168 158) press Enter. + - Select the font-type from the given list. +- The script runs and the text is mark on the video. +![Image](images/video.png) \ No newline at end of file diff --git a/Python/Watermark_to_a_video_with _a_given_font/images/input.png b/Python/Watermark_to_a_video_with _a_given_font/images/input.png new file mode 100644 index 00000000..c7e6abf1 Binary files /dev/null and b/Python/Watermark_to_a_video_with _a_given_font/images/input.png differ diff --git a/Python/Watermark_to_a_video_with _a_given_font/images/video.png b/Python/Watermark_to_a_video_with _a_given_font/images/video.png new file mode 100644 index 00000000..cb370c27 Binary files /dev/null and b/Python/Watermark_to_a_video_with _a_given_font/images/video.png differ diff --git a/Python/Watermark_to_a_video_with _a_given_font/watermark.py b/Python/Watermark_to_a_video_with _a_given_font/watermark.py new file mode 100644 index 00000000..2f897060 --- /dev/null +++ b/Python/Watermark_to_a_video_with _a_given_font/watermark.py @@ -0,0 +1,73 @@ +import numpy as np +import cv2 +from ffpyplayer.player import MediaPlayer +0 +# PATH of the video +print('Enter the Path of the video') +path=input() + +# text +print('Enter the Text') +text=input() + +# org +print('Enter the coordinates of text') +location = tuple(map(int,input().split())) + +# Blue color in BGR +print('Enter the color(Ex- 155 168 158)') +color = tuple(map(int,input().split())) + +# cv2-fonts +Hershey_Simplex = cv2.FONT_HERSHEY_SIMPLEX +Hershey_Plain = cv2.FONT_HERSHEY_PLAIN +Hershey_Duplex = cv2.FONT_HERSHEY_DUPLEX +Hershey_Complex = cv2.FONT_HERSHEY_COMPLEX +Hershey_Triplex = cv2.FONT_HERSHEY_TRIPLEX +Hershey_Complex_Small = cv2.FONT_HERSHEY_COMPLEX_SMALL +Hershey_Script_Simplex = cv2.FONT_HERSHEY_SCRIPT_SIMPLEX +Hershey_Script_Complex = cv2.FONT_HERSHEY_SCRIPT_COMPLEX +font_list_index=[['0','Hershey_Simplex'],['1','Hershey_Plain'],['2','Hershey_Duplex'],['3','Hershey_Complex'],['4','Hershey_Triplex'],['5','Hershey_Complex_Small'],['6','Hershey_Script_Simplex'],['7','Hershey_Script_Complex']] +font_list=[Hershey_Simplex,Hershey_Plain,Hershey_Duplex,Hershey_Complex,Hershey_Triplex,Hershey_Complex_Small,Hershey_Script_Simplex,Hershey_Script_Complex] + +print('choose the font') +print('Id',' ','item') +for item in font_list_index: + print(item[0],' ',str(item[1])) + +Id = int(input()) +font = font_list[Id-1] + +# fontScale +fontScale = 1 + +# Window name in which image is displayed +window_name = 'video' + +# Line thickness of 2 px +thickness = 2 + +video = cv2.VideoCapture(path) +player = MediaPlayer(path) + +while(True): + ret, frame = video.read() + audio_frame, val = player.get_frame() + if ret==True: + # Using cv2.putText() method + image = cv2.putText(frame, text, location, font, fontScale, color, thickness, cv2.LINE_AA) + + # Displaying the image + cv2.imshow(window_name, image) + + if val != 'eof' and audio_frame is not None: + #audio + img, t = audio_frame + + if cv2.waitKey(28) & 0xFF == ord('q'): + break + + +# Release everything if job is finished +cap.release() +cv2.destroyAllWindows()