Recherche avancée

Médias (33)

Mot : - Tags -/creative commons

Autres articles (52)

  • 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 (...)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (5476)

  • Swscale - image patch (NV12) color conversion - invalid border

    6 juin 2019, par dajuric

    The goal is to convert NV12 to BGR24 image, more exactly an image patch (x:0, y:0, w:220, h:220).
    The issue is the undefined pixel column on the right of the converted patch as shown :
    enter image description here

    The question is why is this happening (even though the coordinates and the dimensions of the patch have even values) ?
    (Interestingly enough for an odd width value, that issue is not present)


    The patch has the following bounding box : (x:0, y:0, w:220, h:220).
    The behavior should be reproducible with any image. Conversion can be done using the ppm conversion page.

    The following code creates a nv12 image from a bgr24 image and then converts a nv12 patch back to bgr24 patch. If everything worked properly the output should have been identical to a source image.

    #include <libswscale></libswscale>swscale.h>
    #include <libavutil></libavutil>imgutils.h>

    void readPPM(const char* filename, uint8_t** bgrData, int* stride, int* w, int* h)
    {
       FILE* fp = fopen(filename, "rb");
       fscanf(fp, "%*s\n"); //skip format check

       fscanf(fp, "%d %d\n", w, h);
       fscanf(fp, "%*d\n"); //skip max value check

       *stride = *w * 3;
       *bgrData = av_malloc(*h * *stride);

       for (int r = 0; r &lt; *h; r++)
       {
           uint8_t* rowData = *bgrData + r * *stride;
           for (int c = 0; c &lt; *w; c++)
           {
               //rgb -> bgr
               fread(&amp;rowData[2], 1, 1, fp);
               fread(&amp;rowData[1], 1, 1, fp);
               fread(&amp;rowData[0], 1, 1, fp);

               rowData += 3;
           }
       }

       fclose(fp);
    }

    void writePPM(const char* filename, uint8_t* bgrData, int stride, int w, int h)
    {
       FILE* fp = fopen(filename, "wb");
       fprintf(fp, "P6\n");
       fprintf(fp, "%d %d\n", w, h);
       fprintf(fp, "%d\n", 255);

       for (int r = 0; r &lt; h; r++)
       {
           uint8_t* rowData = bgrData + r * stride;
           for (int c = 0; c &lt; w; c++)
           {
               //bgr -> rgb
               fwrite(&amp;rowData[2], 1, 1, fp);
               fwrite(&amp;rowData[1], 1, 1, fp);
               fwrite(&amp;rowData[0], 1, 1, fp);

               rowData += 3;      
           }
       }

       fclose(fp);
    }


    void bgrToNV12(uint8_t* srcData[4], int srcStride[4],
                  uint8_t* tgtData[4], int tgtStride[4],
                  int w, int h)
    {
       struct SwsContext* context = sws_getContext(w, h, AV_PIX_FMT_BGR24,
                                                   w, h, AV_PIX_FMT_NV12, SWS_POINT, NULL, NULL, NULL);
       {
           sws_scale(context,
                     srcData, srcStride, 0, h,
                     tgtData, tgtStride);
       }
       sws_freeContext(context);
    }

    void nv12ToBgr(uint8_t* srcData[4], int srcStride[4],
                  uint8_t* tgtData[4], int tgtStride[4],
                  int w, int h)
    {
       struct SwsContext* context = sws_getContext(w, h, AV_PIX_FMT_NV12,
                                                   w, h, AV_PIX_FMT_BGR24, SWS_POINT, NULL, NULL, NULL);
       {
           sws_scale(context,
                     srcData, srcStride, 0, h,
                     tgtData, tgtStride);
       }
       sws_freeContext(context);
    }


    int main()
    {
       //load BGR image
       uint8_t* bgrData[4]; int bgrStride[4]; int bgrW, bgrH;
       readPPM("sample.ppm", &amp;bgrData[0], &amp;bgrStride[0], &amp;bgrW, &amp;bgrH);

       //create NV12 image from the BGR image
       uint8_t* nv12Data[4]; int nv12Stride[4];
       av_image_alloc(nv12Data, nv12Stride, bgrW, bgrH, AV_PIX_FMT_NV12, 16);
       bgrToNV12(bgrData, bgrStride, nv12Data, nv12Stride, bgrW, bgrH);

       //convert nv12 patch to bgr patch
       nv12ToBgr(nv12Data, nv12Stride, bgrData, bgrStride, 220, 220);   //invalid result (random column stripe)
       //nv12ToBgr(nv12Data, nv12Stride, bgrData, bgrStride, 221, 220); //valid result

       //save bgr image (should be exactly as original BGR image)
       writePPM("sample-out.ppm", bgrData[0], bgrStride[0], bgrW, bgrH);

       //cleanup
       av_freep(bgrData);
       av_freep(nv12Data);
       return 0;
    }
  • Making a ffmpeg screen capture on Mac OS X using YUV 4:2:0 Planar color model

    30 mai 2019, par Bass

    I make screen recordings with ffmpeg, using avfoundation on Mac OS X, x11grab on Linux and gdigrab on Windows.

    The resulting files should be compatible with modern web browsers (<video></video>), so I use H.264 codec and request YUV 4:2:0 Planar pixel format.

    On Mac OS X, however (unlike Linux and Windows), I receive the following logging :

    /usr/local/bin/ffmpeg -y -v error -f avfoundation -threads 0 -hide_banner -i 1:none -f mp4 -vcodec h264 -pix_fmt yuv420p -r 25/1 -qscale:v 1 -vf scale=-1:1080 target.mp4
    [avfoundation @ 0x7fdba2003a00] Selected pixel format (yuv420p) is not supported by the input device.
    [avfoundation @ 0x7fdba2003a00] Supported pixel formats:
    [avfoundation @ 0x7fdba2003a00]   uyvy422
    [avfoundation @ 0x7fdba2003a00]   yuyv422
    [avfoundation @ 0x7fdba2003a00]   nv12
    [avfoundation @ 0x7fdba2003a00]   0rgb
    [avfoundation @ 0x7fdba2003a00]   bgr0

    Still, according to mplayer, the resulting MP4 file seems to have YUV 4:2:0 Planar color model :

    [h264 @ 0x1048a8ac0]Format yuv420p chosen by get_format().
    [h264 @ 0x1048a8ac0]Reinit context to 1728x1088, pix_fmt: yuv420p
    [h264 @ 0x1048a8ac0]Format yuv420p chosen by get_format().
    [h264 @ 0x1048a8ac0]Reinit context to 1728x1088, pix_fmt: yuv420p
    [swscaler @ 0x1048c3cc0]bicubic scaler, from yuv420p to yuyv422 using MMXEXT
    *** [scale] Exporting mp_image_t, 1728x1080x12bpp YUV planar, 2799360 bytes
    *** [vo] Allocating mp_image_t, 1728x1080x16bpp YUV packed, 3732480 bytes

    the same confirmed by ffmpeg :

    $ ffmpeg -i target.mp4 -hide_banner
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'target.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf58.20.100
     Duration: 00:00:04.72, start: 0.000000, bitrate: 201 kb/s
       Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1728x1080, 197 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
       Metadata:
         handler_name    : VideoHandler

    Questions :

    1. Can someone explain the above ffmpeg logging ?
    2. If I still need to convert the avfoundation video stream to yuv420p, how do I make it on the fly (in a single ffmpeg pass) ?
  • create video with fluctuated background color and drawbox with fluctuated color ?

    27 mai 2019, par Wang

    Is there anyway to create a video with fluctuated background color choosing from a list for example [R, G, B] the background color along time will be R,G,B,R,G,B .... I might use nullsrc with geq. But seems the geq is quite slow which apply to each pixel.

    I would also like to change the color of drawbox too, is there any easy way to do it ? I knew we might be able to use openclsrc but it seems overkill for this simple task.

    Update, for drawbox I found a way, which is kind of abuse the timeline editing :

    ffmpeg -f lavfi -i smptebars=r=30:d=30:size=800x600 -vf "drawbox=enable='eq(mod(n,3),0)':x=0:y=0:t=20:c=red,drawbox=enable='eq(mod(n,3),1)':x=0:y=0:t=20:c=green,drawbox=enable='eq(mod(n,3),2)':x=0:y=0:t=20:c=blue" /tmp/test_box.mp4