Created
February 9, 2023 00:29
-
-
Save louisswarren/6f69f4f0940cac08e55043ef5d5979d4 to your computer and use it in GitHub Desktop.
Trim audio files with fade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: | |
# trim FILE START END FADE_IN FADE_OUT | |
# 1 2 3 4 5 | |
# Trim the file between START and END, with fade in and out, and | |
# 2 seconds of silence after | |
dur=`expr "${3%:*}" \* 60 + "${3#*:}" - "${2%:*}" \* 60 - "${2#*:}"` | |
fo=`expr "$dur" - $5` | |
ffmpeg \ | |
-ss "$2" -to "$3" \ | |
-i "$1" \ | |
-af "afade=t=in:st=0:d=$4,afade=t=out:st=$fo:d=$5,apad=pad_dur=2" \ | |
-ab 320k \ | |
-map_metadata 0 -id3v2_version 3 \ | |
"${1%flac}mp3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment