我需要你的帮助,我写了这个函数来使用vlc.py保存音频流,但是当我在终端上运行时没有任何反应。当我使用python解释器时,我创建了音频文件。感谢
import vlc
def grabar_audio(stream, parametros):
radio = stream
datos = parametros
instancia = vlc.Instance()
player = instancia.media_player_new()
media = instancia.media_new(radio, datos)
media.get_mrl()
player.set_media(media)
player.play()
return media
radio = 'http://212.83.146.67:7212/stream'
datos = "--sout=#standard{access=file,mux=ts,dst='/home/eparionad/Descargas/ProyectoPython/prueba32.mp3'} --run-time=10 --stop-time=10"
grabar_audio(radio, datos)
答案 0 :(得分:0)
问题是该实例是在程序运行时执行的,在示例中,您总是使用具有无限循环的GUI,但是对于您的代码,我们必须提供它。
import sys
import vlc
from time import sleep
def grabar_audio(stream, parametros):
radio = stream
datos = parametros
instancia = vlc.Instance()
player = instancia.media_player_new()
media = instancia.media_new(radio, datos)
media.get_mrl()
player.set_media(media)
player.play()
return media
radio = 'http://212.83.146.67:7212/stream'
datos = "--sout=#standard{access=file,mux=ts,dst='/home/eparionad/Descargas/ProyectoPython/prueba32.mp3'} --run-time=10 --stop-time=10"
grabar_audio(radio, datos)
while True:
try:
sleep(1)
except KeyboardInterrupt:
sys.exit(0)