python检查web无线电url



文件: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:UserschrisDesktop>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:UserschrisDesktop>

有什么想法吗?我该怎么修?

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

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

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

相关内容

  • 没有找到相关文章