添加ffmpeg

This commit is contained in:
shuaikangzhou 2023-12-13 20:45:53 +08:00
parent 48830a648c
commit e9d7b1b7c9
5 changed files with 34 additions and 14 deletions

View File

@ -55,17 +55,20 @@ class MediaMsg:
silk_path = f"{output_path}\\{reserved0}.silk"
pcm_path = f"{output_path}\\{reserved0}.pcm"
mp3_path = f"{output_path}\\{reserved0}.mp3"
slik_path = silk_path.replace("/", "\\")
silk_path = silk_path.replace("/", "\\")
pcm_path = pcm_path.replace("/", "\\")
mp3_path = mp3_path.replace("/", "\\")
print(mp3_path)
if os.path.exists(mp3_path):
return mp3_path
open(silk_path, "wb").write(buf)
with open(silk_path, "wb") as f:
f.write(buf)
# open(silk_path, "wb").write()
decode(silk_path, pcm_path, 44100)
system(f'ffmpeg.exe -loglevel quiet -y -f s16le -i "{pcm_path}" -ar 44100 -ac 1 "{mp3_path}"')
system(f'del "{silk_path}"')
system(f'del "{pcm_path}"')
cmd = f'''{os.path.join(os.getcwd(),'app','resources','ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
system(cmd)
system(f'del {silk_path}')
system(f'del {pcm_path}')
print(mp3_path)
return mp3_path
def get_audio_text(self, content):

View File

@ -203,10 +203,16 @@ class Msg:
for dialog in temp:
msg1 = dialog[0]
msg2 = dialog[1]
res.append((
(msg1[4], msg1[5], msg1[7].split(keyword), msg1[8]),
(msg2[4], msg2[5], msg2[7], msg2[8])
))
try:
res.append((
(msg1[4], msg1[5], msg1[7].split(keyword), msg1[8]),
(msg2[4], msg2[5], msg2[7], msg2[8])
))
except TypeError:
res.append((
('', '', ['', ''], ''),
('', '', '', '')
))
return res
def get_messages_by_days(self, username_, is_Annual_report_=False, year_='2023'):

View File

@ -313,9 +313,20 @@ class ChildThread(QThread):
)
elif self.output_type==Output.TXT:
name = '' if is_send else self.contact.remark
doc.write(
f'''{str_time} {name}\n{content.get('title')}\n引用:{refer_msg.get('displayname')}:{refer_msg.get('content')}\n\n'''
)
if refer_msg:
referText = f"{refer_msg.get('displayname')}{refer_msg.get('content')}"
emojiText = findall(r"(\[.+?\])", referText)
for emoji_text in emojiText:
if emoji_text in emoji:
referText = referText.replace(emoji_text, emoji[emoji_text])
doc.write(
f'''{str_time} {name}\n{content.get('title')}\n引用:{refer_msg.get('displayname')}:{refer_msg.get('content')}\n\n'''
)
else:
doc.write(
f'''{str_time} {name}\n{content.get('title')}\n引用:未知\n\n'''
)
def system_msg(self, doc, message):
str_content = message[7]

BIN
app/resources/ffmpeg.exe Normal file

Binary file not shown.

View File

@ -16,4 +16,4 @@ google==3.0.0
protobuf==4.25.1
soupsieve==2.5
lz4==4.3.2
pilk
pilk==0.2.4