Skip to content
compile.sh 1.1 KiB
Newer Older
Pierre Ozoux's avatar
Pierre Ozoux committed
#!/bin/bash

Pierre Ozoux's avatar
Pierre Ozoux committed
echo "Compiling stream with ID ${STREAM_ID}"

Pierre Ozoux's avatar
Pierre Ozoux committed
export MC_HOST_minio=https://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@${S3_ENDPOINT}

for i in `mc ls minio/${BUCKET}/hls/0/ | grep -o "stream-$STREAM_ID.*.ts"`;do
Pierre Ozoux's avatar
Pierre Ozoux committed
  echo file https://${S3_ENDPOINT}/$BUCKET/hls/0/$i;
Pierre Ozoux's avatar
Pierre Ozoux committed
done > /tmp/allts


ffmpeg -f concat -safe 0 -protocol_whitelist file,http,tcp,https,tls -i /tmp/allts \
  -acodec copy -bsf:a aac_adtstoasc -vcodec copy -movflags frag_keyframe+empty_moov \
  -f mp4 - | mc pipe minio/$BUCKET/recordings/${STREAM_ID}.mp4
Pierre Ozoux's avatar
Pierre Ozoux committed

echo "Deleting original ts files..."

for i in `mc ls minio/${BUCKET}/hls/0/ | grep -o "stream-$STREAM_ID.*.ts"`;do
  mc rm minio/${BUCKET}/hls/0/$i;
Pierre Ozoux's avatar
Pierre Ozoux committed
done
for i in `mc ls minio/${BUCKET}/hls/1/ | grep -o "stream-$STREAM_ID.*.ts"`;do
Pierre Ozoux's avatar
Pierre Ozoux committed
  mc rm minio/${BUCKET}/hls/1/$i;
Pierre Ozoux's avatar
Pierre Ozoux committed
done
for i in `mc ls minio/${BUCKET}/hls/2/ | grep -o "stream-$STREAM_ID.*.ts"`;do
Pierre Ozoux's avatar
Pierre Ozoux committed
  mc rm minio/${BUCKET}/hls/2/$i;
Pierre Ozoux's avatar
Pierre Ozoux committed
done
Pierre Ozoux's avatar
Pierre Ozoux committed

# https://github.com/kubernetes/kubernetes/issues/20255
echo "Last message, even if the last delete didn't succeed, we want a clean return code (: if not the job restarts.. and wipe the recording :)"