sh 在Mac上录制http直播流(HLS,在iOS设备上运行的那些流)的小脚本更好。脚本记录流f

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在Mac上录制http直播流(HLS,在iOS设备上运行的那些流)的小脚本更好。脚本记录流f相关的知识,希望对你有一定的参考价值。

# 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')

以上是关于sh 在Mac上录制http直播流(HLS,在iOS设备上运行的那些流)的小脚本更好。脚本记录流f的主要内容,如果未能解决你的问题,请参考以下文章

如何在 iOS 上下载 LIVE HLS m3u8 流

在播放 iOS 时从 HLS 流(视频)中提取/录制音频

如何使用iOS实现视频的直播点播缓存?-HTTP Live Streaming (HLS)

调用Live555接收RTSP直播流,转换为Http Live Streaming(iOS直播)协议

腾讯云轻量应用服务器使用 SRS 应用镜像搭建个人直播间视频转播本地录制!

腾讯云轻量应用服务器使用 SRS 应用镜像搭建个人直播间视频转播本地录制!