程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

python检查网络广播网址

发布于2023-03-21 14:24     阅读(880)     评论(0)     点赞(7)     收藏(5)


文件:check_web_radio.py

from subprocess import Popen
import subprocess
import os
import sys

def check_retransmition(stream_url):
    try:
        print("Checking url:"+str(stream_url))
        if os.path.exists("outputfile.mp3"):
            os.remove("outputfile.mp3")
        ffmpeg_path = os.path.abspath("ffmpeg.exe")
        p1 = Popen([ffmpeg_path,'-y','-t','10','-i',stream_url,'outputfile.mp3'],stdout=subprocess.PIPE)
        p1.wait()
        try:
            streamdata = p1.communicate()[0]
        except:
            pass
        rc = p1.returncode
        p1.terminate()
        if os.path.exists("outputfile.mp3"):
            os.remove("outputfile.mp3")
        if int(rc)==0:
            print("Result: True")
            return True
        else:
            print("Result: False")
            return False
    except Exception as e:
        print(e)
        print("Result: False (exception)")
        return False

check_retransmition("https://impradio.bytemasters.gr/8002/LIVE")
sys.exit()

结果:

C:\Users\chris\Desktop>python check_web_radio.py
Checking url:https://impradio.bytemasters.gr/8002/LIVE
ffmpeg version N-108547-gaaf4109a5f-20221006 Copyright (c) 2000-2022 the FFmpeg
developers
  built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-conf
ig=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw
32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-
pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --en
able-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbi
s --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable
-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enabl
e-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cu
da-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --en
able-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-lib
rist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enabl
e-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --en
able-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --en
able-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-lib
srt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm -
-disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-
libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid
--enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxx
flags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-
version=20221006
  libavutil      57. 39.100 / 57. 39.100
  libavcodec     59. 50.100 / 59. 50.100
  libavformat    59. 34.100 / 59. 34.100
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 49.101 /  8. 49.101
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    56.  7.100 / 56.  7.100
[tls @ 00000000004db100] Creating security context failed (0x80090302)
https://impradio.bytemasters.gr/8002/LIVE: Unknown error occurred
Result: False

C:\Users\chris\Desktop>

有什么想法我该如何解决?

请注意:check_retransmition("http://impradio.bytemasters.gr/8002/LIVE")(http 而不是 https)在 avast 允许后有效!


解决方案


出于安全原因,旧版本的 Windows 已禁用此功能(我使用的是 Windows 7)。

使用这个 ffmpeg 版本(我使用了第二个链接)解决了这个问题。



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/1944130/a571e716fa0fbe881e50/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

7 0
收藏该文
已收藏

评论内容:(最多支持255个字符)