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

VB.NET Discussion :

Télécharger une vidéo avec le protocle RTMP


Sujet :

VB.NET

  1. #1
    Membre éclairé Avatar de -N4w4k-
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2011
    Messages
    545
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2011
    Messages : 545
    Points : 801
    Points
    801
    Par défaut Télécharger une vidéo avec le protocle RTMP
    Bonjour,

    j'essaie depuis quelques heures de trouver la syntaxe à utiliser pour télécharger une vidéo avec le protocole RTMP mais je n'y parviens pas..

    J'utilise cette ligne de code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Shell("rtmpdump.exe -r """ + adresse + """ -o """ + filename + ".flv""", AppWinStyle.NormalFocus, True)
    mais j'obtiens toujours l'erreur que vous pouvez voir en pièce jointe.

    Est ce que vous auriez une proposition connaissant les données de cette page?

    Merci pour votre aide.
    Images attachées Images attachées  

  2. #2
    Membre éclairé Avatar de -N4w4k-
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2011
    Messages
    545
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2011
    Messages : 545
    Points : 801
    Points
    801
    Par défaut
    Je vous met mon code en entier, si vous avez envie de tester..
    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
        Sub Main()
            Try
                Download("http://hidan.eklablog.com/bleach-169-vostfr-a1467816", "Bleach 169")
            Catch ex As Exception
                Console.WriteLine("Error dl")
                Console.ReadKey()
            End Try
     
        End Sub
     
     
        Sub Download(ByVal link As String, ByVal filename As String)
     
            Dim code_source As String = Nothing
     
            'recherche code source de la page
            Dim uri As New Uri(link)
            Try
                Dim request As WebRequest = WebRequest.Create(uri)
                Dim response As WebResponse = request.GetResponse()
                Dim sr As StreamReader = Nothing
                Try
                    sr = New StreamReader(response.GetResponseStream())
                    code_source = sr.ReadToEnd()
                Catch
                    code_source = Nothing
                Finally
                    If Not sr Is Nothing Then
                        sr.Close()
                    End If
                End Try
            Catch ex As Exception
                code_source = Nothing
            End Try
     
            'code source trouvé
            If code_source IsNot Nothing Then
                'code source parsing
                Dim m As New Regex("(http://video.rutube.ru/)[a-z0-9]*")
                Dim r = m.Match(code_source)
                Dim videoURL = r.Captures(0).ToString
                Dim trackInfoURL As String = videoURL.Replace("http://video.rutube.ru/", "http://rutube.ru/trackinfo/") & ".html"
     
                'trackinfo parsing
                Dim xmlDoc As New XmlDocument
                xmlDoc.Load(trackInfoURL)
                Dim VideoBalancerNode As XmlNode = xmlDoc.GetElementsByTagName("video_balancer")(0)
                Dim ruDataURL As String = VideoBalancerNode.InnerText
     
                'rudata parsing
                xmlDoc.Load(ruDataURL)
                Dim baseUrlNode = xmlDoc.GetElementsByTagName("baseURL")(0)
                Dim baseURL As String = baseUrlNode.InnerText
                Dim mediaNode = xmlDoc.GetElementsByTagName("media")(0)
                Dim media As String = mediaNode.Attributes("url").Value
     
                'telechargement video
                Dim adresse = baseURL + media
     
                Shell("rtmpdump.exe -o """ + filename + ".flv"" -r """ + adresse + """ - w ""http://rutube.ru/player.swf""", , True)
                Console.ReadKey()
            End If
        End Sub
    Ca me tend un peu, je pense qu'après cette fameuse ligne je n'ai plus rien à faire..

  3. #3
    Membre régulier

    Profil pro
    Inscrit en
    Avril 2009
    Messages
    69
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 69
    Points : 78
    Points
    78
    Par défaut bonjour, bonjour,
    Concernant tes vidéos as tu une URL complète (qui fonctionne sous un explorateur internet ou eventuelle sous vlc????)

  4. #4
    Membre éclairé Avatar de -N4w4k-
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2011
    Messages
    545
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2011
    Messages : 545
    Points : 801
    Points
    801
    Par défaut
    Par exemple cette adresse ou celle la (qui fonctionnent sur le navigateur internet grâce à un player flash).

  5. #5
    Membre régulier

    Profil pro
    Inscrit en
    Avril 2009
    Messages
    69
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 69
    Points : 78
    Points
    78
    Par défaut hélas, hélas....
    J'ai essayé de récupérer l'adresse du flux RTMP en vain.....

    Mais bon... Peut être que je m'y prends mal....

    En tout état de cause, je joins le code qui pour moi fonctionne ( rtmp://stream2.lgdf.yacast.net/gulli_replay/12015VOD258.mp4 = Récupération des émissions de gulli....)

    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
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
     
     
    // RTP Protocol.cpp*: définit le point d'entrée pour l'application console.
    //
     
    #include "stdafx.h"
    #include "windows.h"
    #include "stdio.h"
    #include "time.h"
    bool Connection_Internet=FALSE;
    LPCWSTR TOOL_Convert_to_LPC(char *ctl);
    SOCKET IDP;
    #define RD_SUCCESS		0
    #define RD_FAILED		1
    #define RD_INCOMPLETE		2
    #define RD_NO_CONNECT		3
    bool BETA_MODE=FALSE;
    #define IR_SIZE_PAGE	10000
    #define DEF_TIMEOUT	30	/* seconds */
    #define DEF_BUFTIME	(10 * 60 * 60 * 1000)	/* 10 hours default */
     
    char *IPage[20];
    char Temporary[1024];
    #include "rtmp.h"
    FILE *file;
     
      int nStatus = 1;
      double percent = 0;
     
      int nSkipKeyFrames = 0;	// skip this number of keyframes when resuming
     
      int bOverrideBufferTime = FALSE;	// if the user specifies a buffer time override this is true
      int bStdoutMode = TRUE;	// if true print the stream directly to stdout, messages go to stderr
      int bResume = FALSE;		// true in resume mode
      uint32_t dSeek = 0;		// seek position in resume mode, 0 otherwise
      uint32_t bufferTime = DEF_BUFTIME;
     
      // meta header and initial frame for the resume mode (they are read from the file and compared with
      // the stream we are trying to continue
      char *metaHeader = 0;
      uint32_t nMetaHeaderSize = 0;
     
      // video keyframe for matching
      char *initialFrame = 0;
      uint32_t nInitialFrameSize = 0;
      int initialFrameType = 0;	// tye: audio or video
     
      AVal hostname = { 0, 0 };
      AVal playpath = { 0, 0 };
      AVal subscribepath = { 0, 0 };
      AVal usherToken = { 0, 0 }; //Justin.tv auth token
      int port = -1;
      int protocol = RTMP_PROTOCOL_UNDEFINED;
      int retries = 0;
      int bLiveStream = FALSE;	// is it a live stream? then we can't seek/resume
      int bHashes = FALSE;		// display byte counters not hashes by default
     
      long int timeout = DEF_TIMEOUT;	// timeout connection after 120 seconds
      uint32_t dStartOffset = 0;	// seek position in non-live mode
      uint32_t dStopOffset = 0;
      RTMP rtmp = { 0 };
     
      AVal swfUrl = { 0, 0 };
      AVal tcUrl = { 0, 0 };
      AVal pageUrl = { 0, 0 };
      AVal app = { 0, 0 };
      AVal auth = { 0, 0 };
      AVal swfHash = { 0, 0 };
      uint32_t swfSize = 0;
      AVal flashVer = { 0, 0 };
      AVal sockshost = { 0, 0 };
    int Download(RTMP * rtmp,		// connected RTMP object
    	 FILE * file, uint32_t dSeek, uint32_t dStopOffset, double duration, int bResume, char *metaHeader, uint32_t nMetaHeaderSize, char *initialFrame, int initialFrameType, uint32_t nInitialFrameSize, int nSkipKeyFrames, int bStdoutMode, int bLiveStream, int bHashes, int bOverrideBufferTime, uint32_t bufferTime, double *percent);
    int DownloadODC(RTMP * rtmp);
    int DownloadB(RTMP * rtmp,		// connected RTMP object
    	 FILE * file, uint32_t dSeek, uint32_t dStopOffset, double duration, int bResume, char *metaHeader, uint32_t nMetaHeaderSize, char *initialFrame, int initialFrameType, uint32_t nInitialFrameSize, int nSkipKeyFrames, int bStdoutMode, int bLiveStream, int bHashes, int bOverrideBufferTime, uint32_t bufferTime, double *percent);
    #include "Internet.cpp"
    //typedef void RTMP_Init(RTMP *r);
    RTMPPacket rtmpack;
    time_t Ref_Time=0,CTime=0,Cursor=0,ITime=0,SynopsisTime=0,BGTime=0;
    long duration=1; 		
    long Essai=0;
    long ATC=0;
     long NTC=0;
     
     
    typedef void ORTMP_INIT(RTMP *r);
    //typedef void ORTMP_INIT(RTMP *r);
    typedef int ORTMP_LIBVERSION(void);
     
    typedef RTMP *ORTMP_ALLOC(void);
     
    typedef int ORTMP_CONNECT(RTMP *r, RTMPPacket *cp);
     
    typedef int ORTMP_SETUPURL(RTMP *r, char *url);
     
    typedef int ORTMP_CONNECTSTREAM(RTMP *r, int seekTime);
     
    typedef int ORTMP_READ(RTMP *r, char *buf, int size);
     
    typedef int ORTMP_PARSEURL(const char *url, int *protocol, AVal *host,unsigned int *port, AVal *playpath, AVal *app);
     
    typedef void ORTMP_SETUPSTREAM(RTMP *r, int protocol,AVal *hostname,	unsigned int port,	AVal *sockshost,AVal *playpath,	AVal *tcUrl,AVal *swfUrl,AVal *pageUrl,	AVal *app,	AVal *auth,	AVal *swfSHA256Hash,uint32_t swfSize,AVal *flashVer,AVal *subscribepath,AVal *usherToken,int dStart,int dStop, int bLiveStream, long int timeout);
     
    typedef void ORTMP_SETBUFFERMS(RTMP *r, int size);
     
    typedef double ORTMP_GETDURATION(RTMP *r);
     
    typedef int ORTMP_ISCONNECTED(RTMP *r);
     
    typedef int ORTMP_SOCKET(RTMP *r);
     
    typedef int ORTMP_ISTIMEDOUT(RTMP *r);
     
    typedef void ORTMP_UPDATEBUFFERMS(RTMP *r);
     
    typedef void ORTMP_CLOSE(RTMP *r);
     
    ORTMP_ISCONNECTED * ORTMP_IsConnected;
     
    ORTMP_ISTIMEDOUT * ORTMP_IsTimedout;
     
    ORTMP_SETBUFFERMS * ORTMP_SetBufferMS ;
     
    ORTMP_UPDATEBUFFERMS * ORTMP_UpdateBufferMS;
     
    ORTMP_READ * ORTMP_Read;
     
    ORTMP_GETDURATION * ORTMP_GetDuration;
     
    int _tmain(int argc, _TCHAR* argv[]){
    HMODULE module;
     
    module = LoadLibrary(L"librtmp.dll");
     
        ORTMP_INIT * ORTMP_Init = (ORTMP_INIT *)GetProcAddress(module, "RTMP_Init");
        ORTMP_LIBVERSION * ORTMP_LibVersion = (ORTMP_LIBVERSION *)GetProcAddress(module, "RTMP_LibVersion");
        ORTMP_ALLOC * ORTMP_Alloc = (ORTMP_ALLOC *)GetProcAddress(module, "RTMP_Alloc");
    	ORTMP_SETUPURL * ORTMP_SetupURL = (ORTMP_SETUPURL *)GetProcAddress(module, "RTMP_SetupURL");
    	ORTMP_CONNECT * ORTMP_Connect = (ORTMP_CONNECT *)GetProcAddress(module, "RTMP_Connect");
    	ORTMP_CONNECTSTREAM * ORTMP_ConnectStream = (ORTMP_CONNECTSTREAM *)GetProcAddress(module, "RTMP_ConnectStream");
    	ORTMP_Read = (ORTMP_READ *)GetProcAddress(module, "RTMP_Read");
    	ORTMP_PARSEURL * ORTMP_ParseURL = (ORTMP_PARSEURL *)GetProcAddress(module, "RTMP_ParseURL");
    	ORTMP_SETUPSTREAM * ORTMP_SetupStream = (ORTMP_SETUPSTREAM *)GetProcAddress(module, "RTMP_SetupStream");
    	ORTMP_SetBufferMS = (ORTMP_SETBUFFERMS *)GetProcAddress(module, "RTMP_SetBufferMS");
    	ORTMP_GetDuration = (ORTMP_GETDURATION *)GetProcAddress(module, "RTMP_GetDuration");
    	ORTMP_IsConnected = (ORTMP_ISCONNECTED *)GetProcAddress(module, "RTMP_IsConnected");
    	ORTMP_SOCKET * ORTMP_Socket = (ORTMP_SOCKET *)GetProcAddress(module, "RTMP_Socket");
    	ORTMP_IsTimedout = (ORTMP_ISTIMEDOUT *)GetProcAddress(module, "RTMP_IsTimedout");
    ORTMP_UpdateBufferMS=(ORTMP_UPDATEBUFFERMS *)GetProcAddress(module,"RTMP_UpdateBufferMS");
    	ORTMP_CLOSE * ORTMP_Close = (ORTMP_CLOSE *)GetProcAddress(module, "RTMP_Close");
     
     
      uint32_t dSeek = 0;		// seek position in resume mode, 0 otherwise
      long duration = 0.0;
     
    char BUFFER[10240];
    InitWinsockV3();
    ORTMP_Alloc();
    ORTMP_Init(&rtmp);
     
       AVal parsedHost, parsedApp, parsedPlaypath;
    	    unsigned int parsedPort = 0;
    	    int parsedProtocol = RTMP_PROTOCOL_UNDEFINED;
     
    		if (!ORTMP_ParseURL
    		("rtmp://stream2.lgdf.yacast.net/gulli_replay/12015VOD258.mp4", &parsedProtocol, &parsedHost, &parsedPort,&parsedPlaypath, &parsedApp))
    	      {
     
    	      }
    	    else
    	      {
    		if (!hostname.av_len)
    		  hostname = parsedHost;
    		if (port == -1)
    		  port = parsedPort;
    		if (playpath.av_len == 0 && parsedPlaypath.av_len)
    		  {
    		    playpath = parsedPlaypath;
    		  }
    		if (protocol == RTMP_PROTOCOL_UNDEFINED)
    		  protocol = parsedProtocol;
    		if (app.av_len == 0 && parsedApp.av_len)
    		  {
    		    app = parsedApp;
    		  }
     
     
    		}
     
    		  ORTMP_SetupStream(&rtmp, protocol, &hostname, port, &sockshost, &playpath,
    		   &tcUrl, &swfUrl, &pageUrl, &app, &auth, &swfHash, swfSize,
    		   &flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout);
     
    		  long count=0;
     
     
     
    ORTMP_SetBufferMS(&rtmp, bufferTime);
    duration=1;
     
     
    while(Essai<3){
     if(Essai==1)file = fopen("c:\\ITWORKS.mp4", "w+b");
    ATC=GetTickCount();
    ORTMP_Connect(&rtmp, NULL);
    ORTMP_ConnectStream(&rtmp, dSeek);
     
     
    dSeek=DownloadODC(&rtmp);
     
      ORTMP_Close(&rtmp);
     
      Essai++;
      if(Essai>3)break;
    }
     if(Essai==1)fclose(file);
    	free(initialFrame);
          initialFrame = NULL;
     
     
     
    	printf("count : %d",count);
     
     
    return 0;
    }
     
     
    int DownloadODC(RTMP * rtmp){
     int32_t now=0, lastUpdate=0;
      int bufferSize = 256 * 1024;
      char *buffer;
      int nRead = 0;
      off_t size = 0;
      unsigned long lastPercent = 0;
      buffer = (char *) malloc(bufferSize);
     
     
    while(dSeek<=duration*1000){
    lastUpdate=GetTickCount(); 
    while(abs(now-lastUpdate)>10){
    now=GetTickCount();	
    nRead = ORTMP_Read(rtmp, buffer, bufferSize);
    duration=ORTMP_GetDuration(rtmp);
    dSeek=rtmp->m_read.timestamp;
    NTC=GetTickCount();
     
    printf("Duration %d/%d - - - %d\n\r",dSeek/1000,duration,(NTC-ATC)/1000);
     if (nRead > 0){
    	 dSeek=rtmp->m_read.timestamp;
    		if (Essai==1 && fwrite(buffer, sizeof(unsigned char), nRead, file) !=
    	      (size_t) nRead)
    	    {
    	      printf("%s: Failed writing, exiting!", __FUNCTION__);
    	      free(buffer);
    	      return -2;
    	    }
    	  size += nRead;
     
     }
    else return dSeek;
    }
    }
     
    return 0;
    }
     
     
    int DownloadB(RTMP * rtmp,		// connected RTMP object
    	 FILE * file, uint32_t dSeek, uint32_t dStopOffset, double duration, int bResume, char *metaHeader, uint32_t nMetaHeaderSize, char *initialFrame, int initialFrameType, uint32_t nInitialFrameSize, int nSkipKeyFrames, int bStdoutMode, int bLiveStream, int bHashes, int bOverrideBufferTime, uint32_t bufferTime, double *percent)	// percentage downloaded [out]
    {
    	bool STOPIT=0;
      int32_t now=0, lastUpdate=0;
      int bufferSize = 64 * 1024;
      char *buffer;
      int nRead = 0;
      off_t size = 0;
      unsigned long lastPercent = 0;
      buffer = (char *) malloc(bufferSize);
      while(STOPIT==0){
     
      nRead = ORTMP_Read(rtmp, buffer, bufferSize);
    if(nRead==0)Sleep(2000);
    printf("%d / %d\r\n\r",nRead, size);  
     
      if (nRead > 0)
    	{
    dSeek=rtmp->m_read.timestamp;
    		if (fwrite(buffer, sizeof(unsigned char), nRead, file) !=
    	      (size_t) nRead)
    	    {
    	      printf("%s: Failed writing, exiting!", __FUNCTION__);
    	      free(buffer);
    	      return -2;
    	    }
    	  size += nRead;
     
    	  }
    	  else STOPIT=1;
      }
    return 0;
    }
    int Download(RTMP * rtmp,		// connected RTMP object
    	 FILE * file, uint32_t dSeek, uint32_t dStopOffset, double duration, int bResume, char *metaHeader, uint32_t nMetaHeaderSize, char *initialFrame, int initialFrameType, uint32_t nInitialFrameSize, int nSkipKeyFrames, int bStdoutMode, int bLiveStream, int bHashes, int bOverrideBufferTime, uint32_t bufferTime, double *percent)	// percentage downloaded [out]
    {
      int32_t now=0, lastUpdate=0;
      int bufferSize = 64 * 1024;
      char *buffer;
      int nRead = 0;
      off_t size = ftell(file);
      unsigned long lastPercent = 0;
     
      rtmp->m_read.timestamp = dSeek;
     
      *percent = 0.0;
     
      if (rtmp->m_read.timestamp)
        {
          printf("Continuing at TS: %d ms\n\r", rtmp->m_read.timestamp);
        }
     
      if (bLiveStream)
        {
          printf("Starting Live Stream\n\r");
        }
      else
        {
          // print initial status
          // Workaround to exit with 0 if the file is fully (> 99.9%) downloaded
          if (duration > 0)
    	{
    	  if ((double) rtmp->m_read.timestamp >= (double) duration * 999.0)
    	    {
    	      printf("Already Completed at: %.3f sec Duration=%.3f sec\n\r",
    			(double) rtmp->m_read.timestamp / 1000.0,
    			(double) duration / 1000.0);
    	      return 1;
    	    }
    	  else
    	    {
    	      *percent = ((double) rtmp->m_read.timestamp) / (duration * 1000.0) * 100.0;
    	      *percent = ((double) (int) (*percent * 10.0)) / 10.0;
    	      printf("%s download at: %.3f kB / %.3f sec (%.1f%%)\n\r",
    			bResume ? "Resuming" : "Starting",
    			(double) size / 1024.0, (double) rtmp->m_read.timestamp / 1000.0,
    			*percent);
    	    }
    	}
          else
    	{
    	  printf("%s download at: %.3f kB\n\r",
    		    bResume ? "Resuming" : "Starting",
    		    (double) size / 1024.0);
    	}
        }
     
      if (dStopOffset > 0)
        printf("For duration: %.3f sec\n\r", (double) (dStopOffset - dSeek) / 1000.0);
     
      if (bResume && nInitialFrameSize > 0)
        rtmp->m_read.flags |= RTMP_READ_RESUME;
      rtmp->m_read.initialFrameType = initialFrameType;
      rtmp->m_read.nResumeTS = dSeek;
      rtmp->m_read.metaHeader = metaHeader;
      rtmp->m_read.initialFrame = initialFrame;
      rtmp->m_read.nMetaHeaderSize = nMetaHeaderSize;
      rtmp->m_read.nInitialFrameSize = nInitialFrameSize;
     
      buffer = (char *) malloc(bufferSize);
     
      now = GetTickCount();
      lastUpdate = now - 1000;
     
      do{
          nRead = ORTMP_Read(rtmp, buffer, bufferSize);
          //RTMP_LogPrintf("nRead: %d\n\r", nRead);
          if (nRead > 0)
    	{
    	  if (fwrite(buffer, sizeof(unsigned char), nRead, file) !=
    	      (size_t) nRead)
    	    {
    	      printf("%s: Failed writing, exiting!", __FUNCTION__);
    	      free(buffer);
    	      return -2;
    	    }
    	  size += nRead;
     
    	  if (duration <= 0)	// if duration unknown try to get it from the stream (onMetaData)
    	    duration = ORTMP_GetDuration(rtmp);
     
    	  if (duration > 0){
    	      // make sure we claim to have enough buffer time!
    	      if (!bOverrideBufferTime && bufferTime < (duration * 1000.0))		{
    		  bufferTime = (uint32_t) (duration * 1000.0) + 5000;	// extra 5sec to make sure we've got enough
     
    	  printf("Detected that buffer time is less than duration, resetting to: %dms",bufferTime);
    		  ORTMP_SetBufferMS(rtmp, bufferTime);
    		  ORTMP_UpdateBufferMS(rtmp);
    		}
    	      *percent = ((double) rtmp->m_read.timestamp) / (duration * 1000.0) * 100.0;
    	      *percent = ((double) (int) (*percent * 10.0)) / 10.0;
    	      if (bHashes)		{
    		  if (lastPercent + 1 <= *percent)		    {
    //		      RTMP_LogStatus("#");
    		      lastPercent = (unsigned long) *percent;
    		    }
    		}
    	      else	{
     
    		  if (abs(now - lastUpdate) > 200)		    {
    		      printf("\r%.3f kB / %.2f sec (%.1f%%)",(double) size / 1024.0,(double) (rtmp->m_read.timestamp) / 1000.0, *percent);
    		      lastUpdate = now;
    		    }
    		}
    	    }
    	  else	    {
     
    	      if (abs(now - lastUpdate) > 200)		{
    		  if (bHashes)
    		    printf("#");
    		  else
    		    printf("\r%.3f kB / %.2f sec", (double) size / 1024.0,
    			      (double) (rtmp->m_read.timestamp) / 1000.0);
    		  lastUpdate = now;
    		}
    	    }
    	  }
    #ifdef _DEBUG
          else	{
     
     
    	  }
    #endif
     
      }
      while ( nRead > -1 && ORTMP_IsConnected(rtmp));
      free(buffer);
      if (nRead < 0)
        nRead = rtmp->m_read.status;
     
      /* Final status update */
      if (!bHashes)
        {
          if (duration > 0)
    	{
    	  *percent = ((double) rtmp->m_read.timestamp) / (duration * 1000.0) * 100.0;
    	  *percent = ((double) (int) (*percent * 10.0)) / 10.0;
    printf("\r%.3f kB / %.2f sec (%.1f%%)",(double) size / 1024.0, (double) (rtmp->m_read.timestamp) / 1000.0, *percent);
    	}
          else
    	{
    printf("\r%.3f kB / %.2f sec", (double) size / 1024.0, (double) (rtmp->m_read.timestamp) / 1000.0);
    	}
      }
     
     
     
      if (bResume && nRead == -2)
        {
          printf("Couldn't resume FLV file, try --skip %d\n\n\r",nSkipKeyFrames + 1);
          return -1;
        }
     
      if (nRead == -3)
        return 0;
    /*
      if ((duration > 0 && *percent < 99.9)  || nRead < 0
          || ORTMP_IsTimedout(rtmp))
        {
          return -666;
        }*/
     
      return 0;
    }

    Voici le bout de code, qui est un melting pot de l'ensemble des tentatives de fonctionnement......

    Au cas ou....

  6. #6
    Membre éclairé Avatar de -N4w4k-
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2011
    Messages
    545
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2011
    Messages : 545
    Points : 801
    Points
    801
    Par défaut
    Oula du C++, ça fait un bail que j'en ai pas fait ^^

    Apparemment tu utilise une DLL pour effectuer le traitement (rtmp->..). J'ai bien téléchargé une DLL (librtmp.dll je crois) dans le pack RTMP mais j'étais plus parti sur l'utilisation de rtmpdump.exe ayant trouvé beaucoup plus d'info dessus sur le net. J'ai bien entendu essayé d'intégrer la DLL au projet mais en vain (composant COM invalide !?!).

    Comme tu dis, au cas ou.. Si j'arrive à utiliser la DLL ça m'aidera sûrement.

    Merci pour ton aide

  7. #7
    Membre éclairé Avatar de -N4w4k-
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2011
    Messages
    545
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2011
    Messages : 545
    Points : 801
    Points
    801
    Par défaut
    Je viens de voir que l'url dont se sert IDM pour telecharger cette video est bien la même que j'obtiens.. mais comment utiliser cette url??

    J'ai aussi lu que l'erreur que j'obtiens vient du fait qu'il y aurait une redirection..

    Personne n'a d'idée ?
    Images attachées Images attachées  

Discussions similaires

  1. [Video] télécharger une vidéo
    Par WELCOMSMAIL dans le forum Vidéo
    Réponses: 27
    Dernier message: 27/07/2013, 17h19
  2. Détecter la taille d'une vidéo avec PHP
    Par Al3x dans le forum Bibliothèques et frameworks
    Réponses: 3
    Dernier message: 28/03/2007, 09h38
  3. Réponses: 13
    Dernier message: 08/11/2006, 23h34
  4. Réponses: 11
    Dernier message: 15/09/2006, 19h39
  5. [MFC] mixer une vidéo avec un bitmap
    Par Rafoo dans le forum MFC
    Réponses: 5
    Dernier message: 15/09/2006, 15h27

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