Recherche avancée

Médias (0)

Mot : - Tags -/protocoles

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (21)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Qu’est ce qu’un éditorial

    21 juin 2013, par

    Ecrivez votre de point de vue dans un article. Celui-ci sera rangé dans une rubrique prévue à cet effet.
    Un éditorial est un article de type texte uniquement. Il a pour objectif de ranger les points de vue dans une rubrique dédiée. Un seul éditorial est placé à la une en page d’accueil. Pour consulter les précédents, consultez la rubrique dédiée.
    Vous pouvez personnaliser le formulaire de création d’un éditorial.
    Formulaire de création d’un éditorial Dans le cas d’un document de type éditorial, les (...)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

Sur d’autres sites (3146)

  • ffmpeg ios, decoding rtsp stream causes memory leak

    5 août 2013, par Simone M

    i have an ios application that stream a rtsp video via network using ffmpeg library.
    In random time i have a crash without error message, the only message in console is "Memory warning".
    Using instrument i detect some memory leaks, this link a screenshot about error : http://vincentvega.it/iphone/video.png, i think the problem is in the point of code where i make uiimage to show on screen :

    - (void)convertFrameToRGB
    {
       sws_scale(img_convert_ctx,
                 pFrame->data,
                 pFrame->linesize,
                 0,
                 pCodecCtx->height,
                 picture.data,
                 picture.linesize);

    }

    - (UIImage *)imageFromAVPicture:(AVPicture)pict width:(int)width height:(int)height
    {
       CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
       CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, pict.data[0], pict.linesize[0]*height,kCFAllocatorNull);
       CGDataProviderRef provider = CGDataProviderCreateWithCFData(data);
       CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
       CGImageRef cgImage = CGImageCreate(width,
                                          height,
                                          8,
                                          24,
                                          pict.linesize[0],
                                          colorSpace,
                                          bitmapInfo,
                                          provider,
                                          NULL,
                                          NO,
                                          kCGRenderingIntentDefault);
       CGColorSpaceRelease(colorSpace);
       UIImage *image = [[UIImage alloc] initWithCGImage:cgImage];



       return [image autorelease];
    }

    how can i detect the function that causes memory problem ?

    SOLVED ! I just neeed to add the following code in "imagefromavcapture" :

    CGImageRelease(cgImage);
       CGDataProviderRelease(provider);
       CFRelease(data);
  • iOS allocation grow using x264 encoding

    19 juillet 2013, par cssmhyl

    I get the video yuv data in callback and save the image data by NSData.Then I put the data into NSData,And put the array to queue(NSMutableArray). These are code :

    - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection{

       if ([Application sharedInstance].isRecording) {
           if (captureOutput == self.captureManager.videOutput) {

               uint64_t capturedHostTime = [self GetTickCount];
               int allSpace = capturedHostTime - lastCapturedHostTime;
               NSNumber *spaces = [[NSNumber alloc] initWithInt:allSpace];
               NSNumber *startTime = [[NSNumber alloc] initWithUnsignedLongLong:lastCapturedHostTime];
               lastCapturedHostTime = capturedHostTime;

               CVImageBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);

               CVPixelBufferLockBaseAddress(pixelBuffer, 0);

               uint8_t  *baseAddress0 = (uint8_t *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
               uint8_t  *baseAddress1 = (uint8_t *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1);

               size_t width = CVPixelBufferGetWidth(pixelBuffer);
               size_t height = CVPixelBufferGetHeight(pixelBuffer);

               NSData *baseAddress0Data = [[NSData alloc] initWithBytes:baseAddress0 length:width*height];
               NSData *baseAddress1Data = [[NSData alloc] initWithBytes:baseAddress1 length:width*height/2];
               CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);

               NSArray *array = [[NSArray alloc] initWithObjects:baseAddress0Data,baseAddress1Data,spaces,startTime ,nil];
               [baseAddress0Data release];
               [baseAddress1Data release];
               [spaces release];
               [startTime release];

               @synchronized([Application sharedInstance].pearVideoQueue){
                   [[Application sharedInstance] enqueuePearVideo:[Application sharedInstance].pearVideoQueue withData:array];
                   [array release];
               }            
           }
       }
    }

    now,I run an operation and get data from the queue ,then encode them by x264.I destory de array after encoding.

    - (void)main{


       while ([Application sharedInstance].pearVideoQueue) {
           if (![Application sharedInstance].isRecording) {
               NSLog(@"encode operation break");
               break;
           }
           if (![[Application sharedInstance].pearVideoQueue isQueueEmpty]) {
               NSArray *pearVideoArray;
               @synchronized([Application sharedInstance].pearVideoQueue){

                  pearVideoArray = [[Application sharedInstance].pearVideoQueue dequeue];
                   [[Application sharedInstance] encodeToH264:pearVideoArray];
                   [pearVideoArray release];
                   pearVideoArray = nil;
               }
           } else{
             [NSThread sleepForTimeInterval:0.01];  
           }
       }

    }

    this is encoding method

    - (void)encodeX264:(NSArray *)array{

       int         i264Nal;
       x264_picture_t pic_out;
       x264_nal_t  *p264Nal;


       NSNumber *st = [array lastObject];
       NSNumber *sp = [array objectAtIndex:2];
       uint64_t startTime = [st unsignedLongLongValue];
       int spaces = [sp intValue];

       NSData *baseAddress0Data = [array objectAtIndex:0];
       NSData *baseAddress1Data = [array objectAtIndex:1];

       const char *baseAddress0 = baseAddress0Data.bytes;
       const char *baseAddress1 = baseAddress1Data.bytes;


       if (baseAddress0 == nil) {
           return;
       }

       memcpy(p264Pic->img.plane[0], baseAddress0, PRESENT_FRAME_WIDTH*PRESENT_FRAME_HEIGHT);

       uint8_t * pDst1 = p264Pic->img.plane[1];
       uint8_t * pDst2 = p264Pic->img.plane[2];
       for( int i = 0; i < PRESENT_FRAME_WIDTH*PRESENT_FRAME_HEIGHT/4; i ++ )
       {
           *pDst1++ = *baseAddress1++;
           *pDst2++ = *baseAddress1++;
       }

       if( x264_encoder_encode( p264Handle, &p264Nal, &i264Nal, p264Pic ,&pic_out) < 0 )
       {
           fprintf( stderr, "x264_encoder_encode failed/n" );
       }

       i264Nal = 0;
       if (i264Nal > 0) {

           int i_size;
           int spslen =0;
           unsigned char spsData[1024];        
           char * data = (char *)szBuffer+100;
           memset(szBuffer, 0, sizeof(szBuffer));
           if (ifFirstSps) {
               ifFirstSps = NO;
               if (![Application sharedInstance].ifAudioStarted) {
                   NSLog(@"video first");
                   [Application sharedInstance].startTick = startTime;
                   NSLog(@"startTick: %llu",startTime);
                   [Application sharedInstance].ifVideoStarted = YES;
               }
           }        
           for (int i=0 ; inal_buffer_size < p264Nal[i].i_payload*3/2+4) {
                   p264Handle->nal_buffer_size = p264Nal[i].i_payload*2+4;
                   x264_free( p264Handle->nal_buffer );
                   p264Handle->nal_buffer = x264_malloc( p264Handle->nal_buffer_size );
               }

               i_size = p264Nal[i].i_payload;
               memcpy(data, p264Nal[i].p_payload, p264Nal[i].i_payload);
               int splitNum = 0;
               for (int i=0; i=1) {
                   timeSpace = spaces/(i264Nal-1)*i;
               }else{
                   timeSpace  = spaces/i264Nal*i;
               }            
               int timeStamp  = startTime-[Application sharedInstance].startTick + timeSpace;

               switch (type) {
                   case NALU_TYPE_SPS:
                       spslen = i_size-splitNum;
                       memcpy(spsData, data, spslen);                    
                       break;
                   case NALU_TYPE_PPS:
                       timeStamp  = timeStamp - timeSpace;
                       [self pushSpsAndPpsQueue:(char *)spsData andppsData:(char *)data withPPSlength:spslen andPPSlength:(i_size-splitNum) andTimeStamp:timeStamp];
                       break;
                   case NALU_TYPE_IDR:
                       [self pushVideoNALU:(char *)data withLength:(i_size-splitNum) ifIDR:YES andTimeStamp:timeStamp];
                       break;
                   case NALU_TYPE_SLICE:
                   case NALU_TYPE_SEI:
                       [self pushVideoNALU:(char *)data withLength:(i_size-splitNum) ifIDR:NO andTimeStamp:timeStamp];
                       break;
                   default:
                       break;
               }
           }
       }
    }

    the question is :
    I used instruments and found that the data I captured increase ,but NSLog
    show that the space-time I create de array and release it did not increase,and when I release ,the array's retain count is 1. the object's retain count it contains is also one.
    then I didn't encode,the memory didn't increase...I was confused...please help..
    the image pixel is 640x480.

    intruments leaks picture:

  • Memory leak while opening encoders in ffmpeg

    22 janvier 2014, par praks411

    I'm getting memory leaks in avcodec_find_encoder. Although I'm cleaning the resources properly
    still I'm not able to get rid of the leak. By successive commenting the code I found that memory leaks happen only after the call of avcodec_find_encoder(). I've tried my code with different video files and I found that memory leaks blocks are always same. Also if I open only audio or video then I get just one memory leaks block.
    Below is the part of Init and Clean-up code from the application.
    Note that this is just part of code which contains initialization and resource release.

    AVFormatContext *m_informat;
    AVFormatContext *m_outformat;
    AVStream *m_in_vid_strm, *m_out_vid_strm;
    AVStream *m_in_aud_strm, *m_out_aud_strm;


    int VideoClipper::Init(const wxString& filename)
    {
       int ret = 0;
       char errbuf[64];

       av_register_all();
       if ((ret = avformat_open_input( &m_informat, filename.mb_str(), 0, 0)) != 0 )
       {
           av_strerror(ret,errbuf,sizeof(errbuf));
           PRINT_VAL("Not able to Open file;; ", errbuf)
           ret = -1;
           return ret;
       }
       else
       {
           PRINT_MSG("Opened File ")
       }

       if ((ret = avformat_find_stream_info(m_informat, 0))< 0 )
       {

           av_strerror(ret,errbuf,sizeof(errbuf));
           PRINT_VAL("Not Able to find stream info:: ", errbuf)
           ret = -1;
           return ret;
       }
       else
       {
           PRINT_MSG("Got stream Info ")
       }

       for(unsigned int i = 0; inb_streams; i++)
       {
           if(m_informat->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
           {

               PRINT_MSG("Found Video Stream ")
               m_in_vid_strm_idx = i;
               m_in_vid_strm = m_informat->streams[i];
           }

           if(m_informat->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
           {
               PRINT_MSG("Found Audio Stream ")
               m_in_aud_strm_idx = i;
               m_in_aud_strm = m_informat->streams[i];
           }
       }

       AVOutputFormat *outfmt = NULL;
       std::string outfile = std::string(filename) + "clip_out.avi";
       outfmt = av_guess_format(NULL,outfile.c_str(),NULL);

       if(outfmt == NULL)
       {
           ret = -1;
           return ret;
       }
       else
       {
           m_outformat = avformat_alloc_context();
           if(m_outformat)
           {
               m_outformat->oformat = outfmt;
               _snprintf(m_outformat->filename, sizeof(m_outformat->filename), "%s", outfile.c_str());    
           }
           else
           {
               ret = -1;
               return ret;
           }
       }

       AVCodec *out_vid_codec,*out_aud_codec;
       out_vid_codec = out_aud_codec = NULL;

       if(outfmt->video_codec != AV_CODEC_ID_NONE && m_in_vid_strm != NULL)
       {
           out_vid_codec = avcodec_find_encoder(outfmt->video_codec);
           if(NULL == out_vid_codec)
           {
               PRINT_MSG("Could Not Find Vid Encoder")
               ret = -1;
               return ret;
           }
           else
           {
               PRINT_MSG("Found Out Vid Encoder ")
               m_out_vid_strm = avformat_new_stream(m_outformat, out_vid_codec);
               if(NULL == m_out_vid_strm)
               {
                    PRINT_MSG("Failed to Allocate Output Vid Strm ")
                    ret = -1;
                    return ret;
               }
               else
               {
                    PRINT_MSG("Allocated Video Stream ")
                    if(avcodec_copy_context(m_out_vid_strm->codec, m_informat->streams[m_in_vid_strm_idx]->codec) != 0)
                    {
                       PRINT_MSG("Failed to Copy Context ")
                       ret = -1;
                       return ret;
                    }
                  }
               }
         }

       if(outfmt->audio_codec != AV_CODEC_ID_NONE && m_in_aud_strm != NULL)
       {
           out_aud_codec = avcodec_find_encoder(outfmt->audio_codec);
           if(NULL == out_aud_codec)
           {
               PRINT_MSG("Could Not Find Out Aud Encoder ")
               ret = -1;
               return ret;
           }
           else
           {
               PRINT_MSG("Found Out Aud Encoder ")
               m_out_aud_strm = avformat_new_stream(m_outformat, out_aud_codec);
               if(NULL == m_out_aud_strm)
               {
                   PRINT_MSG("Failed to Allocate Out Vid Strm ")
                   ret = -1;
                   return ret;
               }
               else
               {
                   if(avcodec_copy_context(m_out_aud_strm->codec, m_informat->streams[m_in_aud_strm_idx]->codec) != 0)
                   {
                       PRINT_MSG("Failed to Copy Context ")
                       ret = -1;
                       return ret;
                   }
               }
            }
         }

         if (!(outfmt->flags & AVFMT_NOFILE))
         {
           if (avio_open2(&m_outformat->pb, outfile.c_str(), AVIO_FLAG_WRITE,NULL, NULL) < 0)
           {
                   PRINT_VAL("Could Not Open File ", outfile)
                   ret = -1;
                   return ret;
           }
         }
           /* Write the stream header, if any. */
         if (avformat_write_header(m_outformat, NULL) < 0)
         {
               PRINT_VAL("Error Occurred While Writing Header ", outfile)
               ret = -1;
               return ret;
         }
         else
         {
               PRINT_MSG("Written Output header ")
               m_init_done = true;
         }

       return ret;
    }

    Here is the Clean-up part

    void VideoClipper::ReleaseResource(void)
    {
       if(m_in_aud_strm && m_in_aud_strm->codec)
       {
           avcodec_close(m_in_aud_strm->codec);
           PRINT_MSG("Closed Input Audio Codec ")
       }

       if(m_in_vid_strm && m_in_vid_strm->codec)
       {
           avcodec_close(m_in_vid_strm->codec);
           PRINT_MSG("Closed Input Video Codec ")
       }

       if(m_informat)
       {
          avformat_close_input(&m_informat);
           PRINT_MSG("Freed Input Format Contex ")
       }

       if(m_out_aud_strm && m_out_aud_strm->codec)
       {
           avcodec_close(m_out_aud_strm->codec);
           PRINT_MSG("Closed Output Audio Codec ")
       }

       if(m_out_vid_strm && m_out_vid_strm->codec)
       {
           avcodec_close(m_out_vid_strm->codec);
           PRINT_MSG("Closed Output Audio Codec ")
       }

       if(m_outformat)
       {
           avformat_close_input(&m_outformat);
           m_outformat = NULL;
           PRINT_MSG("Closed Output Format ")
       }

    }

    Memory Leaks message

    Detected memory leaks!
    Dumping objects ->
    {13691} normal block at 0x01046A60, 4479 bytes long.
    Data: <                > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
    {13685} normal block at 0x01043FD0, 10831 bytes long.
    Data: <         ?      > CD CD CD CD CD CD CD CD D0 3F 04 01 ED ED ED ED
    Object dump complete.

    I'm using latest version of ffmpeg on Visual Studio 2012.
    Please suggest where I'm missing.

    Thanks
    Pradeep