FFmpeg、Icecast和元数据

FFmpeg、Icecast和元数据,ffmpeg,metadata,icecast,Ffmpeg,Metadata,Icecast,我通过以下方式(声卡线路输入)将FFmpeg流传输到Windows计算机上的Icecast服务器: 这样行 但是我注意到一个Icecast统计数据,FFmpeg不向Icecast发送“音频信息”元数据,而edcast/altacast等则发送它。当FFmpeg被强制发送时,edcast/altacast不发送“用户代理” 我是否让FFmpeg向Icecast发送“音频信息”元数据?无法让它从FFmpeg发送每曲目元数据。您必须使用另一个脚本在带外发送元数据更新。对于MP3,这无法工作,因为MP3

我通过以下方式(声卡线路输入)将FFmpeg流传输到Windows计算机上的Icecast服务器:

这样行

但是我注意到一个Icecast统计数据,FFmpeg不向Icecast发送“音频信息”元数据,而edcast/altacast等则发送它。当FFmpeg被强制发送时,edcast/altacast不发送“用户代理”


我是否让FFmpeg向Icecast发送“音频信息”元数据?

无法让它从FFmpeg发送每曲目元数据。您必须使用另一个脚本在带外发送元数据更新。

对于MP3,这无法工作,因为MP3流不支持正确的元数据。您将需要一个额外的脚本来调用Icecasts元数据更新端点


对于Ogg,这可以工作,但afaik不能使用FFmpeg,因为无法触发它添加元数据并启动新的链接Ogg“段”。

无法评论,但这里是一个开始

/**
 * Please be aware. This gist requires at least PHP 5.4 to run correctly.
 * Otherwise consider downgrading the $opts array code to the classic "array" syntax.
 */
function getmp3StreamTitle($streamingUrl, $interval = 19200)
{
    $needle = 'StreamTitle=';
    $ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36';
    $opts = array('http' => array(
        'method' => 'GET',
        'header' => 'Icy-MetaData: 1',
        'user_agent' => $ua
    ));

    $context = stream_context_create($opts);

    $stream = fopen($streamingUrl, 'r', false, $context);
    if(!$stream) throw new Exception("Unable to open stream [{$streamingUrl}]");

    while(true) {
        $buffer = stream_get_contents($stream, $interval);
        if($buffer === false) throw new Exception('Could not read from stream.');

        if(strpos($buffer, $needle) !== false)
        {
            $text = explode($needle, $buffer)[1];
            $songtext = substr($text, 1, strpos($text, ';') - 2);
            break;
        }
    }

    fclose($stream);

    return $songtext;
}

ini_set('display_errors', 1);
header('Content-type: application/json');
/**
 * Please be aware. This gist requires at least PHP 5.4 to run correctly.
 * Otherwise consider downgrading the $opts array code to the classic "array" syntax.
 */
function getmp3StreamTitle($streamingUrl, $interval = 19200)
{
    $needle = 'StreamTitle=';
    $ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36';
    $opts = array('http' => array(
        'method' => 'GET',
        'header' => 'Icy-MetaData: 1',
        'user_agent' => $ua
    ));

    $context = stream_context_create($opts);

    $stream = fopen($streamingUrl, 'r', false, $context);
    if(!$stream) throw new Exception("Unable to open stream [{$streamingUrl}]");

    while(true) {
        $buffer = stream_get_contents($stream, $interval);
        if($buffer === false) throw new Exception('Could not read from stream.');

        if(strpos($buffer, $needle) !== false)
        {
            $text = explode($needle, $buffer)[1];
            $songtext = substr($text, 1, strpos($text, ';') - 2);
            break;
        }
    }

    fclose($stream);

    return $songtext;
}

ini_set('display_errors', 1);
header('Content-type: application/json');