-
Notifications
You must be signed in to change notification settings - Fork 59
Watermark Script added #280
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
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
 | ||
- 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. | ||
 |
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
73
Python/Watermark_to_a_video_with _a_given_font/watermark.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am getting error for ffpyplayer installation. Can you please specify the version of this module you used