salut
j'essaye de faire afficher deux video dans une meme fenetre sdl
voici mon code
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
static void* invite1()
{    
                   av_register_all();
       initSDL();
            gtk_widget_show_all(conferencewindow);
 
               if(av_open_input_file(&pFormatCtx1, "2.mpg", NULL, 0,NULL)!=0)
                 {printf("Couldn't open file");
                  return NULL; // Couldn't open file
                 } 
 
 
  // Retrieve stream information
               if(av_find_stream_info(pFormatCtx1)<0)
                {   printf("Couldn't find stream information");
                    return NULL; // Couldn't find stream information
                 }
     printf("\n*************************** biterate : %d", pFormatCtx1->bit_rate);
     // Dump information about file onto standard error
     dump_format(pFormatCtx1, 0,  "2.mpg", 0);
 
    // Find the first video stream
    videoStream1=-1;
    for(i1=0; i1<pFormatCtx1->nb_streams; i1++)
      {
          if(pFormatCtx1->streams[i1]->codec->codec_type==CODEC_TYPE_VIDEO) 
            {
                videoStream1=i1;
                break;
            }
     }
   if(videoStream1==-1)
     {   printf("Didn't find a video stream");
          return NULL; // Didn't find a video stream
     }
  printf("\n *****Find the first video stream th2 \n");
  // Get a pointer to the codec context for the video stream
  pCodecCtx1=pFormatCtx1->streams[videoStream1]->codec;
            // Find the decoder for the video stream
  pCodec1=avcodec_find_decoder(pCodecCtx1->codec_id);
   if(pCodec1==NULL) 
     {
              fprintf(stderr, "Unsupported codec!\n");
              return NULL; // Codec not found
     }
 
  // Open codec
           if(avcodec_open(pCodecCtx1, pCodec1)<0)
             return NULL; // Could not open codec
   printf("\n *****Open codec th2 \n");
  // Allocate video frame
           pFrame1=avcodec_alloc_frame();
 
  // Make a screen to put our video
           #ifndef __DARWIN__
        screen1 = SDL_SetVideoMode(pCodecCtx1->width, pCodecCtx1->height, 0, 0);
 
        #else
        screen1 = SDL_SetVideoMode(pCodecCtx1->width, pCodecCtx1->height, 24, 0);
 
        #endif
   printf("\n *****screan th2 \n");
         if(!screen1) 
            {
            fprintf(stderr, "SDL: could not set video mode - exiting\n");
            exit(1);
            }
    printf("\n *****screan2 th2 \n");
  // Allocate a place to put our YUV image on that screen
          bmp1 = SDL_CreateYUVOverlay(pCodecCtx1->width,
				 pCodecCtx1->height,
				 SDL_YV12_OVERLAY,
				 screen1);
 
       printf("\n *****bmp th2 \n");
  // Read frames and save first five frames to disk
          i1=0;
          while(av_read_frame(pFormatCtx1, &packet1)>=0) 
            { printf("\n *****whileth2 \n");
            // Is this a packet from the video stream?
            if(packet1.stream_index==videoStream1) 
            {  printf("\n *****acket from the video stream  th2 \n");
                // Decode video frame
                 avcodec_decode_video(pCodecCtx1, pFrame1, &frameFinished1, 
			   packet1.data, packet1.size);
                printf("\n *****Decode video frame  th2 \n");
                 // Did we get a video frame?
                 if(frameFinished1) 
                   {
	              SDL_LockYUVOverlay(bmp1);
 
	               AVPicture pict1;
	               pict1.data[0] = bmp1->pixels[0];
	               pict1.data[1] = bmp1->pixels[2];
	               pict1.data[2] = bmp1->pixels[1];
 
	               pict1.linesize[0] = bmp1->pitches[0];
	               pict1.linesize[1] = bmp1->pitches[2];
	               pict1.linesize[2] = bmp1->pitches[1];
                       printf("\n *****pict  th2 \n");
	// Convert the image into YUV format that SDL uses
	               int in1=img_convert(&pict1, PIX_FMT_YUV420P,(AVPicture *)pFrame1, pCodecCtx1->pix_fmt,  pCodecCtx1->width, pCodecCtx1->height);
 
	               SDL_UnlockYUVOverlay(bmp1);
	               rect1.x = 10;
	               rect1.y = 250;
	               rect1.w = pCodecCtx1->width;
	               rect1.h = pCodecCtx1->height;
                       printf("\n *****rect  th2 \n");
	               SDL_DisplayYUVOverlay(bmp1, &rect1);
      printf("\n *****display  th2 \n");
                    }
 
 
            }
//Free the packet that was allocated by av_read_frame
           av_free_packet(&packet1);
           SDL_PollEvent(&event1);
           switch(event1.type)
           {
           case SDL_QUIT:
           SDL_Quit();
           exit(0);
           break;
           default:
          break;
          }
         }
 
  // Free the YUV frame
  av_free(pFrame1);
 
  // Close the codec
  avcodec_close(pCodecCtx1);
 
  // Close the video file
  av_close_input_file(pFormatCtx1);
       //}
return NULL;
}
le premier video ça marche mais quand j'essaye d'afficher le deuxieme il signale l'erreur suivante : received an X Window System error.
rect1.x = 10;
rect1.y = 250;
rect1.w = pCodecCtx1->widget;
rect1.h = pCodecCtx1->height;

j'ai mis 250 parsque l'hauteur de video 1 est de 250
et quand j'ai mis
rect1.x = 0;
rect1.y = 0;
rect1.w = pCodecCtx1->width;
rect1.h = pCodecCtx1->height;

ça a marché mais les videos ont été superposés

ces deux fonctions je les assignés à des threads svp aidez moi