----- Forwarded message from [email protected] -----
     Date: Wed, 18 Feb 2009 12:56:56 +0100
     From: Muhammad Ali <[email protected]>
Reply-To: Muhammad Ali <[email protected]>
  Subject: Re: [libav-user] Encoding MPEG2VIDEO
       To: Bruce Weir <[email protected]>


Thanks you respnose me.
I am using the same way as define in Example but the output is not correct.
its lost are the image and show only colores. code only encode the 60
frames and write in the file.. when i run the encode video or decode
the video its its work but not show the original image.. whats your
suggestion whats i do..

"code of developing he image frame and writing in file"

pCodeCtx=avcodec_alloc_context();
     AVFrame *frame;
     frame=avcodec_alloc_frame();
     //Set the codeing attributes...
     pCodeCtx->bit_rate=40000;
     pCodeCtx->width=352;
     pCodeCtx->height=288;
     pCodeCtx->time_base=(AVRational){1,25};
     pCodeCtx->gop_size=10;
     //pCodeCtx->max_b_frames=1;

     pCodeCtx->pix_fmt=PIX_FMT_YUV420P;

     //Open The Code
     if(avcodec_open(pCodeCtx,codec)<0)
     printf("Codec in not Open\n");
    //Open the  File
     f = fopen(outfile, "wb");
      if (!f) {
          fprintf(stderr, "could not open %s\n",outfile);
          exit(1);
      }
      printf("file is opend\n");
     int  j, out_size, size, x, y, outbuf_size;
     uint8_t *outbuf, *frame_buf;

     outbuf_size=100000;
     outbuf=malloc(outbuf_size);
     size=pCodeCtx->width *pCodeCtx->height;
     frame_buf=malloc((size*3)/2);

     frame->data[0]=frame_buf;
     frame->data[1]=frame->data[0]+size;
     frame->data[2]=frame->data[1]+size/4;

      frame->linesize[0] = pCodeCtx->width;
      frame->linesize[1] = pCodeCtx->width / 2;
      frame->linesize[2] = pCodeCtx->width / 2;
   //Encode vide Loop
      for(j=0;j<60;j++)
      {
             for(y=0;y<pCodeCtx->height;y++) {
              for(x=0;x<pCodeCtx->width;x++) {
                  frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
              }
             }
             /* Cb and Cr */
              for(y=0;y<pCodeCtx->height/2;y++) {
               for(x=0;x<pCodeCtx->width/2;x++) {
                   frame->data[1][y * frame->linesize[1] + x] = 128 +  
y + i * 2;
                   frame->data[2][y * frame->linesize[2] + x] =  64 +  
x + i * 5;
                }
             }
             /* encode the image */
          out_size = avcodec_encode_video(pCodeCtx, outbuf, outbuf_size,frame);
          printf("encoding frame %3d (size=%5d)\n", j, out_size);
          fwrite(outbuf, 1, out_size, f);
          //printf("-----frme write in file \n");


Thanks you resopnse me



Quoting Bruce Weir <[email protected]>:

> Easiest thing to do is to work your way through the example in
>
> ffmpeg/libavcodec/apiexample.c
>
> You should be able to build and run it, and then modify it as required.
>
> Without looking at your code, it is hard to work out your bug, but    
> at a guess you should probably pay attention to how you are packing   
>  your AVFrames before encoding.
>
> ________________________________
>
> From: [email protected] on behalf of Muhammad Ali
> Sent: Wed 18/02/2009 09:06
> To: [email protected]
> Subject: [libav-user] Encoding MPEG2VIDEO
>
>
>
>
> Hello all,
>
>
>
> I'm having troubles creating mpeg2 files. from the MPG format video.
> I am using the avcodec example to encode the video.. its run properly.
> but when i run the decode the encode video its lost original video
> picture .. we can see onle differents colors..
>
> Can someone please advise me on what parameters should I set in the
> AVCodecContext for encoding an mpeg2? Are there any caveats that I
> should be aware of?
>
> I am new  in using the ffmpeg ...so please advise me  the whats i do
> and if you have any metrial about this please advise  me..
>
> Thanks in Advance
> --
> Zeshan ALI
> Phd Student
> Tu-Braunschewig Germany
>
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
>
>
> http://www.bbc.co.uk/
> This e-mail (and any attachments) is confidential and may contain    
> personal views which are not the views of the BBC unless    
> specifically stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in    
> reliance on it and notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
>
>



-- 
Zeshan ALI
Phd Student
Tu-Braunschewig Germany



----- End forwarded message -----


-- 
Zeshan ALI
Phd Student
Tu-Braunschewig Germany

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to