Skip to content

watermark updated #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Python/Watermark_to_a_video_with _a_given_font/README.md
Original file line number Diff line number Diff line change
@@ -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)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions Python/Watermark_to_a_video_with _a_given_font/watermark.py
Original file line number Diff line number Diff line change
@@ -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()