|
@@ -642,4 +642,39 @@ function ffmpeg_extract_audio() {
|
|
|
|
|
|
# 提取音频 ffmpeg -i input.mp4 -vn -acodec libmp3lame -q:a 0 output.mp3
|
|
# 提取音频 ffmpeg -i input.mp4 -vn -acodec libmp3lame -q:a 0 output.mp3
|
|
ffmpeg -i "$1" -vn -acodec libmp3lame -q:a 0 "$output_file"
|
|
ffmpeg -i "$1" -vn -acodec libmp3lame -q:a 0 "$output_file"
|
|
|
|
+}
|
|
|
|
+# 合并视频和音频
|
|
|
|
+ffmpeg_merge_video_audio() {
|
|
|
|
+ # 检查参数数量是否正确
|
|
|
|
+ if [ "$#" -ne 3 ]; then
|
|
|
|
+ echo "用法: merge_video_audio <视频文件> <音频文件> <输出文件>"
|
|
|
|
+ return 1
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ # 获取参数
|
|
|
|
+ video_path="$1"
|
|
|
|
+ audio_path="$2"
|
|
|
|
+ output_path="$3"
|
|
|
|
+
|
|
|
|
+ # 检查输入文件是否存在
|
|
|
|
+ if [ ! -f "$video_path" ]; then
|
|
|
|
+ echo "错误: 视频文件 '$video_path' 不存在"
|
|
|
|
+ return 1
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ if [ ! -f "$audio_path" ]; then
|
|
|
|
+ echo "错误: 音频文件 '$audio_path' 不存在"
|
|
|
|
+ return 1
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ # 执行 FFmpeg 命令
|
|
|
|
+ ffmpeg -i "$video_path" -i "$audio_path" -c:v copy -c:a copy "$output_path"
|
|
|
|
+
|
|
|
|
+ # 检查命令是否成功执行
|
|
|
|
+ if [ $? -eq 0 ]; then
|
|
|
|
+ echo "合并完成: 输出文件为 '$output_path'"
|
|
|
|
+ else
|
|
|
|
+ echo "错误: 合并失败"
|
|
|
|
+ return 1
|
|
|
|
+ fi
|
|
}
|
|
}
|