IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

Acquisition flux vidéo


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Ingénieur systèmes embarqués
    Inscrit en
    Janvier 2006
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur systèmes embarqués
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 81
    Par défaut Acquisition flux vidéo
    Bonjour

    Je veux acquérir, dans un logiciel fonctionnant sous Ubuntu, une source vidéo (Motion-JPEG ou MPEG-4) provenant dune caméra. Elle transmet son flux par une liaison IP (Ethernet) et je peux voir la vidéo sur mon navigateur en entrant l'IP locale de la caméra (http://192.168.0.xxx).

    Mon problème est que je ne sais pas du tout par ou commencer. J'ai cherché sur internet mais je ne trouve pas d'explications sur l'acquisition de flux vidéo ni sur l'établissement de connexions HTTP en C. Est-ce que quelqu'un aurait une expérience à ce sujet ou pourrait m'aiguiller vers des explications ?

    Merci d'avance.

  2. #2
    Modérateur
    Avatar de Obsidian
    Homme Profil pro
    Chercheur d'emploi
    Inscrit en
    Septembre 2007
    Messages
    7 484
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Chercheur d'emploi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2007
    Messages : 7 484
    Par défaut
    Citation Envoyé par F0ul Voir le message
    Je veux acquérir, dans un logiciel fonctionnant sous Ubuntu, une source vidéo (Motion-JPEG ou MPEG-4) provenant dune caméra. Elle transmet son flux par une liaison IP (Ethernet) et je peux voir la vidéo sur mon navigateur en entrant l'IP locale de la caméra (http://192.168.0.xxx).
    Si tu la vois depuis ton navigateur, c'est que le serveur de ta caméra (une Axis ?) agit comme un serveur web. Il est donc capable de reconnaître une requête HTTP, répondre en renvoyant les headers nécessaires et même construire une mini-page. Ça fait autant d'infos dont tu n'as pas besoin. En outre, si tu regardes les images en temps réel, c'est qu'il s'agit de streaming. Il faut donc un plug-in supplémentaire et un protocole - à identifier -.

    Commence par ouvrir le code source de la page de ton navigateur pour voir ce qui est réellement invoqué, et par quel biais (HTTP ou autre port).

  3. #3
    Membre confirmé
    Homme Profil pro
    Ingénieur systèmes embarqués
    Inscrit en
    Janvier 2006
    Messages
    81
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur systèmes embarqués
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 81
    Par défaut
    Effectivement c'est une caméra AXIS 211M. J'ai donc ouvert le code source de la page et je crois comprendre que la vidéo est appelée par cette fonction JavaScript :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    video('/mjpg/video.mjpg');
    Dont la déclaration est :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    function video(imagepath)
    {
      var resolution = 0
      var width = 0
      var height = 0
     
      if (imagepath.indexOf("resolution=") != -1) {
        var resStart = imagepath.indexOf("resolution=")
        var resStop = imagepath.indexOf("&", resStart)
        if (resStop == -1) resStop = imagepath.length
        resolution = imagepath.substring(resStart + 11, resStop);
        width = parseInt(resolution.substring(0, resolution.indexOf('x')));
        height = parseInt(resolution.slice((resolution.indexOf('x') + 1)));
      } else if (imagepath.indexOf("mpeg4") != -1) {
        width = 1280;
        height = 1024;
        resolution = width + 'x' + height;
      } else {
        width = 1280;
        height = 1024;
        resolution = width + 'x' + height;
      }
     
      if ((imagepath.indexOf("rotation=90") != -1) || (imagepath.indexOf("rotation=270") != -1)) {
        var aTempWidth = width;
        width = height;
        height = aTempWidth;
        resolution = width + 'x' + height;
      }
     
      if ('1' != '1') {
        width = width * 1;
        height = height * 1;
      }
      var width_height = 'width="' + width + '" height="' + height + '"';
      var use_activex = 0;
      var use_java = 0;
      var use_spush = 0;
      var use_flash = 0;
      var use_still = 0;
      var viewer = "still";
      var use_quicktime = 0;
     
      if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
        viewer = "activex";
      } else {
        viewer = "spush";
      }
     
      if (viewer.indexOf("activex") != -1) {
        use_activex = 1;
      }
      if (viewer.indexOf("spush") != -1) {
        use_spush = 1;
      }
      if (viewer.indexOf("flash") != -1) {
        use_flash = 1;
      }
      if (viewer.indexOf("quicktime") != -1) {
        use_quicktime = 1;
      }
      if (imagepath.indexOf("mpeg4") != -1) {
        if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
            use_quicktime = 0;
            use_activex = 1;
        } else {
          use_quicktime = 1;
          use_spush = 0;
          use_still = 0;
        }
      } else {
        if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
            use_quicktime = 0;
            use_activex = 1;
        } else {
          use_quicktime = 0;
          use_spush = 1;
          use_still = 0;
        }
      }
      if (viewer.indexOf("java") != -1) {
        if (imagepath.indexOf("mpeg4") == -1) {
          use_java = 1;
          use_activex = 0;
          use_spush = 0;
          use_flash = 0;
          use_still = 0;
          use_quicktime = 0;
        }
      }
      if ((viewer.indexOf("still") != -1) || !(use_activex || use_spush || use_flash || use_java || use_quicktime)) {
        if (imagepath.indexOf("mpeg4") == -1) {
          use_still = 1;
          use_quicktime = 0;
          use_spush = 0;
          use_activex = 0;
        } else {
          if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
            use_activex = 1;
          } else {
            use_quicktime = 1;
          }
        }
      }
      var agent = navigator.userAgent.toLowerCase();
      if (agent.indexOf("applewebkit/") != -1) {
        var pos = agent.indexOf("applewebkit/") + 12
        var webKitVersion = parseInt(agent.substring(pos, agent.indexOf(" ", pos)))
        if ((use_spush) && (webKitVersion < 416)) {
          use_java = 1;
          use_spush = 0;
        }
      }
      if (use_activex) {
        height = height + 54
        var notAuthorizedText = "The installation of the MPEG-4 Decoder has been disabled. Contact the Administrator of this AXIS 211M Network Camera.";
        var authorizedText = "Click here to install or upgrade the MPEG-4 Decoder.";
        var installDecoderText1 = "<b>MPEG-4 Decoder</b>, which enables streaming video in Microsoft Internet Explorer, has not been installed or could not be registered on this computer.";
        var installDecoderText2 = "To <a href=\"javascript:launch('/incl/license.shtml')\">install or upgrade</a> the MPEG-4 Decoder, you must have Administration rights on this computer and you must answer Yes <br>when asked if you wish to allow the installation. AXIS 211M Network Camera can also be configured to show still images.";
        var notAuthorizedAacText = "The installation of the AAC Decoder has been disabled. Contact the Administrator of this AXIS 211M Network Camera.";
        var authorizedAacText = "Click here to install or upgrade the AAC Decoder.";
        var installAacDecoderText1 = "<b>AAC Decoder</b>, which enables streaming AAC audio in Microsoft Internet Explorer, has not been installed or could not be registered on this computer.";
        var installAacDecoderText2 = "To <a href=\"javascript:launch('/incl/aac_license.shtml')\">install or upgrade</a> the AAC Decoder, you must have Administration rights on this computer and you must answer Yes <br>when asked if you wish to allow the installation.";
     
        var installText1 = "which enables streaming"; 
        var videoText = "video";
        var audioText = "audio";
        var installText2 = "in Microsoft Internet Explorer, has not been installed or could not be registered on this computer.";
        var installText3 = "To install or upgrade the";
        var installText4 = ", you must have Administration rights on this computer and you must answer Yes <br>when asked if you wish to allow the installation. AXIS 211M Network Camera can also be configured to show still images.";
        DrawAMC("AXIS 211M", "AXIS Media Control", height, width, imagepath, "DE625294-70E6-45ED-B895-CFFA13AEB044", "AMC.cab", "4,1,5,5", "yes", "", "", "1", "", "", "", "no", "no", "554", "no", installText1, videoText, installText2, installText3, installText4, "0", "", "");
        if (imagepath.indexOf("mpeg4") != -1) {
          InstallDecoder("AXIS 211M", "MPEG-4 Decoder", "c32fe9f1-a857-48b0-b7bf-065b5792f28d", "NotFound.cab", "2,0,4,0", "yes", notAuthorizedText, authorizedText, installDecoderText1, installDecoderText2);
          InstallFilter("AXIS 211M", "MPEG RTP Reader", "67B1A88A-B5D2-48B1-BF93-EB74D6FCB077", "1,6,3,6", "AMC.cab", installText1, videoText, installText2, installText3, installText4);
          InstallFilter("AXIS 211M", "Image Notify Component", "0173EEF5-1FDE-479C-9F24-34C3CB0B3243", "1,2,1,0", "AMC.cab", installText1, videoText, installText2, installText3, installText4);
        } 
          InstallFilter("AXIS 211M", "AudioComponent", "C111A91F-D4EC-4D22-8D27-C3BCB0389F43", "2,0,3,0", "AMC.cab", installText1, audioText, installText2, installText3, installText4);  
     
        document.write("<br>");
      }
     
      if (use_spush) {
        document.write('<table cellspacing=0 cellpadding=0 border=0><tr><td colspan=3 align="center">');
          var output = '<img id="stream" SRC="' + imagepath + '" ' + width_height;
          var view_NoImageTxt = "If no image is displayed, there might be too many viewers, or the browser configuration may have to be changed. See help for detailed instructions on how to do this."
          output += ' border=0 ALT="' + view_NoImageTxt + '">';
        output += '<br>';
        document.write(output);
        var fullImagePath = document.stream.src
        var stillImagePath = "/jpg/1/image.jpg"
        if (imagepath.indexOf("/axis-cgi/mjpg/video.cgi") != -1) {
          var searchStr = "/axis-cgi/mjpg/video.cgi"
          var replaceStr = "/jpg/1/image.jpg"
          var re = new RegExp(searchStr , "g")
          stillImagePath = imagepath.replace(re, replaceStr)
        }
     
        document.write('</td></tr>');
        document.write('<tr><td colspan=3 align="center" nowrap class="usedBoxStyle">');
        document.write('<table cellspacing=2 cellpadding=2 border=0 width="100%">');
        document.write('<tr height="32" id="videoItems" class="shownItems">');
        document.write("<td align=\"right\" width=\"40\"><a href=\"javascript:void(0)\" onClick=\"stopStartStream('" + stillImagePath + "')\"><img src=\"/pics/stop_button_27x27px.gif\" width=\"27\" height=\"27\" alt=\"Stop stream\" title=\"Stop stream\" border=\"0\"></a></td>");
        document.write("<td width=\"27\"><a href=\"javascript:void(0)\" onClick=\"stopStartStream('" + fullImagePath + "')\"><img src=\"/pics/play_button_27x27px.gif\" width=\"27\" height=\"27\" alt=\"Start stream\" title=\"Start stream\" border=\"0\"></a></td>");
        document.write("<td><a href=\"javascript:void(0)\" onClick=\"snapshot('" + stillImagePath + "')\"><img src=\"/pics/button_shot_gray_27x27px.gif\" width=\"27\" height=\"27\" alt=\"Snapshot\" title=\"Snapshot\" border=\"0\"></a></td></tr>");
        document.write('</table></td></tr></table>');
      }
     
      if (use_quicktime) {
        var DisplayWidth = width;
        var DisplayHeight = height  + 16;
        var rtspPort = "554";
        if (imagepath.indexOf("://") == -1) {
          var MediaURL = "rtsp://" + location.hostname + ":" + rtspPort + imagepath 
        }  else {
          var MediaURL = imagepath
        }
     
        var output = "";
        output  = '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width=' + DisplayWidth + ' height=' + DisplayHeight + ' CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">';
        output += '<param name="src" value="AxisMoviePoster.mov">';
        output += '<param name="autoplay" value="true">';
        output += '<param name="controller" value="true">';
        output += '<param name="qtsrc" value="' + MediaURL + '">';
        output += '<embed src="AxisMoviePoster.mov" width=' + DisplayWidth + ' height=' + DisplayHeight + ' qtsrc="' + MediaURL + '" autoplay="true" controller="true" target="myself" PLUGINSPAGE="http://www.apple.com/quicktime/download/"></embed>';
        output += '</OBJECT>';
        document.write(output);
      }
     
      if (use_flash) {
        var view_NeedFlashPluginTxt = "You need a Shockwave Flash plugin, get it from:"
        document.write('<EMBED src="/axis-cgi/mjpg/video.swf?resolution=' + resolution +'&camera=1" ' +
        'quality=high bgcolor=#000000 ' + width_height +
        ' TYPE="application/x-shockwave-flash" swLiveConnect=TRUE' +
        ' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' +
        '</EMBED>' +
        '<NOEMBED>' + view_NeedFlashPluginTxt +
        '<a href="http://www.macromedia.com/shockwave/download/">Macromedia</a>.' +
        '</NOEMBED><br>');
      }
     
      if (use_java) {
        var playerWidth = 1280
        var playerHeight = 1024 + 105
        if (playerWidth < 300)
          playerWidth = 300
     
        if (imagepath.indexOf("http") != -1) {
          var addrEnd = imagepath.indexOf("/", 8)
          var addr = imagepath.substring(0, addrEnd)
        } else {
          var addr = ""
        }
     
        document.write('<APPLET archive="ama.jar" codeBase="/java/ama" code="ama.MediaApplet" width="' + playerWidth + '" height="' + playerHeight + '">');
        document.write('<PARAM NAME="code" VALUE="ama.MediaApplet">');
        document.write('<PARAM NAME="archive" VALUE="ama.jar">');
        document.write('<PARAM NAME="codebase" VALUE="/java/ama">');
        document.write('<PARAM NAME="ama_cgi-path" VALUE="axis-cgi">');
        document.write('<PARAM NAME="cache_archive" VALUE="ama.jar">');
        document.write('<PARAM NAME="cache_version" VALUE="1.0.0.0">');
        document.write('<PARAM NAME="ama_plugins" VALUE="">');
        document.write('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">');
        document.write('<PARAM NAME="ama_url" VALUE="' + addr +
        '/axis-cgi/mjpg/video.cgi?camera=1&resolution=1280x1024">');
        document.write("Your browser does not support Java")
        document.write("</APPLET><br>");
      }
     
      if (use_still) {
        var picturepath = imagepath.replace(/video/, "image")
        picturepath = picturepath.replace(/mjpg/g, "jpg")
        picturepath = picturepath.replace(/rtsp/, "http")
        picturepath = picturepath.replace(/mpeg4/g, "jpg")
        picturepath = picturepath.replace(/media.amp/g, "image.jpg")
     
     
        document.write('<img SRC="' + picturepath + '" border=0 ' + width_height +'><br>');
      }
    }
    Mais je ne vois toujours pas comment récupérer le flux en utilisant C ... Est-ce que quelqu'un pourrait m'éclaircir ?

  4. #4
    Modérateur
    Avatar de Obsidian
    Homme Profil pro
    Chercheur d'emploi
    Inscrit en
    Septembre 2007
    Messages
    7 484
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Chercheur d'emploi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2007
    Messages : 7 484
    Par défaut
    Citation Envoyé par F0ul Voir le message
    la vidéo est appelée par cette fonction JavaScript :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    video('/mjpg/video.mjpg');
    
        output  = '<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width=' + DisplayWidth + ' height=' + DisplayHeight + ' CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">';
        output += '<param name="src" value="AxisMoviePoster.mov">';
        output += '<param name="autoplay" value="true">';
        output += '<param name="controller" value="true">';
        output += '<param name="qtsrc" value="' + MediaURL + '">';
        output += '<embed src="AxisMoviePoster.mov" width=' + DisplayWidth + ' height=' + DisplayHeight + ' qtsrc="' + MediaURL + '" autoplay="true" controller="true" target="myself" PLUGINSPAGE="http://www.apple.com/quicktime/download/"></embed>';
        output += '</OBJECT>';
    La fonction étudie le chemin qui est passé en argument, évalue les arguments le cas échéant et génère du code HTML adapté pour que ton navigateur aille lui-même lire la source, après avoir éventuellement installé le plug-in nécessaire. À toi, donc, de faire la même chose :

    Visiblement, le soft de la caméra est capable de présenter le tout sous plusieurs formes (dont applet Java), mais sous forme d'objet imbriqué (embed), il t'est présenté comme un fichier *.mov ordinaire. À toi, donc, d'aller le lire avec une requête.

    Si c'est pour automatiser l'opération, tu peux utiliser wget. Si tu tiens à le faire en C, tu peux voir du côté de la libcurl.

Discussions similaires

  1. Acquisition d'un flux vidéo en réseau
    Par kimlee dans le forum C++
    Réponses: 0
    Dernier message: 29/08/2007, 08h54
  2. Acquisition flux vidéo
    Par babozfr dans le forum DirectX
    Réponses: 7
    Dernier message: 17/01/2007, 19h46
  3. Récupérer un flux vidéo sur une MIDlet
    Par barcelona dans le forum Java ME
    Réponses: 1
    Dernier message: 11/10/2006, 20h02
  4. Afficher un flux vidéo
    Par niglo dans le forum C++Builder
    Réponses: 7
    Dernier message: 18/07/2006, 11h05
  5. [C#]visualiser le flux vidéo d'une caméra Axis
    Par nokta dans le forum Windows Forms
    Réponses: 6
    Dernier message: 21/11/2005, 19h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo