Skip to content

Commit fbdb224

Browse files
committed
新增音效转换工具 修改hz 比特率
1 parent 47bf228 commit fbdb224

File tree

6 files changed

+67
-1
lines changed

6 files changed

+67
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ Tools/AssetStudio/*
77
Tools/WinMerge/*
88
!/Tools/WinMerge/winmerge-2.16.2-x64-exe.zip
99
Tools/sqlitestudio-2.1.5/*
10-
!/Tools/sqlitestudio-2.1.5/sqlitestudio-2.1.5.exe.zip
10+
!/Tools/sqlitestudio-2.1.5/sqlitestudio-2.1.5.exe.zip
11+
Tools/ffmpeg/*
12+
!/Tools/ffmpeg/ffmpeg.zip

GameDevTools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from Tools import to_JPG
3232
from Tools import ImageResize
3333
from Tools import ImageScale
34+
from Tools import Audio_HZ_KBPS_Tools
3435

3536
toolSets=\
3637
{
@@ -123,6 +124,9 @@
123124

124125
# 图片缩放工具 指定比例
125126
ImageScale:[['imagerescale','png','jpg','resize'],u'图片缩放 指定比例'],
127+
128+
# 音效格式转换工具 设置hz 比特率
129+
Audio_HZ_KBPS_Tools:[['audio_hz_kbps_bits','mp3','ogg','wav'],u'音效格式转换工具 设置hz 比特率 '],
126130
}
127131

128132
toolSets_old=toolSets

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ toolSets=\
6060
# 更新日志
6161

6262
```
63+
2019/4/24 Audio_HZ_KBPS_Tools 音效格式转换工具 设置hz 比特率 ,关键词 ['audio_hz_kbps_bits','mp3','ogg','wav']
64+
6365
2019/4/24 ImageScale 图片缩放 指定比例,关键词 ['imagerescale','png','jpg','resize']
6466
6567
2019/4/24 ImageResize 图片缩放 指定尺寸,关键词 ['imageresize','png','jpg']

Tools/Audio_HZ_KBPS_Tools.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/python
2+
# -*- coding: UTF-8 -*-
3+
from Tools import Helper
4+
import io
5+
import os
6+
import zipfile
7+
8+
#使用python 库 求MD5
9+
def run():
10+
tmpZipFilePath=os.getcwd()+"/Tools/ffmpeg/ffmpeg.zip"
11+
tmpZipFilePath=tmpZipFilePath.replace('\\','/')
12+
# print(tmpZipFilePath)
13+
tmpTargetDirPath=os.path.splitext(tmpZipFilePath)[0]
14+
if os.path.isdir(tmpTargetDirPath)==False:
15+
# 先解压
16+
print(u"第一次打开,先解压\n")
17+
tmpZipFile=zipfile.ZipFile(tmpZipFilePath)
18+
print(tmpZipFile.namelist())
19+
20+
21+
tmpTargetDirPath=os.path.splitext(tmpZipFilePath)[0]
22+
os.mkdir(tmpTargetDirPath)
23+
24+
25+
for tmpOneName in tmpZipFile.namelist():
26+
tmpZipFile.extract(tmpOneName,tmpTargetDirPath)
27+
tmpZipFile.close()
28+
print(u"解压完成\n")
29+
30+
31+
print(u"输入音效文件地址:")
32+
tmpFilePath=str(raw_input())
33+
tmpFilePath=Helper.Remove_r_n(tmpFilePath)
34+
35+
print(u"输入Hz(默认44100):")
36+
tmpHZ=str(raw_input())
37+
tmpHZ=Helper.Remove_r_n(tmpHZ)
38+
if tmpHZ=="":
39+
tmpHZ="44100"
40+
41+
print(u"输入声道 数字(默认单声道 1):")
42+
tmpChannel=str(raw_input())
43+
tmpChannel=Helper.Remove_r_n(tmpChannel)
44+
if tmpChannel=="":
45+
tmpChannel="1"
46+
47+
print(u"输入比特率 数字(默认96kbps):")
48+
tmpBits=str(raw_input())
49+
tmpBits=Helper.Remove_r_n(tmpBits)
50+
if tmpBits=="":
51+
tmpBits="96k"
52+
53+
tmpStrParts=tmpFilePath.rpartition('.')
54+
tmpNewPath=tmpStrParts[0]+'_new'+tmpStrParts[1]+tmpStrParts[2]
55+
os.system(os.getcwd()+"/Tools/ffmpeg/ffmpeg/ffmpeg.exe -y -i "+tmpFilePath+" -ar "+tmpHZ+" -ac "+tmpChannel+" -ab "+tmpBits+"k "+tmpNewPath)
56+
57+
if __name__=="__main__":
58+
run()

Tools/Audio_HZ_KBPS_Tools.pyc

1.72 KB
Binary file not shown.

Tools/ffmpeg/ffmpeg.zip

9.99 MB
Binary file not shown.

0 commit comments

Comments
 (0)