SHARE
TWEET

Untitled

a guest Feb 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. # set -euxo pipefail # uncomment this for debugging
  3.  
  4. ###################################
  5. # INSTRUCTIONS
  6. # 1. Set Artist, Album, Timestamps and Track Names below
  7. # 2. Save split.sh into the folder with file to be split
  8. # 3. ./split.sh <m4a file to be split>
  9. ###################################
  10.  
  11. artist="The Artist"
  12. album="My Album"
  13.  
  14. # Timestamps are in seconds
  15. # start_time;end_time;song_title
  16. timestamps=$(cat << EOF
  17.     0;300;First Song
  18.     302;600;Second Song
  19.     602;900;Third Song
  20.     902;1200;Fourth Song
  21. EOF
  22. )
  23.  
  24. ###################################
  25. # DO NOT EDIT BELOW HERE
  26. ###################################
  27. mkdir -p "${artist}/${album}"
  28. track=1
  29. while read -r name
  30. do
  31.     IFS=";" read -ra fields <<<"${name}"
  32.     startpos=${fields[0]}
  33.     endpos=${fields[1]}
  34.     title=${fields[2]}
  35.     length=$(( endpos-startpos ))
  36.     tr=$(printf "%02d" ${track})
  37.     ffmpeg -nostdin \
  38.         -ss "${startpos}" \
  39.         -i "${1}" -vn -c copy \
  40.         -t "${length}" \
  41.         -metadata title="${title}" \
  42.         -metadata artist="${artist}" \
  43.         -metadata track="${track}" \
  44.         -metadata album="${album}" \
  45.         -metadata album_artist="${artist}" \
  46.         "${artist}/${album}/${tr} ${title}.m4a"
  47.     (( "track++" ))
  48. done <<< "${timestamps}"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top