Skip to content

Instantly share code, notes, and snippets.

@Natata
Created March 1, 2017 13:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Natata/1a2d7193404592a19fde145d1f61dd14 to your computer and use it in GitHub Desktop.
Save Natata/1a2d7193404592a19fde145d1f61dd14 to your computer and use it in GitHub Desktop.
record twitcasting streaming
#!/bin/bash
# coding: utf-8
# twitcasting_record.sh by Natata
# modified from showroom.sh by fcicq
# NOTE: need to install jq and livestreamer first
(jq --version 1>/dev/null 2>&1) || (echo 'install jq first'; exit)
(livestreamer --version 1>/dev/null 2>&1) || (echo 'install livestreamer first (run pip/pip3 install livestreamer)'; exit)
if [ -n "$1" ]; then
id=$(echo "$1" | sed 's|^.*/||g')
while true; do
fname="${id}_$(date +'%F_%H-%M-%S').ts"
echo "File name: $fname"
url="http://twitcasting.tv/$id/metastream.m3u8"
echo "url: $url"
livestreamer --hls-segment-threads 3 --hls-segment-timeout 1.5 --http-timeout 1.5 -o "$fname" "hlsvariant://$url" best
# ffmpeg -nostdin -i "$url" \
# -vcodec copy -acodec copy -f mpegts "$fname"
if [ "$2" != "loop" ]; then
break
fi
done
fi
echo "live finish: " $fname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment