by
3 6
0
3
212k
0
Top 1% !
Pearl of Wisdom
Specified
Popularity: 7338th place
Created
Modified Jan 23, 2016

Published on:

No tags for this snippet yet.
LanguageShell
OSiOS
SourceGitHub

A small script to make recording http live streams (HLS, those streams that work on iOS devices) nicer on a Mac. Script records the stream for a defined period of time and sends the user notifications if anything goes wrong and once it's done.

A small script to make recording http live streams (HLS, those streams that work on iOS devices) nicer on a Mac. Script records the stream for a defined period of time and sends the user notifications if anything goes wrong and once it's done.: 
HLS_dvr.sh
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1012320/A-small-script-to-make-recording-http-li?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
# required: ffmpeg (e.g. from homebrew), terminal-notifier from https://github.com/alloy/terminal-notifier # you can schedule this with launchd to run e.g. weekly # Specify in seconds how long the script should record (default here is 1 hour). seconds=3600 # Date format for the recording file name DATE=`date "+%d-%m-%y_%H-%M"` # start ffmpeg recording ffmpeg -re -i http://website.com/playlist.m3u8 -c copy -bsf:a aac_adtstoasc recording_$DATE.mp4 & # notification that recording has started if [ "$(pgrep -P $$ 'ffmpeg')" ] then /Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title 'ffmpeg' -message "is recording now" -sender 'com.apple.Terminal' else /Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title 'ffmpeg' -message "is not recording!" -sound Funk -sender 'com.apple.Terminal' exit 42 fi # check every 30 seconds for $seconds to make sure ffmpeg is still running START=`date +%s` while [ $(( $(date +%s) - $seconds )) -lt $START ]; do if [ -z "$(pgrep -P $$ 'ffmpeg')" ] then /Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title 'ffmpeg' -message "is no longer running" -sound Funk -sender 'com.apple.Terminal' fi sleep 30 done # notification when time is up /Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title 'ffmpeg' -message "recording finished" -sound default -sender 'com.apple.Terminal' # stop ffmpeg (using this because stopping ffmpeg via -t for duration turned out to be extremely unreliable) kill $(pgrep -P $$ 'ffmpeg')
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus