Recherche avancée

Médias (1)

Mot : - Tags -/copyleft

Autres articles (99)

  • 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

  • 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" ;

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

Sur d’autres sites (5470)

  • Using Accord.Video.FFMPEG, I get parameter is not valid exception. How to solve it ?

    14 avril 2023, par Sheron Blumental

    I want to extract all the frames from a mp4 video file and display them on a PictureBox.

    


    The original code comes from this Q&A :
    
How to time the presentation and extraction of frames from a video file ?

    


    The exception happens after clicking the start button on the line :

    


    var frame = videoReader.ReadVideoFrame();


    


    the message

    


    System.ArgumentException&#xA;  HResult=0x80070057&#xA;  Message=Parameter is not valid.&#xA;  Source=System.Drawing&#xA;  StackTrace:&#xA;   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)&#xA;   at Accord.Video.FFMPEG.VideoFileReader.DecodeVideoFrame(BitmapData bitmapData)&#xA;   at Accord.Video.FFMPEG.VideoFileReader.readVideoFrame(Int32 frameIndex, BitmapData output)&#xA;   at Accord.Video.FFMPEG.VideoFileReader.ReadVideoFrame()&#xA;   at Extract_Frames.Form1.<getvideoframesasync>d__15.MoveNext() in D:\Csharp Projects\Extract Frames\Form1.cs:line 114&#xA;   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&#xA;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xA;   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()&#xA;   at Extract_Frames.Form1.d__17.MoveNext() in D:\Csharp Projects\Extract Frames\Form1.cs:line 151&#xA;</getvideoframesasync>

    &#xA;

    the full code

    &#xA;

    using Accord.IO;&#xA;using Accord.Video;&#xA;using Accord.Video.FFMPEG;&#xA;using System;&#xA;using System.Collections.Generic;&#xA;using System.ComponentModel;&#xA;using System.Data;&#xA;using System.Drawing;&#xA;using System.IO;&#xA;using System.Linq;&#xA;using System.Reflection;&#xA;using System.Reflection.Emit;&#xA;using System.Text;&#xA;using System.Threading;&#xA;using System.Threading.Tasks;&#xA;using System.Windows.Forms;&#xA;&#xA;namespace Extract_Frames&#xA;{&#xA;    public partial class Form1 : Form&#xA;    {&#xA;        Bitmap frame = null;&#xA;        Graphics frameGraphics = null;&#xA;        bool isVideoRunning = false;&#xA;        IProgress<bitmap> videoProgress = null;&#xA;        private CancellationTokenSource cts = null;&#xA;        private readonly object syncRoot = new object();&#xA;        private static long pause = 0;&#xA;        private int frameRate = 0;&#xA;        private List<bitmap> frames = new List<bitmap>();&#xA;        string fileName;&#xA;&#xA;        public Form1()&#xA;        {&#xA;            InitializeComponent();&#xA;            &#xA;        }&#xA;&#xA;        private void Form1_Load(object sender, EventArgs e)&#xA;        {&#xA;&#xA;        }&#xA;&#xA;        private void StopPlayback(bool cancel)&#xA;        {&#xA;            lock (syncRoot)&#xA;            {&#xA;                if (cancel) cts?.Cancel();&#xA;                cts?.Dispose();&#xA;                cts = null;&#xA;            }&#xA;        }&#xA;&#xA;        int counter =1;&#xA;        private void Updater(Bitmap videoFrame)&#xA;        {&#xA;            frames.Add(videoFrame);&#xA;&#xA;            label1.Text = "Current Frame Number : " &#x2B; counter;&#xA;            trackBar1.Value = counter;&#xA;            counter&#x2B;&#x2B;;&#xA;&#xA;            //Size size = new Size(videoFrame.Width, videoFrame.Height);&#xA;            //pictureBox1.ClientSize = size;&#xA;            using (videoFrame) frameGraphics.DrawImage(videoFrame, Point.Empty);&#xA;&#xA;            pictureBox1.Invalidate();&#xA;        }&#xA;&#xA;        private async Task GetVideoFramesAsync(IProgress<bitmap> updater, string fileName, int intervalMs, CancellationToken token = default)&#xA;        {&#xA;            using (var videoReader = new VideoFileReader())&#xA;            {&#xA;                if (token.IsCancellationRequested) return;&#xA;                videoReader.Open(fileName);&#xA;&#xA;                videoReader.ReadVideoFrame(1);&#xA;                trackBar1.Value = 1;&#xA;&#xA;                label1.Text = "Current Frame Number : " &#x2B; counter.ToString();&#xA;&#xA;                while (true)&#xA;                {&#xA;                    if (Interlocked.Read(ref pause) == 0)&#xA;                    {&#xA;                        var frame = videoReader.ReadVideoFrame();&#xA;&#xA;                        if (token.IsCancellationRequested || frame is null) break;&#xA;                        updater.Report(frame);&#xA;                    }&#xA;                    await Task.Delay(frameRate).ConfigureAwait(false);&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;        private void trackBar2_Scroll(object sender, EventArgs e)&#xA;        {&#xA;            frameRate = trackBar2.Value / 25;&#xA;        }&#xA;&#xA;        private async void buttonStart_Click(object sender, EventArgs e)&#xA;        {&#xA;            string fileName = textBox1.Text;&#xA;&#xA;            if (isVideoRunning) return;&#xA;            isVideoRunning = true;&#xA;&#xA;            using (var videoReader = new VideoFileReader())&#xA;            {&#xA;                videoReader.Open(fileName);&#xA;                frame = new Bitmap(videoReader.Width &#x2B; 2, videoReader.Height &#x2B; 2);&#xA;                trackBar1.Maximum = (int)videoReader.FrameCount;&#xA;            }&#xA;&#xA;            videoProgress = new Progress<bitmap>((bitmap) => Updater(bitmap));&#xA;            cts = new CancellationTokenSource();&#xA;            pictureBox1.Image = frame;&#xA;            try&#xA;            {&#xA;                frameGraphics = Graphics.FromImage(frame);&#xA;                // Set the fame rate to 25 frames per second&#xA;                //int frameRate = 1000 / 25;&#xA;                await GetVideoFramesAsync(videoProgress, fileName, frameRate, cts.Token);&#xA;            }&#xA;            finally&#xA;            {&#xA;                frameGraphics?.Dispose();&#xA;                StopPlayback(false);&#xA;                isVideoRunning = false;&#xA;            }&#xA;        }&#xA;&#xA;        private void buttonPause_Click(object sender, EventArgs e)&#xA;        {&#xA;            if (pause == 0)&#xA;            {&#xA;                buttonPause.Text = "Resume";&#xA;                Interlocked.Increment(ref pause);&#xA;            }&#xA;            else&#xA;            {&#xA;                Interlocked.Decrement(ref pause);&#xA;                buttonPause.Text = "Pause";&#xA;            }&#xA;        }&#xA;&#xA;        private void buttonStop_Click(object sender, EventArgs e)&#xA;        {&#xA;            StopPlayback(true);&#xA;        }&#xA;&#xA;        protected override void OnFormClosing(FormClosingEventArgs e)&#xA;        {&#xA;            if (isVideoRunning) StopPlayback(true);&#xA;            pictureBox1.Image?.Dispose();&#xA;            base.OnFormClosing(e);&#xA;        }&#xA;&#xA;        private void pictureBox1_Paint(object sender, PaintEventArgs e)&#xA;        {&#xA;            ControlPaint.DrawBorder(e.Graphics, pictureBox1.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);&#xA;        }&#xA;&#xA;        private void trackBar1_Scroll(object sender, EventArgs e)&#xA;        {&#xA;            pictureBox1.Image = frames[trackBar1.Value];&#xA;        }&#xA;&#xA;        private void button1_Click(object sender, EventArgs e)&#xA;        {&#xA;            using (OpenFileDialog openFileDialog = new OpenFileDialog())&#xA;            {&#xA;                openFileDialog.InitialDirectory = "c:\\";&#xA;                openFileDialog.Filter = "video files (*.mp4)|*.mp4|All files (*.*)|*.*";&#xA;                openFileDialog.FilterIndex = 2;&#xA;                openFileDialog.RestoreDirectory = true;&#xA;&#xA;                if (openFileDialog.ShowDialog() == DialogResult.OK)&#xA;                {&#xA;                    //Get the path of specified file&#xA;                    textBox1.Text = openFileDialog.FileName;&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;</bitmap></bitmap></bitmap></bitmap></bitmap>

    &#xA;

  • using Accord.Video.FFMPEG aka(AForge) give exception error paramter is not valid. how to solve it ?

    12 avril 2023, par Sheron Blumental

    I want to extract all the frames from a mp4 video file and display them on a pictureBox.

    &#xA;

    The exception happens after clicking the start button on the line :

    &#xA;

    var frame = videoReader.ReadVideoFrame();&#xA;

    &#xA;

    the message

    &#xA;

    System.ArgumentException&#xA;  HResult=0x80070057&#xA;  Message=Parameter is not valid.&#xA;  Source=System.Drawing&#xA;  StackTrace:&#xA;   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)&#xA;   at Accord.Video.FFMPEG.VideoFileReader.DecodeVideoFrame(BitmapData bitmapData)&#xA;   at Accord.Video.FFMPEG.VideoFileReader.readVideoFrame(Int32 frameIndex, BitmapData output)&#xA;   at Accord.Video.FFMPEG.VideoFileReader.ReadVideoFrame()&#xA;   at Extract_Frames.Form1.<getvideoframesasync>d__15.MoveNext() in D:\Csharp Projects\Extract Frames\Form1.cs:line 114&#xA;   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)&#xA;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xA;   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()&#xA;   at Extract_Frames.Form1.d__17.MoveNext() in D:\Csharp Projects\Extract Frames\Form1.cs:line 151&#xA;</getvideoframesasync>

    &#xA;

    the full code

    &#xA;

    using Accord.IO;&#xA;using Accord.Video;&#xA;using Accord.Video.FFMPEG;&#xA;using System;&#xA;using System.Collections.Generic;&#xA;using System.ComponentModel;&#xA;using System.Data;&#xA;using System.Drawing;&#xA;using System.IO;&#xA;using System.Linq;&#xA;using System.Reflection;&#xA;using System.Reflection.Emit;&#xA;using System.Text;&#xA;using System.Threading;&#xA;using System.Threading.Tasks;&#xA;using System.Windows.Forms;&#xA;&#xA;namespace Extract_Frames&#xA;{&#xA;    public partial class Form1 : Form&#xA;    {&#xA;        Bitmap frame = null;&#xA;        Graphics frameGraphics = null;&#xA;        bool isVideoRunning = false;&#xA;        IProgress<bitmap> videoProgress = null;&#xA;        private CancellationTokenSource cts = null;&#xA;        private readonly object syncRoot = new object();&#xA;        private static long pause = 0;&#xA;        private int frameRate = 0;&#xA;        private List<bitmap> frames = new List<bitmap>();&#xA;        string fileName;&#xA;&#xA;        public Form1()&#xA;        {&#xA;            InitializeComponent();&#xA;            &#xA;        }&#xA;&#xA;        private void Form1_Load(object sender, EventArgs e)&#xA;        {&#xA;&#xA;        }&#xA;&#xA;        private void StopPlayback(bool cancel)&#xA;        {&#xA;            lock (syncRoot)&#xA;            {&#xA;                if (cancel) cts?.Cancel();&#xA;                cts?.Dispose();&#xA;                cts = null;&#xA;            }&#xA;        }&#xA;&#xA;        int counter =1;&#xA;        private void Updater(Bitmap videoFrame)&#xA;        {&#xA;            frames.Add(videoFrame);&#xA;&#xA;            label1.Text = "Current Frame Number : " &#x2B; counter;&#xA;            trackBar1.Value = counter;&#xA;            counter&#x2B;&#x2B;;&#xA;&#xA;            //Size size = new Size(videoFrame.Width, videoFrame.Height);&#xA;            //pictureBox1.ClientSize = size;&#xA;            using (videoFrame) frameGraphics.DrawImage(videoFrame, Point.Empty);&#xA;&#xA;            pictureBox1.Invalidate();&#xA;        }&#xA;&#xA;        private async Task GetVideoFramesAsync(IProgress<bitmap> updater, string fileName, int intervalMs, CancellationToken token = default)&#xA;        {&#xA;            using (var videoReader = new VideoFileReader())&#xA;            {&#xA;                if (token.IsCancellationRequested) return;&#xA;                videoReader.Open(fileName);&#xA;&#xA;                videoReader.ReadVideoFrame(1);&#xA;                trackBar1.Value = 1;&#xA;&#xA;                label1.Text = "Current Frame Number : " &#x2B; counter.ToString();&#xA;&#xA;                while (true)&#xA;                {&#xA;                    if (Interlocked.Read(ref pause) == 0)&#xA;                    {&#xA;                        var frame = videoReader.ReadVideoFrame();&#xA;&#xA;                        if (token.IsCancellationRequested || frame is null) break;&#xA;                        updater.Report(frame);&#xA;                    }&#xA;                    await Task.Delay(frameRate).ConfigureAwait(false);&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;        private void trackBar2_Scroll(object sender, EventArgs e)&#xA;        {&#xA;            frameRate = trackBar2.Value / 25;&#xA;        }&#xA;&#xA;        private async void buttonStart_Click(object sender, EventArgs e)&#xA;        {&#xA;            string fileName = textBox1.Text;&#xA;&#xA;            if (isVideoRunning) return;&#xA;            isVideoRunning = true;&#xA;&#xA;            using (var videoReader = new VideoFileReader())&#xA;            {&#xA;                videoReader.Open(fileName);&#xA;                frame = new Bitmap(videoReader.Width &#x2B; 2, videoReader.Height &#x2B; 2);&#xA;                trackBar1.Maximum = (int)videoReader.FrameCount;&#xA;            }&#xA;&#xA;            videoProgress = new Progress<bitmap>((bitmap) => Updater(bitmap));&#xA;            cts = new CancellationTokenSource();&#xA;            pictureBox1.Image = frame;&#xA;            try&#xA;            {&#xA;                frameGraphics = Graphics.FromImage(frame);&#xA;                // Set the fame rate to 25 frames per second&#xA;                //int frameRate = 1000 / 25;&#xA;                await GetVideoFramesAsync(videoProgress, fileName, frameRate, cts.Token);&#xA;            }&#xA;            finally&#xA;            {&#xA;                frameGraphics?.Dispose();&#xA;                StopPlayback(false);&#xA;                isVideoRunning = false;&#xA;            }&#xA;        }&#xA;&#xA;        private void buttonPause_Click(object sender, EventArgs e)&#xA;        {&#xA;            if (pause == 0)&#xA;            {&#xA;                buttonPause.Text = "Resume";&#xA;                Interlocked.Increment(ref pause);&#xA;            }&#xA;            else&#xA;            {&#xA;                Interlocked.Decrement(ref pause);&#xA;                buttonPause.Text = "Pause";&#xA;            }&#xA;        }&#xA;&#xA;        private void buttonStop_Click(object sender, EventArgs e)&#xA;        {&#xA;            StopPlayback(true);&#xA;        }&#xA;&#xA;        protected override void OnFormClosing(FormClosingEventArgs e)&#xA;        {&#xA;            if (isVideoRunning) StopPlayback(true);&#xA;            pictureBox1.Image?.Dispose();&#xA;            base.OnFormClosing(e);&#xA;        }&#xA;&#xA;        private void pictureBox1_Paint(object sender, PaintEventArgs e)&#xA;        {&#xA;            ControlPaint.DrawBorder(e.Graphics, pictureBox1.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);&#xA;        }&#xA;&#xA;        private void trackBar1_Scroll(object sender, EventArgs e)&#xA;        {&#xA;            pictureBox1.Image = frames[trackBar1.Value];&#xA;        }&#xA;&#xA;        private void button1_Click(object sender, EventArgs e)&#xA;        {&#xA;            using (OpenFileDialog openFileDialog = new OpenFileDialog())&#xA;            {&#xA;                openFileDialog.InitialDirectory = "c:\\";&#xA;                openFileDialog.Filter = "video files (*.mp4)|*.mp4|All files (*.*)|*.*";&#xA;                openFileDialog.FilterIndex = 2;&#xA;                openFileDialog.RestoreDirectory = true;&#xA;&#xA;                if (openFileDialog.ShowDialog() == DialogResult.OK)&#xA;                {&#xA;                    //Get the path of specified file&#xA;                    textBox1.Text = openFileDialog.FileName;&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;</bitmap></bitmap></bitmap></bitmap></bitmap>

    &#xA;

  • How to get better video quality using Accord.Video.FFMPEG.DLL

    31 juillet 2023, par HighwayRob

    I have developed a Visual Studio Winapp that produces a video file utilizing Accord.Video.FFMPEG.DLL.

    &#xA;

    The quality the video is less than the original images.&#xA;Here is the code and then a sample original image and snapshot of the resulting video.

    &#xA;

    What can I change to improve the video image ?

    &#xA;

                VideoFileWriter writer = new VideoFileWriter();&#xA;            writer.Open(outfile, width, height, 1, VideoCodec.Mpeg4);&#xA;            for (int i = firstrow; i &lt;= testframes; i&#x2B;&#x2B;)&#xA;            {&#xA;                Bitmap bitmap = new Bitmap(ffiles[i, 0].ToString());&#xA;                writer.WriteVideoFrame(bitmap);&#xA;                bitmap.Dispose();&#xA;            }&#xA;

    &#xA;

    I tried Bitmap image = new Bitmap(width, height, PixelFormat.Format64bppArgb) ;

    &#xA;

    enter image description here

    &#xA;