2015-08-03 2 views
0

En FFmpeg, il y a un paramètre "-listen" afin d'écouter un port spécifié:écoute de port FFmpeg/Libav

# Server side (receiving): 
ffmpeg -listen 1 -enter code herei http://server:port -c copy somefile.ogg 

https://www.ffmpeg.org/ffmpeg-protocols.html#toc-http

Je voudrais utiliser cette commande C++ avec Libav (comme FFMpeg a été déplacé vers Libav).

Pour écouter un port, quelle méthode Libav dois-je utiliser?

+3

"FFMPEG a été déplacé vers Libav". Cette déclaration n'a aucun sens. – LordNeckbeard

Répondre

0

Je résolu le problème par:

void listen(const unsigned int port) { 

const int TIMEOUT = 600000; 

// check if webservice is already listening 
if (!m_listening) { 

    m_listening = true; 

    // Format specification: tcp://hostname:port[?options] 
    // See: https://www.ffmpeg.org/ffmpeg-protocols.html#tcp 

    std::stringstream ss; 
    ss << "tcp://localhost:" << port << "?listen=1" << "?listen_timeout=" << TIMEOUT << "?timeout=" << TIMEOUT * 1000; 
    const std::string publishingPointURI = ss.str(); 
    avformat_network_init(); 
    if (avformat_open_input(&m_stream, publishingPointURI.c_str(), NULL, NULL) != 0) { 
      throw Exception(
        "Unable to buffer stream received from " + publishingPointURI + ""); 
    } 

    m_listening = false; 
}