Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfcb6e1

Browse files
committed
video_do.py
1 parent 0f47ea6 commit cfcb6e1

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

pyfile/file_unique_hash.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import datetime
22
import hashlib
33
import os
4-
import re
5-
6-
import moviepy.editor as mp
74

85

96
def get_file_hash(src_file):
@@ -29,23 +26,6 @@ def get_bytes_hash(src_file, Bytes=1024):
2926
return ret
3027

3128

32-
def water_mark(src_file):
33-
video = mp.VideoFileClip(src_file)
34-
35-
logo = (mp.ImageClip("watermark.png")
36-
.set_duration(video.duration) # 时长
37-
.resize(height=100) # 水印高度,等比缩放
38-
.margin(left=10, top=10, opacity=1) # 水印边距和透明度
39-
.set_pos(("left", "top"))) # 水印位置
40-
41-
result = mp.CompositeVideoClip([video, logo])
42-
43-
print("开始写入水印。。。")
44-
# mp4文件默认用libx264编码, 比特率单位bps
45-
result.write_videofile(re.sub(r'\.mp4$', "_mark.mp4", src_file), codec="libx264", bitrate="10000000")
46-
print("写入完成")
47-
48-
4929
def traverse_file(src_dir):
5030
start = datetime.datetime.now()
5131
file_num = 0
@@ -54,8 +34,6 @@ def traverse_file(src_dir):
5434
for file in files:
5535
file_num = file_num + 1
5636
src_file = os.path.join(root, file)
57-
if re.search(r'11\.mp4$', file) is not None:
58-
water_mark(src_file)
5937

6038
print(
6139
file + "-->file_hash-->" + get_file_hash(src_file) + "-->bytes_hash-->" + get_bytes_hash(src_file))

pyvideo/video_cv.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import cv2
2+
3+
vidcap = cv2.VideoCapture('005.avi')
4+
success, image = vidcap.read()
5+
count = 0
6+
success = True
7+
while success:
8+
success, image = vidcap.read()
9+
cv2.imwrite("frame%d.jpg" % count, image) # save frame as JPEG file
10+
if cv2.waitKey(10) == 27:
11+
break
12+
count += 1

0 commit comments

Comments
 (0)