Skip to content

Instantly share code, notes, and snippets.

@nramsbottom
Created March 29, 2020 00:02
Show Gist options
  • Save nramsbottom/a4c9d0732b5823d2c0f9a634774f737f to your computer and use it in GitHub Desktop.
Save nramsbottom/a4c9d0732b5823d2c0f9a634774f737f to your computer and use it in GitHub Desktop.
Rebuild MP4
#!/bin/bash
# this is a script that was made to extract the video and *second* audio stream
# from an all the mp4 files in the current directory and rebuild them to contain
# just the video and the second audio stream
for filename in *.avi; do
ffmpeg -y -i "$filename" -an -vcodec copy video.mp4
ffmpeg -y -i "$filename" -map 0:2 -vn -acodec copy audio.mp3
mv "$filename" "$filename.old"
ffmpeg -i video.mp4 -i audio.mp3 -vcodec copy -acodec copy "$filename"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment