Skip to content

Instantly share code, notes, and snippets.

@ThePredators
Last active December 1, 2022 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThePredators/f0ce7eb080077587def0adb28ba51894 to your computer and use it in GitHub Desktop.
Save ThePredators/f0ce7eb080077587def0adb28ba51894 to your computer and use it in GitHub Desktop.

⭐ Manipulate Audio/Video with FFmpeg

Install

brew install ffmpeg

How to use ?

Simply copy the following aliases to your .zshrc and use the commands marked with CLI ! Enjoy :)

Edit an audio file // Slice from/to

# CLI : audio_edit test.m4a 00:00:36 00:08:19
audio_edit() {
	OUTPUT='new_'$1;
	rm $OUTPUT;
	ffmpeg -i $1 -ss $2 -to $3 -c copy $OUTPUT;
}

Mix 1 single audio file multiple times to increase its duration

# CLI : audio_mix 10 new_test.m4a test-1H.m4a
audio_mix() {
	LIST=list.txt;
	max=$1;for i in `seq 1 $max`; do echo "file '$2'" >> $LIST; done;
	ffmpeg -f concat -safe 0 -i $LIST -c copy $3;
	rm $LIST;
}

Make a video using Audio & a Cover

# CLI : video_make cover.jpg test-1H.m4a test-1H.mp4
video_make() {
	ffmpeg -loop 1 -i $1 -i $2 -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest $3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment