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

Skip to content

Commit 0f47ea6

Browse files
committed
video_do.py
1 parent 02cfe19 commit 0f47ea6

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

pyfile/file_unique_hash.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def get_bytes_hash(src_file, Bytes=1024):
2929
return ret
3030

3131

32-
def water_mark(src_dir):
33-
video = mp.VideoFileClip(src_dir)
32+
def water_mark(src_file):
33+
video = mp.VideoFileClip(src_file)
3434

3535
logo = (mp.ImageClip("watermark.png")
3636
.set_duration(video.duration) # 时长
@@ -42,7 +42,7 @@ def water_mark(src_dir):
4242

4343
print("开始写入水印。。。")
4444
# mp4文件默认用libx264编码, 比特率单位bps
45-
result.write_videofile(re.sub(r'\.mp4$', "_mark.mp4", src_dir), codec="libx264", bitrate="10000000")
45+
result.write_videofile(re.sub(r'\.mp4$', "_mark.mp4", src_file), codec="libx264", bitrate="10000000")
4646
print("写入完成")
4747

4848

pyregex/txt_regx.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
print(text.group())
99

10-
print("###############################################")
10+
print("#######################findall########################")
1111

1212
listMatch = regex.findall(strText)
1313
print(listMatch)
1414

1515
for index, strMatch in enumerate(listMatch):
1616
print(str(index) + '--' + strMatch)
1717

18-
print("###############################################")
18+
print("######################match#########################")
1919

2020
m = re.match(r"(\w+)\s+(\w+)", "Isaac Newton, physicist")
2121
print(m.group())
@@ -27,15 +27,15 @@
2727
for strMatch in tGroup:
2828
print(strMatch)
2929

30-
print("###############################################")
30+
print("########################search#######################")
3131

3232
str1 = """# print(q) #<img src="/img.ivsky.com/im.jpg"
3333
alt="&#x65F6;&#x5C1A;&#x6444;&#x5F71;&#x56FE;&#x7247;"/> """
3434
regex1 = re.compile(r'/img.+jpg') # 匹配6个字符的单词
3535

3636
print(regex1.search(str1).group())
3737

38-
print("###############################################")
38+
print("######################replace#########################")
3939

4040
url = "https://mtl.gzhuibei.com/images/img/3273/1.jpg"
4141
finalU = re.sub(r'https.+img', "", url)

pyvideo/video_do.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import moviepy.editor as mp
66

77

8-
def water_mark(src_dir):
9-
video = mp.VideoFileClip(src_dir)
8+
def water_mark(src_file):
9+
video = mp.VideoFileClip(src_file)
1010

1111
logo = (mp.ImageClip("watermark.png")
1212
.set_duration(video.duration) # 时长
@@ -16,10 +16,18 @@ def water_mark(src_dir):
1616

1717
result = mp.CompositeVideoClip([video, logo])
1818

19-
print("开始写入水印。。。")
19+
print(getFileName(src_file) + "-->开始写入水印。。。")
2020
# mp4文件默认用libx264编码, 比特率单位bps
21-
result.write_videofile(re.sub(r'\.mp4$', "_mark.mp4", src_dir), codec="libx264", bitrate="10000000")
22-
print("写入完成")
21+
result.write_videofile(re.sub(r'\.mp4$', "_mark.mp4", src_file), codec="libx264", bitrate="10000000")
22+
print(getFileName(src_file) + "-->写入水印完成")
23+
24+
25+
def getFileName(src_file):
26+
return re.search(r'[^/]+$', src_file).group()
27+
28+
29+
def remove_water_mark(src_dir):
30+
pass
2331

2432

2533
def traverse_file(src_dir):

pyvideo/watermark.png

25.5 KB
Loading

0 commit comments

Comments
 (0)