Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aeea204

Browse files
Merge pull request avinashkranjan#75 from bislara/video_watermark
Video watermarker
2 parents 25b1fbd + 8e6280f commit aeea204

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed

‎Video_Watermark/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
venv/

‎Video_Watermark/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Video Watermaker
2+
### Made by [Biswajeet Sahoo](https://github.com/bislara)
3+
This script can add watermark to a video with the given font.
4+
5+
## How to run
6+
* Install the dependencies from requirements.txt
7+
8+
`pip install -r requirements.txt`
9+
* Run the python file now
10+
11+
`python watermark.py`
12+
13+
Ouput is saved in the videos folder
14+
15+
## Modules used
16+
* opencv-python
17+
18+
## Screenshot
19+
![image](https://user-images.githubusercontent.com/35392585/95066130-9cbdd800-071f-11eb-81eb-5e83dfbe7e25.png)
20+
21+

‎Video_Watermark/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy==1.19.2
2+
opencv-python==4.4.0.44

‎Video_Watermark/videos/input.mp4

2.99 MB
Binary file not shown.

‎Video_Watermark/videos/output.avi

5.89 MB
Binary file not shown.

‎Video_Watermark/watermark.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from cv2 import cv2
2+
3+
# take the input video
4+
cap = cv2.VideoCapture('videos/input.mp4')
5+
6+
# We need to set resolutions.
7+
# so, convert them from float to integer.
8+
frame_width = int(cap.get(3))
9+
frame_height = int(cap.get(4))
10+
11+
size = (frame_width, frame_height)
12+
13+
# get the frame rate of the input video
14+
fps = cap.get(cv2.CAP_PROP_FPS)
15+
print("Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps))
16+
17+
# Below VideoWriter object will create
18+
# a frame of above defined The output
19+
# is stored in 'videos/output' file.
20+
result = cv2.VideoWriter('videos/output.avi', cv2.VideoWriter_fourcc(*'MJPG'), fps, size)
21+
22+
print("processing started...")
23+
24+
# continue till the video is not over...
25+
while(cap.isOpened()):
26+
27+
# Capture frame-by-frame from the video
28+
ret, frame = cap.read()
29+
if ret == True:
30+
31+
# describe the type of font to be used.
32+
font = cv2.FONT_HERSHEY_SIMPLEX
33+
34+
# Use putText() method for inserting text on video
35+
# Parameters:-
36+
# frame: current running frame of the video.
37+
# Text: The text string to be inserted.
38+
# org: bottom-left corner of the text string
39+
# font: the type of font to be used.
40+
# color: the colour of the font.
41+
# thickness: the thickness of the font
42+
43+
cv2.putText(frame, 'HELLO WORLD', (50, 50), font, 1, (0, 255, 255), 2, cv2.LINE_4)
44+
# write in the output file
45+
result.write(frame)
46+
47+
# Display the resulting frame
48+
cv2.imshow('video', frame)
49+
50+
# creating 'q' as the quit button for the video
51+
if cv2.waitKey(1) & 0xFF == ord('q'):
52+
break
53+
else:
54+
break
55+
56+
57+
# release the cap object
58+
cap.release()
59+
result.release()
60+
61+
# close all windows
62+
cv2.destroyAllWindows()
63+
64+
print("Video successfully saved inside the videos folder")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /