Closed TzuHanLiang closed 3 months ago
import subprocess
def convert_video_to_audio(video_path, audio_path):
command = [
'ffmpeg',
'-i', video_path, # 输入文件
'-q:a', '0', # 音质设置为最好
'-map', 'a', # 仅提取音频
audio_path # 输出音频文件路径
]
try:
subprocess.run(command, check=True)
print("音频提取成功,保存为:{}".format(audio_path))
except subprocess.CalledProcessError as e:
print("错误:音频提取失败", e)
# 调用函数
convert_video_to_audio('downloaded_full_video.mp4', 'output_audio.wav')
took 3hrs done
實作目標:
將影片轉換為音頻文件。
方法:
使用 ffmpeg 或其他轉換工具將下載的影片轉換為音頻文件。 確認音頻文件質量良好,適合後續的逐字稿生成。
驗證:
確認可以成功生成音頻文件並播放音頻文件以檢查質量。