Recherche avancée

Médias (0)

Mot : - Tags -/interaction

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

Autres articles (42)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

Sur d’autres sites (5096)

  • how to make live streaming for multiple clients

    19 septembre 2014, par Abdulrahman Alcharbaji

    I have new project to do and I need some help to know where to start.
    I have more than 1000 DVR each with 4 channels, I need to be able to do live streaming for multiple clients, and clients could be android,iPhone or windows.
    Now throw searching i tried to check ffserver and ffmpeg but i couldn’t find much references to guide me throw a solution for my problem.
    NOTE : the DVRs streaming with h.264 encoding.

    So Please can anybody help me by guiding me for a start or some good references about this particular issue.

    Many Thnaks

  • How to make your plugin configurable – Introducing the Piwik Platform

    18 septembre 2014, par Thomas Steur — Development

    This is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to add new pages and menu items to Piwik). This time you will learn how to define settings for your plugin. For this tutorial you will need to have basic knowledge of PHP.

    What can I do with settings ?

    The Settings API offers you a simple way to make your plugin configurable within the Admin interface of Piwik without having to deal with HTML, JavaScript, CSS or CSRF tokens. There are many things you can do with settings, for instance let users configure :

    • connection infos to a third party system such as a WordPress installation.
    • select a metric to be displayed in your widget
    • select a refresh interval for your widget
    • which menu items, reports or widgets should be displayed
    • and much more

    Getting started

    In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.

    To summarize the things you have to do to get setup :

    • Install Piwik (for instance via git).
    • Activate the developer mode : ./console development:enable --full.
    • Generate a plugin : ./console generate:plugin --name="MySettingsPlugin". There should now be a folder plugins/MySettingsPlugin.
    • And activate the created plugin under Settings => Plugins.

    Let’s start creating settings

    We start by using the Piwik Console to create a settings template :

    ./console generate:settings

    The command will ask you to enter the name of the plugin the settings should belong to. I will simply use the above chosen plugin name “MySettingsPlugin”. There should now be a file plugins/MySettingsPlugin/Settings.php which contains already some examples to get you started easily. To see the settings in action go to Settings => Plugin settings in your Piwik installation.

    Adding one or more settings

    Settings are added in the init() method of the settings class by calling the method addSetting() and passing an instance of a UserSetting or SystemSetting object. How to create a setting is explained in the next chapter.

    Customising a setting

    To create a setting you have to define a name along some options. For instance which input field should be displayed, what type of value you expect, a validator and more. Depending on the input field we might automatically validate the values for you. For example if you define available values for a select field then we make sure to validate and store only a valid value which provides good security out of the box.

    For a list of possible properties have a look at the SystemSetting and UserSetting API reference.

    class Settings extends \Piwik\Plugin\Settings
    {
       public $refreshInterval;

       protected function init()
       {
           $this->setIntroduction('Here you can specify the settings for this plugin.');

           $this->createRefreshIntervalSetting();
       }

       private function createRefreshIntervalSetting()
       {
           $this->refreshInterval = new UserSetting('refreshInterval', 'Refresh Interval');
           $this->refreshInterval->type = static::TYPE_INT;
           $this->refreshInterval->uiControlType = static::CONTROL_TEXT;
           $this->refreshInterval->uiControlAttributes = array('size' => 3);
           $this->refreshInterval->description = 'How often the value should be updated';
           $this->refreshInterval->inlineHelp = 'Enter a number which is >= 15';
           $this->refreshInterval->defaultValue = '30';
           $this->refreshInterval->validate = function ($value, $setting) {
               if ($value < 15) {
                   throw new \Exception('Value is invalid');
               }
           };

           $this->addSetting($this->refreshInterval);
       }
    }

    In this example you can see some of those properties. Here we create a setting named “refreshInterval” with the display name “Refresh Interval”. We want the setting value to be an integer and the user should enter this value in a text input field having the size 3. There is a description, an inline help and a default value of 30. The validate function makes sure to accept only integers that are at least 15, otherwise an error in the UI will be shown.

    You do not always have to specify a PHP type and a uiControlType. For instance if you specify a PHP type boolean we automatically display a checkbox by default. Similarly if you specify to display a checkbox we assume that you want a boolean value.

    Accessing settings values

    You can access the value of a setting in a widget, in a controller, in a report or anywhere you want. To access the value create an instance of your settings class and get the value like this :

    $settings = new Settings();
    $interval = $settings->refreshInterval->getValue()

    Type of settings

    The Piwik platform differentiates between UserSetting and SystemSetting. User settings can be configured by any logged in user and each user can configure the setting independently. The Piwik platform makes sure that settings are stored per user and that a user cannot see another users configuration.

    A system setting applies to all of your users. It can be configured only by a user who has super user access. By default, the value can be read only by a super user as well but often you want to have it readable by anyone or at least by logged in users. If you set a setting readable the value will still be only displayed to super users but you will always be able to access the value in the background.

    Imagine you are building a widget that fetches data from a third party system where you need to configure an API URL and token. While no regular user should see the value of both settings, the value should still be readable by any logged in user. Otherwise when logged in users cannot read the setting value then the data cannot be fetched in the background when this user wants to see the content of the widget. Solve this by making the setting readable by the current user :

    $setting->readableByCurrentUser = !Piwik::isUserIsAnonymous();

    Publishing your Plugin on the Marketplace

    In case you want to share your settings or your plugin with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin.

    Advanced features

    Isn’t it easy to create settings for plugins ? We never even created a file ! The Settings API already offers many possibilities but it might not yet be as flexible as your use case requires. So let us know in case you are missing something and we hope to add this feature at some point in the future.

    If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.

  • FFMPEG Encoding Issues

    16 octobre 2014, par madprogrammer2015

    I am having issues encoding screen captures, into a h.264 file for viewing. The program below is cobbled together from examples here and here. The first example, uses an older version of the ffmpeg api. So I tried to update that example for use in my program. The file is created and has something written to it, but when I view the file. The encoded images are all distorted. I am able to run the video encoding example from the ffmpeg api successfully. This is my first time posting, so if I missed anything please let me know.

    I appreciate any assistance that is given.

    My program :

    #include
    #include <string>
    #include <sstream>
    #include
    #include <iostream>
    #include

    extern "C"{
    #include
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavutil></libavutil>imgutils.h>
    #include <libswscale></libswscale>swscale.h>
    #include <libavutil></libavutil>opt.h>
    }

    using namespace std;

    void ScreenShot(const char* BmpName, uint8_t *frame)
    {
       HWND DesktopHwnd = GetDesktopWindow();
       RECT DesktopParams;
       HDC DevC = GetDC(DesktopHwnd);
       GetWindowRect(DesktopHwnd,&amp;DesktopParams);
       DWORD Width = DesktopParams.right - DesktopParams.left;
       DWORD Height = DesktopParams.bottom - DesktopParams.top;

       DWORD FileSize = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+(sizeof(RGBTRIPLE)+1*(Width*Height*4));
       char *BmpFileData = (char*)GlobalAlloc(0x0040,FileSize);

       PBITMAPFILEHEADER BFileHeader = (PBITMAPFILEHEADER)BmpFileData;
       PBITMAPINFOHEADER  BInfoHeader = (PBITMAPINFOHEADER)&amp;BmpFileData[sizeof(BITMAPFILEHEADER)];

       BFileHeader->bfType = 0x4D42; // BM
       BFileHeader->bfSize = sizeof(BITMAPFILEHEADER);
       BFileHeader->bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);

       BInfoHeader->biSize = sizeof(BITMAPINFOHEADER);
       BInfoHeader->biPlanes = 1;
       BInfoHeader->biBitCount = 32;
       BInfoHeader->biCompression = BI_RGB;
       BInfoHeader->biHeight = Height;
       BInfoHeader->biWidth = Width;

       RGBTRIPLE *Image = (RGBTRIPLE*)&amp;BmpFileData[sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)];
       RGBTRIPLE color;
       //pPixels = (RGBQUAD **)new RGBQUAD[sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)];
       int start = clock();

       HDC CaptureDC = CreateCompatibleDC(DevC);
       HBITMAP CaptureBitmap = CreateCompatibleBitmap(DevC,Width,Height);
       SelectObject(CaptureDC,CaptureBitmap);
       BitBlt(CaptureDC,0,0,Width,Height,DevC,0,0,SRCCOPY|CAPTUREBLT);
       GetDIBits(CaptureDC,CaptureBitmap,0,Height,frame,(LPBITMAPINFO)BInfoHeader, DIB_RGB_COLORS);

       int end = clock();

       cout &lt;&lt; "it took " &lt;&lt; end - start &lt;&lt; " to capture a frame" &lt;&lt; endl;

       DWORD Junk;
       HANDLE FH = CreateFileA(BmpName,GENERIC_WRITE,FILE_SHARE_WRITE,0,CREATE_ALWAYS,0,0);
       WriteFile(FH,BmpFileData,FileSize,&amp;Junk,0);
       CloseHandle(FH);
       GlobalFree(BmpFileData);
    }

    void video_encode_example(const char *filename, int codec_id)
    {
       AVCodec *codec;
       AVCodecContext *c= NULL;
       int i, ret, x, y, got_output;
       FILE *f;
       AVFrame *frame;
       AVPacket pkt;
       uint8_t endcode[] = { 0, 0, 1, 0xb7 };

       printf("Encode video file %s\n", filename);

       /* find the mpeg1 video encoder */
       codec = avcodec_find_encoder(AV_CODEC_ID_H264);
       if (!codec) {
           fprintf(stderr, "Codec not found\n");
           cin.get();
           exit(1);
       }

       c = avcodec_alloc_context3(codec);
       if (!c) {
           fprintf(stderr, "Could not allocate video codec context\n");
           cin.get();
           exit(1);
       }

       /* put sample parameters */
       c->bit_rate = 400000;
       /* resolution must be a multiple of two */
       c->width = 352;
       c->height = 288;
       /* frames per second */
       c->time_base.num=1;
       c->time_base.den = 25;
       c->gop_size = 10; /* emit one intra frame every ten frames */
       c->max_b_frames=1;
       c->pix_fmt = AV_PIX_FMT_YUV420P;

       if(codec_id == AV_CODEC_ID_H264)
           av_opt_set(c->priv_data, "preset", "slow", 0);

       /* open it */
       if (avcodec_open2(c, codec, NULL) &lt; 0) {
           fprintf(stderr, "Could not open codec\n");
           exit(1);
       }

       f = fopen(filename, "wb");
       if (!f) {
           fprintf(stderr, "Could not open %s\n", filename);
           exit(1);
       }

       frame = av_frame_alloc();
       if (!frame) {
           fprintf(stderr, "Could not allocate video frame\n");
           exit(1);
       }

       frame->format = c->pix_fmt;
       frame->width  = c->width;
       frame->height = c->height;

       /* the image can be allocated by any means and av_image_alloc() is
       just the most convenient way if av_malloc() is to be used */
       ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height, c->pix_fmt, 32);

       if (ret &lt; 0) {
           fprintf(stderr, "Could not allocate raw picture buffer\n");
           exit(1);
       }

       /* encode 1 second of video */
       for(i=0;i&lt;250;i++) {
           av_init_packet(&amp;pkt);
           pkt.data = NULL;    // packet data will be allocated by the encoder
           pkt.size = 0;

           fflush(stdout);
           /* prepare a dummy image */
           /* Y */
           for(y=0;yheight;y++) {
               for(x=0;xwidth;x++) {
                   frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
               }
           }

           /* Cb and Cr */
           for(y=0;yheight/2;y++) {
               for(x=0;xwidth/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;
               }
           }

           frame->pts = i;

           /* encode the image */
           ret = avcodec_encode_video2(c, &amp;pkt, frame, &amp;got_output);
           if (ret &lt; 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_free_packet(&amp;pkt);
           }
       }

       /* get the delayed frames */
       for (got_output = 1; got_output; i++) {
           fflush(stdout);

           ret = avcodec_encode_video2(c, &amp;pkt, NULL, &amp;got_output);

           if (ret &lt; 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_free_packet(&amp;pkt);
           }
       }

       /* add sequence end code to have a real mpeg file */
       fwrite(endcode, 1, sizeof(endcode), f);
       fclose(f);

        avcodec_close(c);
        av_free(c);
        av_freep(&amp;frame->data[0]);
        av_frame_free(&amp;frame);
        printf("\n");
    }

    void write_video_frame()
    {
    }

    int lineSizeOfFrame(int width)
    {
       return  (width*24 + 31)/32 * 4;//((width*24 / 8) + 3) &amp; ~3;//(width*24 + 31)/32 * 4;
    }

    int getScreenshotWithCursor(uint8_t* frame)
    {
       int successful = 0;
           HDC screen, bitmapDC;
           HBITMAP screen_bitmap;

           screen = GetDC(NULL);
           RECT DesktopParams;

           HWND desktop = GetDesktopWindow();
           GetWindowRect(desktop, &amp;DesktopParams);

           int width = DesktopParams.right;
           int height = DesktopParams.bottom;

           bitmapDC = CreateCompatibleDC(screen);
           screen_bitmap = CreateCompatibleBitmap(screen, width, height);
           SelectObject(bitmapDC, screen_bitmap);
           if (BitBlt(bitmapDC, 0, 0, width, height, screen, 0, 0, SRCCOPY))
           {
                   int pos_x, pos_y;
                   HICON hcur;
                   ICONINFO icon_info;
                   CURSORINFO cursor_info;
                   cursor_info.cbSize = sizeof(CURSORINFO);
                   if (GetCursorInfo(&amp;cursor_info))
                   {
                           if (cursor_info.flags == CURSOR_SHOWING)
                           {
                                   hcur = CopyIcon(cursor_info.hCursor);
                                   if (GetIconInfo(hcur, &amp;icon_info))
                                   {
                                           pos_x = cursor_info.ptScreenPos.x - icon_info.xHotspot;
                                           pos_y = cursor_info.ptScreenPos.y - icon_info.yHotspot;
                                           DrawIcon(bitmapDC, pos_x, pos_y, hcur);
                                           if (icon_info.hbmColor) DeleteObject(icon_info.hbmColor);
                                           if (icon_info.hbmMask) DeleteObject(icon_info.hbmMask);
                                   }
                           }
                   }
                   int header_size = sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD);
                   size_t line_size = lineSizeOfFrame(width);
                   PBITMAPINFO lpbi = (PBITMAPINFO) malloc(header_size);
                   lpbi->bmiHeader.biSize = header_size;
                   lpbi->bmiHeader.biWidth = width;
                   lpbi->bmiHeader.biHeight = height;
                   lpbi->bmiHeader.biPlanes = 1;
                   lpbi->bmiHeader.biBitCount = 24;
                   lpbi->bmiHeader.biCompression = BI_RGB;
                   lpbi->bmiHeader.biSizeImage = height*line_size;
                   lpbi->bmiHeader.biXPelsPerMeter = 0;
                   lpbi->bmiHeader.biYPelsPerMeter = 0;
                   lpbi->bmiHeader.biClrUsed = 0;
                   lpbi->bmiHeader.biClrImportant = 0;
                   if (GetDIBits(bitmapDC, screen_bitmap, 0, height, (LPVOID)frame, lpbi, DIB_RGB_COLORS))
                   {
                       int i;
                       uint8_t *buf_begin = frame;
                       uint8_t *buf_end = frame + line_size*(lpbi->bmiHeader.biHeight - 1);
                       void *temp = malloc(line_size);
                       for (i = 0; i &lt; lpbi->bmiHeader.biHeight / 2; ++i)
                       {
                           memcpy(temp, buf_begin, line_size);
                           memcpy(buf_begin, buf_end, line_size);
                           memcpy(buf_end, temp, line_size);
                           buf_begin += line_size;
                           buf_end -= line_size;
                       }
                       cout &lt;&lt; *buf_begin &lt;&lt; endl;
                       free(temp);
                       successful = 1;
                   }
                   free(lpbi);
           }
           DeleteObject(screen_bitmap);
           DeleteDC(bitmapDC);
           ReleaseDC(NULL, screen);
           return successful;
    }

    int main()
    {
       RECT DesktopParams;

       HWND desktop = GetDesktopWindow();
       GetWindowRect(desktop, &amp;DesktopParams);

       int width = DesktopParams.right;
       int height = DesktopParams.bottom;
       uint8_t *frame = (uint8_t *)malloc(width * height);

       AVCodec *codec;
       AVCodecContext *codecContext = NULL;
       AVPacket packet;
       FILE *f;
       AVFrame *pictureYUV = NULL;
       AVFrame *pictureRGB;

       avcodec_register_all();

       codec = avcodec_find_encoder(AV_CODEC_ID_H264);

       if(!codec)
       {
           cout &lt;&lt; "codec not found!" &lt;&lt; endl;
           cin.get();
           return 1;
       }
       else
       {
           cout &lt;&lt; "codec h265 found!" &lt;&lt; endl;
       }

       codecContext = avcodec_alloc_context3(codec);

       codecContext->bit_rate = width * height * 4;
       codecContext->width = width;
       codecContext->height = height;
       codecContext->time_base.num = 1;
       codecContext->time_base.den = 250;
       codecContext->gop_size = 10;
       codecContext->max_b_frames = 1;
       codecContext->keyint_min = 1;
       codecContext->i_quant_factor = (float)0.71;                        // qscale factor between P and I frames
       codecContext->b_frame_strategy = 20;                               ///// find out exactly what this does
       codecContext->qcompress = (float)0.6;                              ///// find out exactly what this does
       codecContext->qmin = 20;                                           // minimum quantizer
       codecContext->qmax = 51;                                           // maximum quantizer
       codecContext->max_qdiff = 4;                                       // maximum quantizer difference between frames
       codecContext->refs = 4;                                            // number of reference frames
       codecContext->trellis = 1;
       codecContext->pix_fmt = AV_PIX_FMT_YUV420P;
       codecContext->codec_id = AV_CODEC_ID_H264;
       codecContext->codec_type = AVMEDIA_TYPE_VIDEO;

       if(avcodec_open2(codecContext, codec, NULL) &lt; 0)
       {
           cout &lt;&lt; "couldn't open codec" &lt;&lt; endl;
           cout &lt;&lt; stderr &lt;&lt; endl;
           cin.get();
           return 1;
       }
       else
       {
           cout &lt;&lt; "opened h265 codec!" &lt;&lt; endl;
           cin.get();
       }

       f = fopen("test.h264", "wb");

       if(!f)
       {
           cout &lt;&lt; "Unable to open file" &lt;&lt; endl;
           return 1;
       }



       struct SwsContext *img_convert_ctx = sws_getContext(codecContext->width, codecContext->height, PIX_FMT_RGB32, codecContext->width,
           codecContext->height, codecContext->pix_fmt, SWS_BILINEAR, NULL, NULL, NULL);

       int got_output = 0, i = 0;
       uint8_t encode[] = { 0, 0, 1, 0xb7 };

       try
       {
           for(i = 0; i &lt; codecContext->time_base.den; i++)
           {
               av_init_packet(&amp;packet);
               packet.data = NULL;
               packet.size = 0;

               pictureRGB = av_frame_alloc();
               pictureYUV = av_frame_alloc();

               getScreenshotWithCursor(frame);
               //ScreenShot("example.bmp", frame);

               int nbytes = avpicture_get_size(AV_PIX_FMT_YUV420P, codecContext->width, codecContext->height);                                    // allocating outbuffer
               uint8_t* outbuffer = (uint8_t*)av_malloc(nbytes*sizeof(uint8_t));

               pictureRGB = av_frame_alloc();
               pictureYUV = av_frame_alloc();

               avpicture_fill((AVPicture*)pictureRGB, frame, PIX_FMT_RGB32, codecContext->width, codecContext->height);                   // fill image with input screenshot
               avpicture_fill((AVPicture*)pictureYUV, outbuffer, PIX_FMT_YUV420P, codecContext->width, codecContext->height);
               av_image_alloc(pictureYUV->data, pictureYUV->linesize, codecContext->width, codecContext->height, codecContext->pix_fmt, 32);

               sws_scale(img_convert_ctx, pictureRGB->data, pictureRGB->linesize, 0, codecContext->height, pictureYUV->data, pictureYUV->linesize);

               pictureYUV->pts = i;

               avcodec_encode_video2(codecContext, &amp;packet, pictureYUV, &amp;got_output);

               if(got_output)
               {
                   printf("Write frame %3d (size=%5d)\n", i, packet.size);
                   fwrite(packet.data, 1, packet.size, f);
                   av_free_packet(&amp;packet);
               }

               //av_frame_free(&amp;pictureRGB);
               //av_frame_free(&amp;pictureYUV);
           }

           for(got_output = 1; got_output; i++)
           {
               fflush(stdout);

               avcodec_encode_video2(codecContext, &amp;packet, NULL, &amp;got_output);

               if (got_output) {
                   printf("Write frame %3d (size=%5d)\n", i, packet.size);
                   fwrite(packet.data, 1, packet.size, f);
                   av_free_packet(&amp;packet);
               }
           }
       }
       catch(std::exception ex)
       {
           cout &lt;&lt; ex.what() &lt;&lt; endl;
       }

       avcodec_close(codecContext);
       av_free(codecContext);
       av_freep(&amp;pictureYUV->data[0]);
       //av_frame_free(&amp;picture);
       fwrite(encode, 1, sizeof(encode), f);
       fclose(f);

       cin.get();

       return 0;
    }
    </iostream></sstream></string>