Recherche avancée

Médias (91)

Autres articles (95)

  • 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

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

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

  • Overthinking My Search Engine Problem

    31 décembre 2013, par Multimedia Mike — General

    I wrote a search engine for my Game Music Appreciation website, because the site would have been significantly less valuable without it (and I would eventually realize that the search feature is probably the most valuable part of this endeavor). I came up with a search solution that was a bit sketchy, but worked… until it didn’t. I thought of a fix but still searched for more robust and modern solutions (where ‘modern’ is defined as something that doesn’t require compiling a C program into a static CGI script and hoping that it works on a server I can’t debug on).

    Finally, I realized that I was overthinking the problem– did you know that a bunch of relational database management systems (RDBMSs) support full text search (FTS) ? Okay, maybe you did, but I didn’t know this.

    Problem Statement
    My goal is to enable users to search the metadata (title, composer, copyright, other tags) attached to various games. To do this, I want to index a series of contrived documents that describe the metadata. 2 examples of these contrived documents, interesting because both of these games have very different titles depending on region, something the search engine needs to account for :

    system : Nintendo NES
    game : Snoopy’s Silly Sports Spectacular
    author : None ; copyright : 1988 Kemco ; dumped by : None
    additional tags : Donald Duck.nsf Donald Duck
    

    system : Super Nintendo
    game : Arcana
    author : Jun Ishikawa, Hirokazu Ando ; copyright : 1992 HAL Laboratory ; dumped by : Datschge
    additional tags : card.rsn.gamemusic Card Master Cardmaster

    The index needs to map these documents to various pieces of game music and the search solution needs to efficiently search these documents and find the various game music entries that match a user’s request.

    Now that I’ve been looking at it for long enough, I’m able to express the problem surprisingly succinctly. If I had understood that much originally, this probably would have been simpler.

    First Solution & Breakage
    My original solution was based on SWISH-E. The CGI script was a C program that statically linked the SWISH-E library into a binary that miraculously ran on my web provider. At least, it ran until it decided to stop working a month ago when I added a new feature unrelated to search. It was a very bizarre problem, the details of which would probably bore you to tears. But if you care, the details are all there in the Stack Overflow question I asked on the matter.

    While no one could think of a direct answer to the problem, I eventually thought of a roundabout fix. The problem seemed to pertain to the static linking. Since I couldn’t count on the relevant SWISH-E library to be on my host’s system, I uploaded the shared library to the same directory as the CGI script and used dlopen()/dlsym() to fetch the functions I needed. It worked again, but I didn’t know for how long.

    Searching For A Hosted Solution
    I know that anything is possible in this day and age ; while my web host is fairly limited, there are lots of solutions for things like this and you can deploy any technology you want, and for reasonable prices. I figured that there must be a hosted solution out there.

    I have long wanted a compelling reason to really dive into Amazon Web Services (AWS) and this sounded like a good opportunity. After all, my script works well enough ; if I could just find a simple Linux box out there where I could install the SWISH-E library and compile the CGI script, I should be good to go. AWS has a free tier and I started investigating this approach. But it seems like a rabbit hole with a lot of moving pieces necessary for such a simple task.

    I had heard that AWS had something in this area. Sure enough, it’s called CloudSearch. However, I’m somewhat discouraged by the fact that it would cost me around $75 per month to run the smallest type of search instance which is at the core of the service.

    Finally, I came to another platform called Heroku. It’s supposed to be super-scalable while having a free tier for hobbyists. I started investigating FTS on Heroku and found this article which recommends using the FTS capabilities of their standard hosted PostgreSQL solution. However, the free tier of Postgres hosting only allows for 10,000 rows of data. Right now, my database has about 5400 rows. I expect it to easily overflow the 10,000 limit as soon as I incorporate the C64 SID music corpus.

    However, this Postgres approach planted a seed.

    RDBMS Revelation
    I have 2 RDBMSs available on my hosting plan– MySQL and SQLite (the former is a separate service while SQLite is built into PHP). I quickly learned that both have FTS capabilities. Since I like using SQLite so much, I elected to leverage its FTS functionality. And it’s just this simple :

    CREATE VIRTUAL TABLE gamemusic_metadata_fts USING fts3
    ( content TEXT, game_id INT, title TEXT ) ;
    

    SELECT id, title FROM gamemusic_metadata_fts WHERE content MATCH "arcana" ;
    479|Arcana

    The ‘content’ column gets the metadata pseudo-documents. The SQL gets wrapped up in a little PHP so that it queries this small database and turns the result into JSON. The script is then ready as a drop-in replacement for the previous script.

  • SegFault while freeing nvenc hwdevice_ctx

    23 février 2024, par camelCase

    For a project, I created a class encoding the output of an OpenGL renderbuffer object using h264_nvenc. Unfortunately, tidying up doesn't work, and the program crashes with a SegFault. The reason is accessing an unaccessable memory region, happening twice in the final lines (see below) when calling av_buffer_unref( &_hwDeviceRefCtx ) and implicitely also during avcodec_free_context( &_pCodecCtx ), but both calls are required for shutting down.

    


    The (in this case relevant) valgrind-output is

    


    Invalid read of size 8
   at 0x48AD987: UnknownInlinedFun (buffer.c:121)
   by 0x48AD987: UnknownInlinedFun (buffer.c:144)
   by 0x48AD987: av_buffer_unref (buffer.c:139)
   by 0x5D06D7A: avcodec_close (avcodec.c:486)
   by 0x628DD7D: avcodec_free_context (options.c:175)
   by 0x10A863: main (main.cpp:115)
 Address 0x17812700 is 0 bytes inside a block of size 24 free'd
   at 0x484488F: free (vg_replace_malloc.c:985)
   by 0x48AD98F: UnknownInlinedFun (buffer.c:127)
   by 0x48AD98F: UnknownInlinedFun (buffer.c:144)
   by 0x48AD98F: av_buffer_unref (buffer.c:139)
   by 0x48BE098: hwframe_ctx_free (hwcontext.c:240)
   by 0x48AD9A6: UnknownInlinedFun (buffer.c:133)
   by 0x48AD9A6: UnknownInlinedFun (buffer.c:144)
   by 0x48AD9A6: av_buffer_unref (buffer.c:139)
   by 0x5D06D0A: UnknownInlinedFun (decode.c:1261)
   by 0x5D06D0A: avcodec_close (avcodec.c:465)
   by 0x628DD7D: avcodec_free_context (options.c:175)
   by 0x10A863: main (main.cpp:115)
 Block was alloc'd at
   at 0x4849366: posix_memalign (vg_replace_malloc.c:2099)
   by 0x48D9BD5: av_malloc (mem.c:105)
   by 0x48D9DAD: av_mallocz (mem.c:256)
   by 0x48AD8DD: UnknownInlinedFun (buffer.c:44)
   by 0x48AD8DD: av_buffer_create (buffer.c:64)
   by 0x48BDDEB: av_hwdevice_ctx_alloc (hwcontext.c:179)
   by 0x48BDF29: av_hwdevice_ctx_create (hwcontext.c:622)
   by 0x10A482: main (main.cpp:43)

Invalid free() / delete / delete[] / realloc()
   at 0x484488F: free (vg_replace_malloc.c:985)
   by 0x48AD98F: UnknownInlinedFun (buffer.c:127)
   by 0x48AD98F: UnknownInlinedFun (buffer.c:144)
   by 0x48AD98F: av_buffer_unref (buffer.c:139)
   by 0x5D06D7A: avcodec_close (avcodec.c:486)
   by 0x628DD7D: avcodec_free_context (options.c:175)
   by 0x10A863: main (main.cpp:115)
 Address 0x17812700 is 0 bytes inside a block of size 24 free'd
   at 0x484488F: free (vg_replace_malloc.c:985)
   by 0x48AD98F: UnknownInlinedFun (buffer.c:127)
   by 0x48AD98F: UnknownInlinedFun (buffer.c:144)
   by 0x48AD98F: av_buffer_unref (buffer.c:139)
   by 0x48BE098: hwframe_ctx_free (hwcontext.c:240)
   by 0x48AD9A6: UnknownInlinedFun (buffer.c:133)
   by 0x48AD9A6: UnknownInlinedFun (buffer.c:144)
   by 0x48AD9A6: av_buffer_unref (buffer.c:139)
   by 0x5D06D0A: UnknownInlinedFun (decode.c:1261)
   by 0x5D06D0A: avcodec_close (avcodec.c:465)
   by 0x628DD7D: avcodec_free_context (options.c:175)
   by 0x10A863: main (main.cpp:115)
 Block was alloc'd at
   at 0x4849366: posix_memalign (vg_replace_malloc.c:2099)
   by 0x48D9BD5: av_malloc (mem.c:105)
   by 0x48D9DAD: av_mallocz (mem.c:256)
   by 0x48AD8DD: UnknownInlinedFun (buffer.c:44)
   by 0x48AD8DD: av_buffer_create (buffer.c:64)
   by 0x48BDDEB: av_hwdevice_ctx_alloc (hwcontext.c:179)
   by 0x48BDF29: av_hwdevice_ctx_create (hwcontext.c:622)
   by 0x10A482: main (main.cpp:43)


    


    that is also duplicated (due to the calls to avcodec_free_context() and av_buffer_unref()).

    


    The question is : How can I fix this ?

    


    The (more or less) minimal (not) working example reads

    


    #include <string>&#xA;&#xA;extern "C" {&#xA;  #include <libavutil></libavutil>opt.h>&#xA;  #include <libavcodec></libavcodec>avcodec.h>&#xA;  #include <libavformat></libavformat>avformat.h>&#xA;  #include <libavutil></libavutil>hwcontext.h>&#xA;  #include <libavutil></libavutil>pixdesc.h>&#xA;  #include <libavutil></libavutil>hwcontext_cuda.h>&#xA;}&#xA;&#xA;//(former) libx264 encoding based on https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/muxing.c&#xA;//update to h264_nvenc with a lot of help from https://stackoverflow.com/questions/49862610/opengl-to-ffmpeg-encode&#xA;//and some additional info of https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/vaapi_encode.c&#xA;&#xA;int main() {&#xA;    const int _SrcImageWidth=640;&#xA;    const int _SrcImageHeight=480;&#xA;    &#xA;    const AVOutputFormat *_oFmt = nullptr;&#xA;    AVFormatContext *_oFmtCtx = nullptr;&#xA;    &#xA;    const AVCodec *_pCodec = nullptr;&#xA;    AVCodecContext *_pCodecCtx = nullptr;&#xA;    &#xA;    AVFrame* _frame;&#xA;    AVPacket* _packet;&#xA;    AVStream* _stream;&#xA;    &#xA;    AVBufferRef *_hwDeviceRefCtx = nullptr;&#xA;    const CUcontext* _cudaCtx;&#xA;    &#xA;    const std::string _OutFileName = "output.mkv";&#xA;    &#xA;    //constructor part&#xA;    int ret;&#xA;&#xA;    //output format context      &#xA;    avformat_alloc_output_context2( &amp;_oFmtCtx, nullptr, nullptr, _OutFileName.c_str() );&#xA;    _oFmt = _oFmtCtx->oformat;&#xA;&#xA;    //hardware format context&#xA;    ret = av_hwdevice_ctx_create( &amp;_hwDeviceRefCtx, AV_HWDEVICE_TYPE_CUDA, "NVIDIA GeForce RTX 4070", nullptr, 0 );&#xA;&#xA;    //hardware frame context for device buffer allocation&#xA;    AVBufferRef* hwFrameRefCtx = av_hwframe_ctx_alloc( _hwDeviceRefCtx );&#xA;    AVHWFramesContext* hwFrameCtx = (AVHWFramesContext*) (hwFrameRefCtx->data);&#xA;    hwFrameCtx->width = _SrcImageWidth;&#xA;    hwFrameCtx->height = _SrcImageHeight;&#xA;    hwFrameCtx->sw_format = AV_PIX_FMT_0BGR32;&#xA;    hwFrameCtx->format = AV_PIX_FMT_CUDA;&#xA;    hwFrameCtx->device_ref = _hwDeviceRefCtx;&#xA;    hwFrameCtx->device_ctx = (AVHWDeviceContext*) _hwDeviceRefCtx->data;&#xA;&#xA;    ret = av_hwframe_ctx_init( hwFrameRefCtx );&#xA;&#xA;    //get cuda context&#xA;    const AVHWDeviceContext* hwDeviceCtx = (AVHWDeviceContext*)(_hwDeviceRefCtx->data);&#xA;    const AVCUDADeviceContext* cudaDeviceCtx = (AVCUDADeviceContext*)(hwDeviceCtx->hwctx);&#xA;    _cudaCtx = &amp;(cudaDeviceCtx->cuda_ctx);&#xA;&#xA;    //codec context&#xA;    _pCodec = avcodec_find_encoder_by_name( "h264_nvenc" );&#xA;&#xA;    _packet = av_packet_alloc();&#xA;&#xA;    _stream = avformat_new_stream( _oFmtCtx, nullptr );&#xA;    _stream->id = _oFmtCtx->nb_streams - 1;&#xA;    _pCodecCtx = avcodec_alloc_context3( _pCodec );&#xA;&#xA;    _pCodecCtx->qmin = 18;&#xA;    _pCodecCtx->qmax = 20;&#xA;    _pCodecCtx->width = _SrcImageWidth;&#xA;    _pCodecCtx->height = _SrcImageHeight;&#xA;    _pCodecCtx->framerate = (AVRational) {25,1};&#xA;    _pCodecCtx->time_base = (AVRational) {1,25};&#xA;    _stream->time_base = _pCodecCtx->time_base;&#xA;    _pCodecCtx->gop_size = 12; //I-Frame every at most 12 frames&#xA;    _pCodecCtx->max_b_frames = 2;&#xA;    _pCodecCtx->pix_fmt = AV_PIX_FMT_CUDA; //required to use renderbuffer as src&#xA;    _pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    _pCodecCtx->sw_pix_fmt = AV_PIX_FMT_0BGR32; &#xA;    _pCodecCtx->hw_device_ctx = _hwDeviceRefCtx;&#xA;    _pCodecCtx->hw_frames_ctx = av_buffer_ref( hwFrameRefCtx );&#xA;    av_opt_set(_pCodecCtx->priv_data, "preset", "p7", 0);&#xA;    av_opt_set(_pCodecCtx->priv_data, "rc", "vbr", 0);&#xA;    if( _oFmtCtx->oformat->flags &amp; AVFMT_GLOBALHEADER ) {&#xA;        _pCodecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    }&#xA;&#xA;    ret = avcodec_open2( _pCodecCtx, _pCodec, nullptr );&#xA;    avcodec_parameters_from_context( _stream->codecpar, _pCodecCtx );&#xA;&#xA;    if (!(_oFmtCtx->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        ret = avio_open(&amp;_oFmtCtx->pb, _OutFileName.c_str(), AVIO_FLAG_WRITE);&#xA;    }&#xA;    ret = avformat_write_header( _oFmtCtx, nullptr );&#xA;&#xA;    //use hardware frame from above&#xA;    _frame = av_frame_alloc();&#xA;    ret = av_hwframe_get_buffer( _pCodecCtx->hw_frames_ctx, _frame, 0 );&#xA;    _frame->pts = 1;&#xA;&#xA;    av_buffer_unref( &amp;hwFrameRefCtx );&#xA;&#xA;    //destructor part&#xA;    av_frame_free( &amp;_frame );&#xA;    av_packet_free( &amp;_packet );&#xA;&#xA;    av_write_trailer( _oFmtCtx );&#xA;    avio_closep( &amp;_oFmtCtx->pb );&#xA;&#xA;    avformat_free_context( _oFmtCtx );&#xA;&#xA;    avcodec_free_context( &amp;_pCodecCtx );&#xA;    av_buffer_unref( &amp;_hwDeviceRefCtx );&#xA;&#xA;    return 0;&#xA;}&#xA;</string>

    &#xA;

    and compiles with (linux user)

    &#xA;

    g&#x2B;&#x2B; -lavutil -lavformat -lavcodec -lz -lavutil -lswscale -lswresample -lm -ggdb3 -I/opt/cuda/include main.cpp&#xA;

    &#xA;

    Thanks in advance !

    &#xA;

  • Is there a way to extract frames from a video file using ffmpeg to memory and make some manipulation on each frame ?

    28 octobre 2022, par Rojer Brief

    The goal is to extract each time a frame from the video file then make histogram from the image and then to move to the next frame. this way all the frames.

    &#xA;

    The frames extraction and the histogram manipulation is working fine when the frames have saved as images on the hard disk. but now i want to do it all in memory.

    &#xA;

    to extract the frames i'm using ffmpeg because i think it's fast enough :

    &#xA;

    ffmpeg -r 1 -i MyVid.mp4 -r 1 "$filename%03d.png&#xA;

    &#xA;

    for now i'm using the ffmpeg in command prompt window.

    &#xA;

    with this command it will save on the hard disk over 65000 images(frames).&#xA;but instead saving them on the hard disk i wonder if i can make the histogram manipulation on each frame in memory instead saving all the 65000 frames to the hard disk.

    &#xA;

    then i want to find specific images using the histogram and save to the hard disk this frames.

    &#xA;

    the histogram part for now is also using files from the hard disk and not from the memory :

    &#xA;

    private void btnLoadHistogram_Click(object sender, System.EventArgs e)&#xA;        {&#xA;            string[] files = Directory.GetFiles(@"d:\screenshots\", "*.jpg");&#xA;&#xA;            for (int i = 0; i &lt; files.Length; i&#x2B;&#x2B;)&#xA;            {&#xA;                sbInfo.Text = "Loading image";&#xA;                if (pbImage.Image != null)&#xA;                    pbImage.Image.Dispose();&#xA;&#xA;                pbImage.Image = Image.FromFile(files[i]);//txtFileName.Text);&#xA;&#xA;                Application.DoEvents();&#xA;&#xA;                sbInfo.Text = "Computing histogram";&#xA;                long[] myValues = GetHistogram(new Bitmap(pbImage.Image));&#xA;&#xA;                Histogram.DrawHistogram(myValues);&#xA;&#xA;                sbInfo.Text = "";   &#xA;            }   &#xA;        }&#xA;&#xA;        public long[] GetHistogram(System.Drawing.Bitmap picture)&#xA;        {&#xA;            long[] myHistogram = new long[256];&#xA;&#xA;            for (int i=0;i3;&#xA;                    myHistogram[Temp]&#x2B;&#x2B;;&#xA;                }&#xA;&#xA;            return myHistogram;&#xA;        }&#xA;

    &#xA;

    and the code of the class of the constrol HistogramaDesenat :

    &#xA;

    using System;&#xA;using System.Collections;&#xA;using System.ComponentModel;&#xA;using System.Drawing;&#xA;using System.Data;&#xA;using System.Windows.Forms;&#xA;&#xA;namespace Histograma&#xA;{&#xA;    /// <summary>&#xA;    /// Summary description for HistogramaDesenat.&#xA;    /// </summary>&#xA;    public class HistogramaDesenat : System.Windows.Forms.UserControl&#xA;    {&#xA;        /// <summary> &#xA;        /// Required designer variable.&#xA;        /// </summary>&#xA;        private System.ComponentModel.Container components = null;&#xA;&#xA;        public HistogramaDesenat()&#xA;        {&#xA;            // This call is required by the Windows.Forms Form Designer.&#xA;            InitializeComponent();&#xA;&#xA;            // TODO: Add any initialization after the InitializeComponent call&#xA;&#xA;            this.Paint &#x2B;= new PaintEventHandler(HistogramaDesenat_Paint);&#xA;            this.Resize&#x2B;=new EventHandler(HistogramaDesenat_Resize);&#xA;        }&#xA;&#xA;        /// <summary> &#xA;        /// Clean up any resources being used.&#xA;        /// </summary>&#xA;        protected override void Dispose( bool disposing )&#xA;        {&#xA;            if( disposing )&#xA;            {&#xA;                if(components != null)&#xA;                {&#xA;                    components.Dispose();&#xA;                }&#xA;            }&#xA;            base.Dispose( disposing );&#xA;        }&#xA;&#xA;        #region Component Designer generated code&#xA;        /// <summary> &#xA;        /// Required method for Designer support - do not modify &#xA;        /// the contents of this method with the code editor.&#xA;        /// </summary>&#xA;        private void InitializeComponent()&#xA;        {&#xA;            // &#xA;            // HistogramaDesenat&#xA;            // &#xA;            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));&#xA;            this.Name = "HistogramaDesenat";&#xA;            this.Size = new System.Drawing.Size(208, 176);&#xA;        }&#xA;        #endregion&#xA;&#xA;        private void HistogramaDesenat_Paint(object sender, PaintEventArgs e)&#xA;        {&#xA;            if (myIsDrawing)&#xA;            {&#xA;&#xA;                Graphics g = e.Graphics;&#xA;                Pen myPen = new Pen(new SolidBrush(myColor),myXUnit);&#xA;                //The width of the pen is given by the XUnit for the control.&#xA;                for (int i=0;i/We draw each line &#xA;                    g.DrawLine(myPen,&#xA;                        new PointF(myOffset &#x2B; (i*myXUnit), this.Height - myOffset), &#xA;                        new PointF(myOffset &#x2B; (i*myXUnit), this.Height - myOffset - myValues[i] * myYUnit));&#xA;&#xA;                    //We plot the coresponding index for the maximum value.&#xA;                    if (myValues[i]==myMaxValue)&#xA;                    {&#xA;                        SizeF mySize = g.MeasureString(i.ToString(),myFont);&#xA;&#xA;                        g.DrawString(i.ToString(),myFont,new SolidBrush(myColor),&#xA;                            new PointF(myOffset &#x2B; (i*myXUnit) - (mySize.Width/2), this.Height - myFont.Height ),&#xA;                            System.Drawing.StringFormat.GenericDefault);&#xA;                    }&#xA;                }&#xA;&#xA;                //We draw the indexes for 0 and for the length of the array beeing plotted&#xA;                g.DrawString("0",myFont, new SolidBrush(myColor),new PointF(myOffset,this.Height - myFont.Height),System.Drawing.StringFormat.GenericDefault);&#xA;                g.DrawString((myValues.Length-1).ToString(),myFont, &#xA;                    new SolidBrush(myColor),&#xA;                    new PointF(myOffset &#x2B; (myValues.Length * myXUnit) - g.MeasureString((myValues.Length-1).ToString(),myFont).Width,&#xA;                    this.Height - myFont.Height),&#xA;                    System.Drawing.StringFormat.GenericDefault);&#xA;&#xA;                //We draw a rectangle surrounding the control.&#xA;                g.DrawRectangle(new System.Drawing.Pen(new SolidBrush(Color.Black),1),0,0,this.Width-1,this.Height-1);&#xA;            }&#xA;&#xA;        }&#xA;&#xA;        long myMaxValue;&#xA;        private long[] myValues;&#xA;        private bool myIsDrawing;&#xA;&#xA;        private float myYUnit; //this gives the vertical unit used to scale our values&#xA;        private float myXUnit; //this gives the horizontal unit used to scale our values&#xA;        private int myOffset = 20; //the offset, in pixels, from the control margins.&#xA;&#xA;        private Color myColor = Color.Black;&#xA;        private Font myFont = new Font("Tahoma",10);&#xA;&#xA;        [Category("Histogram Options")]&#xA;        [Description ("The distance from the margins for the histogram")]&#xA;        public int Offset&#xA;        {&#xA;            set&#xA;            {&#xA;                if (value>0)&#xA;                    myOffset= value;&#xA;            }&#xA;            get&#xA;            {&#xA;                return myOffset;&#xA;            }&#xA;        }&#xA;&#xA;        [Category("Histogram Options")]&#xA;        [Description ("The color used within the control")]&#xA;        public Color DisplayColor&#xA;        {&#xA;            set&#xA;            {&#xA;                myColor = value;&#xA;            }&#xA;            get&#xA;            {&#xA;                return myColor;&#xA;            }&#xA;        }&#xA;&#xA;        /// <summary>&#xA;        /// We draw the histogram on the control&#xA;        /// </summary>&#xA;        /// The values beeing draw&#xA;        public void DrawHistogram(long[] Values)&#xA;        {&#xA;            myValues = new long[Values.Length];&#xA;            Values.CopyTo(myValues,0);&#xA;&#xA;            myIsDrawing = true;&#xA;            myMaxValue = getMaxim(myValues);&#xA;&#xA;            ComputeXYUnitValues();&#xA;&#xA;            this.Refresh();&#xA;        }&#xA;&#xA;        /// <summary>&#xA;        /// We get the highest value from the array&#xA;        /// </summary>&#xA;        /// The array of values in which we look&#xA;        /// <returns>The maximum value</returns>&#xA;        private long getMaxim(long[] Vals)&#xA;        {&#xA;            if (myIsDrawing)&#xA;            {&#xA;                long max = 0;&#xA;                for (int i=0;i max)&#xA;                        max = Vals[i];&#xA;                }&#xA;                return max;&#xA;            }&#xA;            return 1;&#xA;        }&#xA;&#xA;        private void HistogramaDesenat_Resize(object sender, EventArgs e)&#xA;        {&#xA;            if (myIsDrawing)&#xA;            {&#xA;                ComputeXYUnitValues();&#xA;            }&#xA;            this.Refresh();&#xA;        }&#xA;&#xA;        private void ComputeXYUnitValues()&#xA;        {&#xA;            myYUnit = (float) (this.Height - (2 * myOffset)) / myMaxValue;&#xA;            myXUnit = (float) (this.Width - (2 * myOffset)) / (myValues.Length-1);&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;

    so in the end this is what i want to do :

    &#xA;

      &#xA;
    • extract the frames from the video file in memory using the ffmpeg.

      &#xA;

    • &#xA;

    • instead using Directory.GetFiles i want to make the histogram manipulation on each frame from the memory that is extracted by the ffmpeg.

      &#xA;

    • &#xA;

    • each extracted frame image to use the histogram to find if there is a lightning(weather lightning) in the image.

      &#xA;

    • &#xA;

    • if there is a lightning save the frame image to the hard disk.

      &#xA;

    • &#xA;

    &#xA;