Skip to content

Instantly share code, notes, and snippets.

@Padam87
Last active October 7, 2019 15:57
Show Gist options
  • Save Padam87/7303685 to your computer and use it in GitHub Desktop.
Save Padam87/7303685 to your computer and use it in GitHub Desktop.
Remove unnecessary audio streams from video files using ffmpeg.
#!/bin/bash
files=${1-"*.avi"};
audio_stream=${2-"0:1"};
video_stream=${3-"0:0"};
output_dir=${4-output};
echo -e "\e[0;33m";
echo " Files: $files";
echo "Video stream: $video_stream";
echo "Audio stream: $audio_stream";
echo " Output dir: $output_dir";
echo -e "\e[0m";
read -p "Continue? (y/n)" continue
case "$continue" in
y*) break;;
n*) exit;;
esac
mkdir $output_dir;
for f in $files;
do ffmpeg -i "$f" -map $video_stream -map $audio_stream -vcodec copy -acodec copy "$output_dir/$f";
done
@Padam87
Copy link
Author

Padam87 commented Nov 4, 2013

Usage:

ffmpeg-singleaudiostream.sh [files] [audio_stream] [video_stream] [output_dir]

ffmpeg-singleaudiostream.sh "*.avi" 0:1 0:0 output

@Padam87
Copy link
Author

Padam87 commented Apr 25, 2015

@muchbetterbig 30 bucks to replace a one liner command is not a good deal if you ask me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment