Skip to content

Instantly share code, notes, and snippets.

@fcicq
Forked from dyama/twitcast.sh
Last active September 11, 2021 04:30
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcicq/93106778ebea9e31bab5 to your computer and use it in GitHub Desktop.
Save fcicq/93106778ebea9e31bab5 to your computer and use it in GitHub Desktop.
Simple recorder for Twitcasting.tv
#!/bin/bash
# coding: utf-8
# twitcast.sh by dyama
LIVESTREAMER="streamlink"
($LIVESTREAMER --version 1>/dev/null 2>&1) || (echo 'install streamlink first (run pip/pip3 install streamlink)'; exit)
if [ -n "$1" ]; then
id=$(echo "$1" | sed 's|^.*/||g')
while true; do
while true; do
(curl -s "http://api.twitcasting.tv/api/livestatus?user=$id" | grep "\"islive\":true") && break
echo "Not Alive, Sleeping $(date +'%F_%H-%M-%S')"
sleep 30
done
fname="${id}_$(date +'%F_%H-%M-%S').ts"
$LIVESTREAMER --hls-segment-threads 3 --hls-segment-timeout 1.5 --http-timeout 1.5 -o "$fname" "hlsvariant://twitcasting.tv/$id/metastream.m3u8?video=1" best
# ffmpeg -nostdin -i "http://twitcasting.tv/$id/metastream.m3u8?video=1" \
# -vcodec copy -acodec copy -fflags nobuffer -f mpegts "$fname"
if [ "$2" != "loop" ]; then
break
fi
done
else
echo "usage: $0 twitcasting_account"
fi
@fcicq
Copy link
Author

fcicq commented Dec 14, 2016

TODO: https: //api.periscope.tv/api/v2/accessVideoPublic?broadcast_id=
hls_url (https_hls_url) / replay_url

@fcicq
Copy link
Author

fcicq commented May 16, 2017

<input type="hidden" id="movie_file_path" value="ttp://dl01.twitcasting.tv/USERNAME/download/VIDEOID">

ffmpeg -i URI -c copy -bsf:a aac_adtstoasc OUTFILE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment