CAFECA-IO / KnowledgeManagement

Creating, Sharing, Using and Managing the knowledge and information of CAFECA
https://mermer.com.tw/knowledge-management
MIT License
0 stars 1 forks source link

(小範圍實驗) 任務 5: 音頻提取 #174

Closed TzuHanLiang closed 3 months ago

TzuHanLiang commented 3 months ago

實作目標:

將影片轉換為音頻文件。

方法:

使用 ffmpeg 或其他轉換工具將下載的影片轉換為音頻文件。 確認音頻文件質量良好,適合後續的逐字稿生成。

驗證:

確認可以成功生成音頻文件並播放音頻文件以檢查質量。

TzuHanLiang commented 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')
TzuHanLiang commented 3 months ago

took 3hrs done