Recherche avancée

Médias (2)

Mot : - Tags -/documentation

Autres articles (47)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (3639)

  • FFMPEG eats all the memory

    19 mai 2021, par Abhinandan Chakraborty

    Probably one of the most cliche question but here is the problem : So I have a Ubuntu Server running as an isolated machine only to handle FFMPEG jobs. It has 4 vCPU, 4GB RAM, 80GB storage. I am currently using this script to convert a video into HLS playlist : https://gist.github.com/maitrungduc1410/9c640c61a7871390843af00ae1d8758e This works fine for all video including 4K recorded from iPhone. However, I am trying to add watermark so I changed the line 106 of this script

    


    from :

    


    cmd+=" ${static_params} -vf scale=w=${widthParam}:h=${heightParam}"


    


    to :

    


    cmd+=" ${static_params} -filter_complex [1]colorchannelmixer=aa=0.5,scale=iw*0.1:-1[wm];[0][wm]overlay=W-w-5:H-h-5[out];[out]scale=w=${widthParam}:h=${heightParam}[final] -map [final]"


    


    Now this works flawlessly in videos from Youtube or other sources but as soon as I am trying to use 4K videos from iPhone, the RAM usage grows from 250MB to 3.8GB in less than minute and crashes the entire process. So I looked out for some similar question :

    


      

    1. FFmpeg Concat Filter High Memory Usage
    2. 


    3. https://github.com/jitsi/jibri/issues/269
    4. 


    5. https://superuser.com/questions/1509906/reduce-ffmpeg-memory-usage-when-joining-videos
    6. 


    7. ffmpeg amerge Error while filtering : Cannot allocate memory
    8. 


    


    I understand that FFMPEG requires high amount of memory consumption but I am unsure what's the exact way to process video without holding the stream in the memory but instead release any memory allocation in real-time. Even if we decide to work without watermark, It still hangs around 1.8GB RAM for processing 5 seconds 4K video and this create a risk of what if our user upload rather longer video than it will eventually crash down the server. I have thought about ulimit but this does seem like restricting FFMPEG instead of writing an improved command. Let me know how I can tackle this problem. Thanks

    


  • Memory leak when using av_frame_get_buffer()

    19 juillet 2018, par Alec Matthews

    I am making a simple video player with ffmpeg. I have noticed that there is a memory leak originating in libavutil. Because ffmpeg is a mature library I assume that I am allocating a new frame incorrectly. The documentation is also vague about freeing the buffer that is created when you call av_frame_get_buffer(). Below is the code I am using to decode the video and queue it up for display on the UI thread.

    DWORD WINAPI DecoderThread(LPVOID lpParam)
    {
       AVFrame *frame = NULL;
       AVPacket pkt;

       SwsContext *swsCtx = NULL;
       UINT8 *buffer = NULL;
       INT iNumBytes = 0;

       INT result = 0;

       frame = av_frame_alloc();

       av_init_packet(&pkt);
       pkt.data = NULL;
       pkt.size = 0;

       // Create scaling context
       swsCtx = sws_getContext(codecCtx->width, codecCtx->height, codecCtx->pix_fmt, codecCtx->width, codecCtx->height, AV_PIX_FMT_BGR24, SWS_BICUBIC, NULL, NULL, NULL);

      while (av_read_frame(fmtCtx, &pkt) >= 0) {
           if (pkt.stream_index == videoStream) {
               result = avcodec_send_packet(codecCtx, &pkt);

               while (result >= 0) {
                   result = avcodec_receive_frame(codecCtx, frame);
                   if (result == AVERROR(EAGAIN) || result == AVERROR_EOF) {
                       break;
                   } else if (result < 0) {
                       // another error.
                   }
                   // Create a new frame to store the RGB24 data.
                   AVFrame *pFrameRGB = av_frame_alloc();
                   // Allocate space for the new RGB image.
                   //av_image_alloc(pFrameRGB->data, pFrameRGB->linesize, codecCtx->width, codecCtx->height, AV_PIX_FMT_BGR24, 1);
                   // Copy all of the properties from the YUV420P frame.
                   av_frame_copy_props(pFrameRGB, frame);
                   pFrameRGB->width = frame->width;
                   pFrameRGB->height = frame->height;
                   pFrameRGB->format = AV_PIX_FMT_BGR24;
                   av_frame_get_buffer(pFrameRGB, 0);

                   // Convert fram from YUV420P to BGR24 for display.
                   sws_scale(swsCtx, (const UINT8* const *) frame->data, frame->linesize, 0, codecCtx->height, pFrameRGB->data, pFrameRGB->linesize);

                   // Queue thr BGR frame for drawing by the main thread.
                   AddItemToFrameQueue(pFrameRGB);

                   av_frame_unref(frame);
               }
           }
          while (GetQueueSize() > 100) {
               Sleep(10);
          }
      }

       CloseFrameQueue();

       av_frame_free(&frame);
      avcodec_close(codecCtx);
      avformat_close_input(&fmtCtx);

       return 0;
    }

    Is there a better way to allocate a new frame for holding the post sws_scale() transformation ?

    There is a similar stackoverflow question that uses mostly depreciated function calls. I can’t seem to find any answers that conform to the new version of ffmpeg in the documentation. Any help would be appreciated.

  • Can't merge mp4 files with FFmpeg on android

    6 mai 2017, par Brian

    I’m using https://github.com/hiteshsondhi88/ffmpeg-android-java in an app that needs to combine multiple mp4 files into one.

    Here is a command

    ffmpeg -i concat:"/data/data/com.testapp.app/cache:temp/lds82df9skov65i15k3ct16cik.mp4|/data/data/com.testapp.app/cache:temp/qm5s0utmb8c1gbhch6us2tnilo.mp4" -codec copy /data/data/com.testapp.app/cache:temp/4egqalludvs03tnfleu5dgb6iv.mp4

    java method to append files, movie files is an array holding files i want to combine

    public void appendFiles() {

       showProgressDialog();

       movieFile = getRandomFile();

       StringBuilder b = new StringBuilder();

       try {

           for (int i = 0; i < movieFiles.size(); i++) {

               File f = movieFiles.get(i);

               if (!f.exists()) {
                   continue;
               }

               if(i != 0){
                   b.append("|");
               }

               b.append(f.getPath());


           }

           final String command = "-i concat:\""+b.toString() + "\" -codec copy " + movieFile.getPath();



           try {
               ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
                   @Override
                   public void onFailure(String s) {
                       app.log("FAILED with output : " + s);
                   }

                   @Override
                   public void onSuccess(String s) {
                       app.log("SUCCESS with output : " + s);

                       createThumbnail();

                       stopProgressDialog();

                       startReview();
                   }

                   @Override
                   public void onProgress(String s) {
                       app.log("Started command : ffmpeg " + command);

                   }

                   @Override
                   public void onStart() {

                       app.log("Started command : ffmpeg " + command);

                   }

                   @Override
                   public void onFinish() {
                       app.log("Finished command : ffmpeg " + command);

                   }
               });
           }
           catch (FFmpegCommandAlreadyRunningException e) {
               e.printStackTrace();
           }


       }

       catch (Exception e) {
           e.printStackTrace();
       }

    }

    and getRandomFile()

       public File getRandomFile() {
           if (captureDir != null) {
               if (captureDir.exists()) {

                   SecureRandom random = new SecureRandom();
                   File file = new File(captureDir, new BigInteger(130, random).toString(32) + ".mp4");
                   return file;
               }
           }
           return null;
       }

    but I keep seeing the error no such file or directory

    concat :"/data/data/com.testapp.app/cache:temp/lds82df9skov65i15k3ct16cik.mp4|/data/data/com.testapp.app/cache:temp/qm5s0utmb8c1gbhch6us2tnilo.mp4" : No such file or directory

    any ideas ?