如何让`mpv --stream-record`使用icecast标题作为文件名?

问题描述 投票:0回答:2

在将

mpv
与icecast 流一起使用时,是否可以让
icy-title
根据当前
--stream-record
值将流转储到单独的文件?

man mpv
仅提到使用固定文件名与
--record-file
,
--stream-record
--dump-cache
.

如果无法直接使用

mpv
实现这一点,有什么可能的方法可以为 Icecast 播放列表中的每首歌曲保存单独的文件,而不是像
--stream-record=mystream.mp3
那样保存一个巨大的连续文件?

streaming icecast mpv
2个回答
2
投票

虽然可以使用自定义 lua 脚本来解决

mpv
显然
mpv
无法做到这一点 ootb。

一个可以解析icecast标题并将流转储到单独文件的专用实用程序是🔗

streamripper
。它可以在 debian linux 上使用
apt install streamripper
或在 mac 上使用
brew install streamripper
安装。

以下命令将创建以流标题命名的单独文件:

streamripper http://some-icast-server.com/stream -r 8888

-r
标志将在端口
8888
上创建一个中继服务器。您可以在下载时收听中继流:

mpv http://localhost:8888

0
投票

我目前正在编写一个Python脚本,它可以做到这一点。

过几天我会给你repo地址来查看,它是一个网络广播客户端,还可以录制所选的流。

这是一个非常非常简化的版本,它显示了整个过程的原理:

import mpv
import time

def title0(player):
 tit1 = player.metadata.get('icy-title')
 tit2 = player.metadata.get('title')
 tit3 = player.metadata.get('TITLE')
 tit4 = player.metadata.get('artist')
 tit5 = player.metadata.get('ARTIST')
 if tit1 == None:
  tit1 = ""
 if tit2 == None:
  tit2 = ""
 if tit3 == None:
  tit3 = ""
 if tit4 == None:
  tit4 = ""
 if tit5 == None:
  tit5 = ""
 if tit4 == "" and tit5 == "":
  pavla = ""
 else:
  pavla = " - "
 tit0 = tit1+tit2+tit3+pavla+tit4+tit5
 if tit0 == '':
  tit0 = "Not Available"
 return tit0

player = mpv.MPV()
player.play('https://laterna.kafeneio.social/public/kafeneio')
player.wait_for_playback()
tit0 = "Not Available"
while tit0 == "Not Available":
 try:
  fil_format = player.file_format
  tit0 = title0(player).replace("-", " ")
  fil_nam = tit0+'.'+fil_format
 except:
  time.sleep(1)
player.stream_record = fil_nam
time.sleep(30)

此脚本将以正确的格式和“icy-title”名称保存文件到与 py 脚本相同的目录中。

© www.soinside.com 2019 - 2024. All rights reserved.