【问题标题】:YouTube Live Broadcast silence detectYouTube 直播静音检测
【发布时间】:2020-05-08 04:55:16
【问题描述】:

我正在尝试监视 YouTube 直播是否静默,以便能够重新启动 ffmpeg 广播。在不违反 YouTube ToS 的情况下如何实现这一目标?

我尝试使用 YouTube API,但 health.status 仅支持直播,不支持广播。

我想出了 youtube-dl 的想法,抓住 m3u8 并使用静音检测运行 ffmpeg,但现在我不知何故被卡住了。

获取格式

youtube-dl --list-formats https://www.youtube.com/watch?v=BiHequcIiNw

获取 m3u8 清单

youtube-dl -f 91 -g https://www.youtube.com/watch?v=BiHequcIiNw

运行 ffprobe

ffprobe -v quiet -print_format json -show_streams https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1588936061/ei/Hem0Xp35EZLl1wLLhYaYCA/ip/2a02:1205:c6bb:4590:301f:6186:c624:f2ba/id/BiHequcIiNw.0/itag/91/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/goi/160/sgoap/gir%3Dyes%3Bitag%3D139/sgovp/gir%3Dyes%3Bitag%3D160/hls_chunk_host/r3---sn-nfpnnjvh-9and.googlevideo.com/playlist_duration/30/manifest_duration/30/vprv/1/playlist_type/DVR/initcwndbps/13630/mh/GY/mm/44/mn/sn-nfpnnjvh-9and/ms/lva/mv/m/mvi/2/pl/48/dover/11/keepalive/yes/fexp/23882513/mt/1588914375/disable_polymer/true/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,goi,sgoap,sgovp,playlist_duration,manifest_duration,vprv,playlist_type/sig/AOq0QJ8wRgIhALApv3H2YEE2GLTXIyRxw8Fu8espLgRThUfhi97DIS6-AiEAsT_4bwAfsihK6zsrKgaxMYTemlAr8BXnBTwuhwe3aAE%3D/lsparams/hls_chunk_host,initcwndbps,mh,mm,mn,ms,mv,mvi,pl/lsig/AG3C_xAwRQIgRG3c1ww23Jokzk6vfAfeZlhwEanWG_9GmwRip81v65cCIQDg1Y9pXWS4bUjpKpZ90c3icp4slmAzhQJPn2gqW0UOeQ%3D%3D/playlist/index.m3u8

但是如果流向上或向下,我在 json 中没有发现差异。任何提示我如何监控 m3u8 是向上还是向下?

【问题讨论】:

    标签: ffmpeg youtube-api monitoring health-monitoring


    【解决方案1】:

    这是我想出的解决方案

    !/bin/bash
    #
    # YouTube live broadcast monitor
    #
    cd /var/azuracast/videostream/
    youtubeURL=https://www.youtube.com/watch?v=BiHequcIiNw
    # Get YouTube Manifest 1
    youtube-dl -4 -f 91 -g $youtubeURL > manifest1.txt
    # Probe Manifest 1
    ffprobe -v quiet -print_format json -show_streams "$(<manifest1.txt)" > json1.txt
    sleep 2
    youtube-dl -4 -f 91 -g $youtubeURL > manifest2.txt
    ffprobe -v quiet -print_format json -show_streams "$(<manifest2.txt)" > json2.txt
    # do we have a valid json
    starttime=$(cat json1.txt | jq '.streams[].start_time')
    if [ -z "$starttime" ]; then
      echo "$(date)" "Error: No start_time" "$starttime"
      exit 1
    fi
    # compare the ffprobe json, if they are the same, the live stream stopped
    if cmp -s json1.txt json2.txt; then
        echo "$(date)" "Stream Down"
    # restart stream
        docker-compose restart videostream
        echo "$(date)" "Stream Up"
        sleep 20
    else
        echo "$(date)" "Stream Up"
    fi
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-03
      • 2017-04-11
      • 1970-01-01
      • 2012-07-16
      • 1970-01-01
      • 2017-03-23
      • 2015-08-01
      • 2017-07-31
      相关资源
      最近更新 更多