Recherche avancée

Médias (0)

Mot : - Tags -/presse-papier

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

Autres articles (78)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

Sur d’autres sites (6353)

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

    


    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.

    


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

    


    ffmpeg -r 1 -i MyVid.mp4 -r 1 "$filename%03d.png


    


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

    


    with this command it will save on the hard disk over 65000 images(frames).
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.

    


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

    


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

    


    private void btnLoadHistogram_Click(object sender, System.EventArgs e)
        {
            string[] files = Directory.GetFiles(@"d:\screenshots\", "*.jpg");

            for (int i = 0; i < files.Length; i++)
            {
                sbInfo.Text = "Loading image";
                if (pbImage.Image != null)
                    pbImage.Image.Dispose();

                pbImage.Image = Image.FromFile(files[i]);//txtFileName.Text);

                Application.DoEvents();

                sbInfo.Text = "Computing histogram";
                long[] myValues = GetHistogram(new Bitmap(pbImage.Image));

                Histogram.DrawHistogram(myValues);

                sbInfo.Text = "";   
            }   
        }

        public long[] GetHistogram(System.Drawing.Bitmap picture)
        {
            long[] myHistogram = new long[256];

            for (int i=0;i3;
                    myHistogram[Temp]++;
                }

            return myHistogram;
        }


    


    and the code of the class of the constrol HistogramaDesenat :

    


    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;

  • ffmpeg for android, out of memory on encoding h264

    15 juin 2018, par Rafael Lima

    I’m getting an weird error when enconding a video with ffmpeg on android

    Failed to inject frame into filter network: Out of memory

    Althoug is a pretty objective error, I do believe this is some "generic message" for another problem, because the video I used for testing is 17MB and less than 11 seconds length and I’ve sucessfully tested with videos bigger than 200MB and longer than 5min

    This problem happens to any video vertical videos recorded on my phone (the videos were recorded and play fine on my phone but i cant reencode them... other video h264 were encoded fine on same phone)

    this is ffmpeg output

    ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
     built with Android (4691093 based on r316199) clang version 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55536e7d904e0abae47888fc7f) (https://android.googlesource.com/toolchain/llvm 34361f192e41ed6e4e8f9aca80a4ea7e9856f327) (based on LLVM 6.0.2svn)
     configuration: --prefix=/home/rafa/Desktop/m4/build --target-os=android --arch=i686 --cpu=i686 --cross-prefix=/home/rafa/Desktop/m4/ndk/toolchain/i686/bin/i686-linux-android- --enable-cross-compile --cc=/home/rafa/Desktop/m4/ndk/toolchain/i686/bin/clang --cxx=/home/rafa/Desktop/m4/ndk/toolchain/i686/bin/clang++ --pkg-config=/usr/bin/pkg-config --pkg-config-flags=--static --enable-pic --enable-gpl --enable-nonfree --enable-static --disable-shared --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-doc --disable-devices --enable-libx264 --enable-libfdk-aac --enable-bsf=aac_adtstoasc --disable-asm
     libavutil      56. 14.100 / 56. 14.100
     libavcodec     58. 18.100 / 58. 18.100
     libavformat    58. 12.100 / 58. 12.100
     libavdevice    58.  3.100 / 58.  3.100
     libavfilter     7. 16.100 /  7. 16.100
     libswscale      5.  1.100 /  5.  1.100
     libswresample   3.  1.100 /  3.  1.100
     libpostproc    55.  1.100 / 55.  1.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/data/com.tomatedigital.toolsforinstagram/qqq.mp4':
     Metadata:  
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: isommp42
       creation_time   : 2018-06-09T04:28:55.000000Z
       location        : -08.0638-034.8723/
       location-eng    : -08.0638-034.8723/
       com.android.version: 7.0
     Duration: 00:00:09.06, start: 0.000000, bitrate: 17349 kb/s
       Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 17088 kb/s, SAR 1:1 DAR 16:9, 30.04 fps, 30 tbr, 90k tbn, 180k tbc (default)
       Metadata:
         rotate          : 90
         creation_time   : 2018-06-09T04:28:55.000000Z
         handler_name    : VideoHandle
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
       Metadata:
         creation_time   : 2018-06-09T04:28:55.000000Z
         handler_name    : SoundHandle
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
     Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    Error reinitializing filters!
    Failed to inject frame into filter network: Out of memory
    Error while processing the decoded data for stream #0:0
    Conversion failed!

    =====================UPDATE===================

    I re-run the command with -v 9 -loglevel 99 and got paste the log file at :

    https://pastebin.com/ihawsPvZ

    If someone have real good expertise at ffmpeg i would apreciate very much the help

    =====================UPDATE 2=================

    I made more tests and the problem happens only when i record the video with my phone at vertical (other videos in vertical work and videos from my phone in horizontal also work)

    ==================UPDATE 3====================
    I detected the problem happens to ANY video with the

    Metadata:
         rotate          : 90 (or any value)

    It was suggested to use -noautorotate as workaround and it WORKDED, but this implies in tons of other complications ex :

    -if i decide to apply any filter to the video, it will be applied to the horizontal version but the video will be played at vertical producing a totally different effect

    ex : https://i.stack.imgur.com/R3jXJ.jpg (at this photo the drawtext filter should be placed at bottom line with horizontal text, but as ffmpeg can’t handle the orientation it is missplaced and rotated at runtime producing this vertical message)

    -I checked and if I set -metadata:s:v:0 rotate= while enconding it has no effect ex :

    ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate= output.mp4
    will remove the rotate metadata and produce a non rotated video

    BUT
    ffmpeg -i input.mp4 -c:v libx264 -metadata:s:v:0 rotate= output.mp4
    will keep the metadata and the produced video will be played rotated (this behavior was also noticed on the official ffmpeg 4.0 binaries for windows available at ffmpeg website)

    I’M STILL LOOKING FOR A BETTER SOLUTION, THANKS FOR THE HELP

  • ffmpeg for android, out of memory on encoding h264

    15 juin 2018, par Rafael Lima

    I’m getting an weird error when enconding a video with ffmpeg on android

    Failed to inject frame into filter network: Out of memory

    Althoug is a pretty objective error, I do believe this is some "generic message" for another problem, because the video I used for testing is 17MB and less than 11 seconds length and I’ve sucessfully tested with videos bigger than 200MB and longer than 5min

    This problem happens to any video vertical videos recorded on my phone (the videos were recorded and play fine on my phone but i cant reencode them... other video h264 were encoded fine on same phone)

    this is ffmpeg output

    ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
     built with Android (4691093 based on r316199) clang version 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55536e7d904e0abae47888fc7f) (https://android.googlesource.com/toolchain/llvm 34361f192e41ed6e4e8f9aca80a4ea7e9856f327) (based on LLVM 6.0.2svn)
     configuration: --prefix=/home/rafa/Desktop/m4/build --target-os=android --arch=i686 --cpu=i686 --cross-prefix=/home/rafa/Desktop/m4/ndk/toolchain/i686/bin/i686-linux-android- --enable-cross-compile --cc=/home/rafa/Desktop/m4/ndk/toolchain/i686/bin/clang --cxx=/home/rafa/Desktop/m4/ndk/toolchain/i686/bin/clang++ --pkg-config=/usr/bin/pkg-config --pkg-config-flags=--static --enable-pic --enable-gpl --enable-nonfree --enable-static --disable-shared --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-doc --disable-devices --enable-libx264 --enable-libfdk-aac --enable-bsf=aac_adtstoasc --disable-asm
     libavutil      56. 14.100 / 56. 14.100
     libavcodec     58. 18.100 / 58. 18.100
     libavformat    58. 12.100 / 58. 12.100
     libavdevice    58.  3.100 / 58.  3.100
     libavfilter     7. 16.100 /  7. 16.100
     libswscale      5.  1.100 /  5.  1.100
     libswresample   3.  1.100 /  3.  1.100
     libpostproc    55.  1.100 / 55.  1.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/data/com.tomatedigital.toolsforinstagram/qqq.mp4':
     Metadata:  
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: isommp42
       creation_time   : 2018-06-09T04:28:55.000000Z
       location        : -08.0638-034.8723/
       location-eng    : -08.0638-034.8723/
       com.android.version: 7.0
     Duration: 00:00:09.06, start: 0.000000, bitrate: 17349 kb/s
       Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 17088 kb/s, SAR 1:1 DAR 16:9, 30.04 fps, 30 tbr, 90k tbn, 180k tbc (default)
       Metadata:
         rotate          : 90
         creation_time   : 2018-06-09T04:28:55.000000Z
         handler_name    : VideoHandle
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
       Metadata:
         creation_time   : 2018-06-09T04:28:55.000000Z
         handler_name    : SoundHandle
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
     Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    Error reinitializing filters!
    Failed to inject frame into filter network: Out of memory
    Error while processing the decoded data for stream #0:0
    Conversion failed!

    =====================UPDATE===================

    I re-run the command with -v 9 -loglevel 99 and got paste the log file at :

    https://pastebin.com/ihawsPvZ

    If someone have real good expertise at ffmpeg i would apreciate very much the help

    =====================UPDATE 2=================

    I made more tests and the problem happens only when i record the video with my phone at vertical (other videos in vertical work and videos from my phone in horizontal also work)

    ==================UPDATE 3====================
    I detected the problem happens to ANY video with the

    Metadata:
         rotate          : 90 (or any value)

    It was suggested to use -noautorotate as workaround and it WORKDED, but this implies in tons of other complications ex :

    -if i decide to apply any filter to the video, it will be applied to the horizontal version but the video will be played at vertical producing a totally different effect

    ex : https://i.stack.imgur.com/R3jXJ.jpg (at this photo the drawtext filter should be placed at bottom line with horizontal text, but as ffmpeg can’t handle the orientation it is missplaced and rotated at runtime producing this vertical message)

    -I checked and if I set -metadata:s:v:0 rotate= while enconding it has no effect ex :

    ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate= output.mp4
    will remove the rotate metadata and produce a non rotated video

    BUT
    ffmpeg -i input.mp4 -c:v libx264 -metadata:s:v:0 rotate= output.mp4
    will keep the metadata and the produced video will be played rotated (this behavior was also noticed on the official ffmpeg 4.0 binaries for windows available at ffmpeg website)

    I’M STILL LOOKING FOR A BETTER SOLUTION, THANKS FOR THE HELP