File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # 檢查是否提供了至少兩個參數 (集數和至少一個輸入檔)
4+ if [ " $# " -lt 2 ]; then
5+ echo " 錯誤: 未提供足夠的參數。"
6+ echo " 用法: $0 <episode-number> <input-file-1> [input-file-2] ..."
7+ echo " 範例: $0 101 video1.mp4 video2.mkv"
8+ exit 1
9+ fi
10+
11+ # 第一個參數是集數
12+ episode_number=" $1 "
13+ # 移除第一個參數,剩下的就是檔案列表
14+ shift
15+
16+ # 初始化輸入檔案的索引
17+ input_index=1
18+
19+ # 遍歷所有剩餘的參數 (即輸入檔案列表)
20+ for input in " $@ " ; do
21+ # # 檢查輸入檔案是否存在
22+ # if [ ! -f "${input}" ]; then
23+ # echo "警告: 找不到檔案 '${input}',將跳過處理。"
24+ # continue # 跳到下一個檔案
25+ # fi
26+
27+ # 設定輸出的檔名
28+ output_filename=" ${episode_number} -${input_index} .mp3"
29+
30+ echo " ----------------------------------------"
31+ echo " 正在處理檔案 #${input_index} : ${input} "
32+ echo " 輸出至 -> ${output_filename} "
33+ echo " ----------------------------------------"
34+
35+ # 執行 ffmpeg 指令
36+ # -i "${input}" : 指定輸入檔案 (用引號括起來以支援包含空格的檔名)
37+ # -vn : 忽略影片軌,只處理音訊
38+ # "${output_filename}" : 指定輸出檔名
39+ ffmpeg -i " ${input} " -vn " ${output_filename} "
40+
41+ # 索引加一,為下一個檔案做準備
42+ (( input_index++ ))
43+ done
44+
45+ echo " 所有檔案處理完畢。"
You can’t perform that action at this time.
0 commit comments