Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # set -euxo pipefail # uncomment this for debugging
- ###################################
- # INSTRUCTIONS
- # 1. Set Artist, Album, Timestamps and Track Names below
- # 2. Save split.sh into the folder with file to be split
- # 3. ./split.sh <m4a file to be split>
- ###################################
- artist="The Artist"
- album="My Album"
- # Timestamps are in seconds
- # start_time;end_time;song_title
- timestamps=$(cat << EOF
- 0;300;First Song
- 302;600;Second Song
- 602;900;Third Song
- 902;1200;Fourth Song
- EOF
- )
- ###################################
- # DO NOT EDIT BELOW HERE
- ###################################
- mkdir -p "${artist}/${album}"
- track=1
- while read -r name
- do
- IFS=";" read -ra fields <<<"${name}"
- startpos=${fields[0]}
- endpos=${fields[1]}
- title=${fields[2]}
- length=$(( endpos-startpos ))
- tr=$(printf "%02d" ${track})
- ffmpeg -nostdin \
- -ss "${startpos}" \
- -i "${1}" -vn -c copy \
- -t "${length}" \
- -metadata title="${title}" \
- -metadata artist="${artist}" \
- -metadata track="${track}" \
- -metadata album="${album}" \
- -metadata album_artist="${artist}" \
- "${artist}/${album}/${tr} ${title}.m4a"
- (( "track++" ))
- done <<< "${timestamps}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement