Add --audio-track-no flag support to scripts/shell/ffmpeg-helper.sh file
This commit is contained in:
@@ -12,6 +12,7 @@ show_help() {
|
||||
echo " --scale640 Scale the video to 640x320."
|
||||
echo " --merge-audio Merge all audio tracks into the main track."
|
||||
echo " --remove-audio Suppress all audio and remove audio tracks."
|
||||
echo " --audio-track-no Selects a specific audio track for the output"
|
||||
echo " --output|-o Specify the output filename (required)."
|
||||
}
|
||||
|
||||
@@ -36,6 +37,7 @@ new_fps=""
|
||||
scale640=false
|
||||
merge_audio=false
|
||||
remove_audio=false
|
||||
audio_track_no=1
|
||||
output_file=""
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
@@ -50,6 +52,7 @@ while [ "$#" -gt 0 ]; do
|
||||
--scale640) scale640=true; shift ;;
|
||||
--merge-audio) merge_audio=true; shift ;;
|
||||
--remove-audio) remove_audio=true; shift;;
|
||||
--audio-track-no) audio_track_no="$2"; shift;;
|
||||
--output|-o) output_file="$2"; shift 2 ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
@@ -90,6 +93,16 @@ if [ "$merge_audio" = true ] && [ "$remove_audio" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$merge_audio" = true ] && [ "$audio_track_no" != 1 ]; then
|
||||
echo "Error: Cannot use both --merge-audio and --audio-track-no together."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$remove_audio" = true ] && [ "$audio_track_no" != 1 ]; then
|
||||
echo "Error: Cannot use both --remove-audio and --audio-track-no together."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ffmpeg_command="ffmpeg -i \"$input_file\""
|
||||
|
||||
if [ "$remove_audio" = true ]; then
|
||||
@@ -121,6 +134,10 @@ if [ "$merge_audio" = true ]; then
|
||||
ffmpeg_command+=" -filter_complex amerge=inputs=$num_audio_streams"
|
||||
fi
|
||||
|
||||
if [ "$audio_track_no" != 1 ]; then
|
||||
ffmpeg_command+=" -map 0:0 -map 0:$audio_track_no"
|
||||
fi
|
||||
|
||||
ffmpeg_command+=" \"$output_file\""
|
||||
|
||||
echo "Running ffmpeg command:"
|
||||
|
||||
Reference in New Issue
Block a user