Alyssa Smith revised this gist . Go to revision
1 file changed, 10 insertions, 8 deletions
hlstranscode.sh
| @@ -1,5 +1,5 @@ | |||
| 1 | 1 | #!/bin/bash | |
| 2 | - | # hlstranscode "$URL" | |
| 2 | + | # hlstranscode $URL | |
| 3 | 3 | ||
| 4 | 4 | cat >/tmp/cloud.conf <<EOFF | |
| 5 | 5 | #!/bin/bash | |
| @@ -16,23 +16,25 @@ $(cat ~/.config/rclone/rclone.conf) | |||
| 16 | 16 | EOF | |
| 17 | 17 | ||
| 18 | 18 | cd /root/inp | |
| 19 | - | curl "\$URL" -O 2>/dev/null | |
| 19 | + | curl "\$URL" -L -O | |
| 20 | 20 | export SUM=\$(sha1sum * | awk '{print \$1}') | |
| 21 | 21 | cd /root | |
| 22 | 22 | ||
| 23 | 23 | git clone https://github.com/vincentbernat/video2hls /root/video2hls 2>/dev/null | |
| 24 | - | /root/video2hls/video2hls --output /root/out/\$SUM /root/inp/* | |
| 24 | + | /root/video2hls/video2hls --audio-only --audio-bitrate 128 --output /root/out/\$SUM /root/inp/* | |
| 25 | 25 | ffmpeg -i /root/inp/* /root/out/\$SUM/index.vtt 2>/dev/null | |
| 26 | + | echo "\$URL" >> /root/out/\$SUM/.source | |
| 26 | 27 | rclone copy /root/out/ b2:ads-share/hls/ --transfers=40 | |
| 27 | 28 | ||
| 28 | 29 | echo \$SUM | |
| 29 | 30 | echo "ALLDONE (ctrl-c)" | |
| 31 | + | curl -X POST --data '{"from": "hlstranscode", "message": "transcoded $(basename "$1") '\$SUM'"}' https://logger.alyssasmith.id.au | |
| 30 | 32 | curl -X DELETE -H "Authorization: Bearer $(grep access-token "/Users/alyssa/Library/Application Support/doctl/config.yaml" | awk '{print $2}')" https://api.digitalocean.com/v2/droplets/\$ID | |
| 31 | 33 | EOFF | |
| 32 | 34 | cat /tmp/cloud.conf | |
| 33 | - | #read IP <<< $(set -x; doctl compute droplet create $(base32 -w0 <<<"$1" | sed 's/=/0/g') --region sgp1 --size s-16vcpu-64gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf --wait --no-header --format PublicIPv4) | |
| 34 | - | (set -x; doctl compute droplet create hlstranscode-$(date +%Y%m%d-%H%M%S) --region sgp1 --size s-16vcpu-64gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf) | |
| 35 | + | read IP <<< $(set -x; doctl compute droplet create hlstranscode-$(date +%Y%m%d-%H%M%S) --region sgp1 --size s-24vcpu-128gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf --wait --no-header --format PublicIPv4) | |
| 36 | + | #(set -x; doctl compute droplet create hlstranscode-$(date +%Y%m%d-%H%M%S) --region sgp1 --size s-24vcpu-128gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf) | |
| 35 | 37 | rm /tmp/cloud.conf | |
| 36 | - | #until (ssh -o StrictHostKeyChecking=no root@$IP tail -f /var/log/cloud-init-output.log); do | |
| 37 | - | # sleep 1 | |
| 38 | - | #done | |
| 38 | + | until (ssh -o StrictHostKeyChecking=no root@$IP tail -f /var/log/cloud-init-output.log); do | |
| 39 | + | sleep 1 | |
| 40 | + | done | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 6 insertions, 5 deletions
hlstranscode.sh
| @@ -8,7 +8,7 @@ apt-get install ffmpeg -y -qq | |||
| 8 | 8 | curl https://rclone.org/install.sh | bash 2>/dev/null >/dev/null | |
| 9 | 9 | ||
| 10 | 10 | export ID=\$(curl http://169.254.169.254/metadata/v1/id 2>/dev/null) | |
| 11 | - | export URL=\$(curl http://169.254.169.254/metadata/v1/hostname 2>/dev/null | sed 's/0/=/g' | base32 -d) | |
| 11 | + | export URL="$1" | |
| 12 | 12 | ||
| 13 | 13 | mkdir -p /root/.config/rclone /root/inp | |
| 14 | 14 | cat > /root/.config/rclone/rclone.conf <<EOF | |
| @@ -30,8 +30,9 @@ echo "ALLDONE (ctrl-c)" | |||
| 30 | 30 | curl -X DELETE -H "Authorization: Bearer $(grep access-token "/Users/alyssa/Library/Application Support/doctl/config.yaml" | awk '{print $2}')" https://api.digitalocean.com/v2/droplets/\$ID | |
| 31 | 31 | EOFF | |
| 32 | 32 | cat /tmp/cloud.conf | |
| 33 | - | read IP <<< $(set -x; doctl compute droplet create $(base32 -w0 <<<"$1" | sed 's/=/0/g') --region sgp1 --size s-16vcpu-64gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf --wait --no-header --format PublicIPv4) | |
| 33 | + | #read IP <<< $(set -x; doctl compute droplet create $(base32 -w0 <<<"$1" | sed 's/=/0/g') --region sgp1 --size s-16vcpu-64gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf --wait --no-header --format PublicIPv4) | |
| 34 | + | (set -x; doctl compute droplet create hlstranscode-$(date +%Y%m%d-%H%M%S) --region sgp1 --size s-16vcpu-64gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf) | |
| 34 | 35 | rm /tmp/cloud.conf | |
| 35 | - | until (ssh -o StrictHostKeyChecking=no root@$IP tail -f /var/log/cloud-init-output.log); do | |
| 36 | - | sleep 1 | |
| 37 | - | done | |
| 36 | + | #until (ssh -o StrictHostKeyChecking=no root@$IP tail -f /var/log/cloud-init-output.log); do | |
| 37 | + | # sleep 1 | |
| 38 | + | #done | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 2 insertions, 2 deletions
hlstranscode.sh
| @@ -8,7 +8,7 @@ apt-get install ffmpeg -y -qq | |||
| 8 | 8 | curl https://rclone.org/install.sh | bash 2>/dev/null >/dev/null | |
| 9 | 9 | ||
| 10 | 10 | export ID=\$(curl http://169.254.169.254/metadata/v1/id 2>/dev/null) | |
| 11 | - | export URL=\$(curl http://169.254.169.254/metadata/v1/hostname 2>/dev/null | sed 's/-/=/g' | base32 -d) | |
| 11 | + | export URL=\$(curl http://169.254.169.254/metadata/v1/hostname 2>/dev/null | sed 's/0/=/g' | base32 -d) | |
| 12 | 12 | ||
| 13 | 13 | mkdir -p /root/.config/rclone /root/inp | |
| 14 | 14 | cat > /root/.config/rclone/rclone.conf <<EOF | |
| @@ -30,7 +30,7 @@ echo "ALLDONE (ctrl-c)" | |||
| 30 | 30 | curl -X DELETE -H "Authorization: Bearer $(grep access-token "/Users/alyssa/Library/Application Support/doctl/config.yaml" | awk '{print $2}')" https://api.digitalocean.com/v2/droplets/\$ID | |
| 31 | 31 | EOFF | |
| 32 | 32 | cat /tmp/cloud.conf | |
| 33 | - | read IP <<< $(set -x; doctl compute droplet create $(base32 -w0 <<<"$1" | sed 's/=/-/g') --region sgp1 --size s-16vcpu-64gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf --wait --no-header --format PublicIPv4) | |
| 33 | + | read IP <<< $(set -x; doctl compute droplet create $(base32 -w0 <<<"$1" | sed 's/=/0/g') --region sgp1 --size s-16vcpu-64gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf --wait --no-header --format PublicIPv4) | |
| 34 | 34 | rm /tmp/cloud.conf | |
| 35 | 35 | until (ssh -o StrictHostKeyChecking=no root@$IP tail -f /var/log/cloud-init-output.log); do | |
| 36 | 36 | sleep 1 | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 10 insertions, 10 deletions
hlstranscode.sh
| @@ -1,14 +1,14 @@ | |||
| 1 | 1 | #!/bin/bash | |
| 2 | - | # hlstranscode "URL" | |
| 2 | + | # hlstranscode "$URL" | |
| 3 | 3 | ||
| 4 | 4 | cat >/tmp/cloud.conf <<EOFF | |
| 5 | - | #!/bin/bash -x | |
| 6 | - | apt-get update | |
| 7 | - | apt-get install ffmpeg -y | |
| 8 | - | curl https://rclone.org/install.sh | bash | |
| 5 | + | #!/bin/bash | |
| 6 | + | apt-get update -qq | |
| 7 | + | apt-get install ffmpeg -y -qq | |
| 8 | + | curl https://rclone.org/install.sh | bash 2>/dev/null >/dev/null | |
| 9 | 9 | ||
| 10 | - | export ID=\$(curl http://169.254.169.254/metadata/v1/id) | |
| 11 | - | export URL=\$(curl http://169.254.169.254/metadata/v1/hostname | sed 's/-/=/g' | base32 -d) | |
| 10 | + | export ID=\$(curl http://169.254.169.254/metadata/v1/id 2>/dev/null) | |
| 11 | + | export URL=\$(curl http://169.254.169.254/metadata/v1/hostname 2>/dev/null | sed 's/-/=/g' | base32 -d) | |
| 12 | 12 | ||
| 13 | 13 | mkdir -p /root/.config/rclone /root/inp | |
| 14 | 14 | cat > /root/.config/rclone/rclone.conf <<EOF | |
| @@ -20,13 +20,13 @@ curl "\$URL" -O 2>/dev/null | |||
| 20 | 20 | export SUM=\$(sha1sum * | awk '{print \$1}') | |
| 21 | 21 | cd /root | |
| 22 | 22 | ||
| 23 | - | git clone https://github.com/vincentbernat/video2hls /root/video2hls | |
| 23 | + | git clone https://github.com/vincentbernat/video2hls /root/video2hls 2>/dev/null | |
| 24 | 24 | /root/video2hls/video2hls --output /root/out/\$SUM /root/inp/* | |
| 25 | - | ffmpeg -i /root/inp/* /root/out/\$SUM/index.vtt | |
| 25 | + | ffmpeg -i /root/inp/* /root/out/\$SUM/index.vtt 2>/dev/null | |
| 26 | 26 | rclone copy /root/out/ b2:ads-share/hls/ --transfers=40 | |
| 27 | 27 | ||
| 28 | 28 | echo \$SUM | |
| 29 | - | echo ALLDONE | |
| 29 | + | echo "ALLDONE (ctrl-c)" | |
| 30 | 30 | curl -X DELETE -H "Authorization: Bearer $(grep access-token "/Users/alyssa/Library/Application Support/doctl/config.yaml" | awk '{print $2}')" https://api.digitalocean.com/v2/droplets/\$ID | |
| 31 | 31 | EOFF | |
| 32 | 32 | cat /tmp/cloud.conf | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 37 insertions
hlstranscode.sh(file created)
| @@ -0,0 +1,37 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # hlstranscode "URL" | |
| 3 | + | ||
| 4 | + | cat >/tmp/cloud.conf <<EOFF | |
| 5 | + | #!/bin/bash -x | |
| 6 | + | apt-get update | |
| 7 | + | apt-get install ffmpeg -y | |
| 8 | + | curl https://rclone.org/install.sh | bash | |
| 9 | + | ||
| 10 | + | export ID=\$(curl http://169.254.169.254/metadata/v1/id) | |
| 11 | + | export URL=\$(curl http://169.254.169.254/metadata/v1/hostname | sed 's/-/=/g' | base32 -d) | |
| 12 | + | ||
| 13 | + | mkdir -p /root/.config/rclone /root/inp | |
| 14 | + | cat > /root/.config/rclone/rclone.conf <<EOF | |
| 15 | + | $(cat ~/.config/rclone/rclone.conf) | |
| 16 | + | EOF | |
| 17 | + | ||
| 18 | + | cd /root/inp | |
| 19 | + | curl "\$URL" -O 2>/dev/null | |
| 20 | + | export SUM=\$(sha1sum * | awk '{print \$1}') | |
| 21 | + | cd /root | |
| 22 | + | ||
| 23 | + | git clone https://github.com/vincentbernat/video2hls /root/video2hls | |
| 24 | + | /root/video2hls/video2hls --output /root/out/\$SUM /root/inp/* | |
| 25 | + | ffmpeg -i /root/inp/* /root/out/\$SUM/index.vtt | |
| 26 | + | rclone copy /root/out/ b2:ads-share/hls/ --transfers=40 | |
| 27 | + | ||
| 28 | + | echo \$SUM | |
| 29 | + | echo ALLDONE | |
| 30 | + | curl -X DELETE -H "Authorization: Bearer $(grep access-token "/Users/alyssa/Library/Application Support/doctl/config.yaml" | awk '{print $2}')" https://api.digitalocean.com/v2/droplets/\$ID | |
| 31 | + | EOFF | |
| 32 | + | cat /tmp/cloud.conf | |
| 33 | + | read IP <<< $(set -x; doctl compute droplet create $(base32 -w0 <<<"$1" | sed 's/=/-/g') --region sgp1 --size s-16vcpu-64gb --image ubuntu-20-04-x64 --ssh-keys 28633873,28633866,29533274,29451733,29347920,30747235 --user-data-file /tmp/cloud.conf --wait --no-header --format PublicIPv4) | |
| 34 | + | rm /tmp/cloud.conf | |
| 35 | + | until (ssh -o StrictHostKeyChecking=no root@$IP tail -f /var/log/cloud-init-output.log); do | |
| 36 | + | sleep 1 | |
| 37 | + | done | |