Recherche avancée

Médias (2)

Mot : - Tags -/documentation

Autres articles (72)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

  • Librairies et logiciels spécifiques aux médias

    10 décembre 2010, par

    Pour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
    Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...)

Sur d’autres sites (14202)

  • How can i capture a screenshots from pictureBox1 every X milliseconds ?

    9 avril 2016, par Brubaker Haim

    The way it is now it’s capturing screenshots depending on on what screen I am in.
    For example if i’m in my desktop it will take screenshots of my desktop if I move to the form1 and see the pictureBox1 it will take screenshots of the pictureBox1.

    But how can I get directly screenshots from the pictureBox1 no matter on what screen I am ?

    Bitmap bmp1;
           public static int counter = 0;
           private void timer1_Tick(object sender, EventArgs e)
           {
               counter++;

               Rectangle rect = new Rectangle(0, 0, pictureBox1.ClientSize.Width, pictureBox1.ClientSize.Height);
               bmp1 = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
               Graphics g = Graphics.FromImage(bmp1);
               g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp1.Size, CopyPixelOperation.SourceCopy);
               bmp1.Save(@"e:\screenshots\" + "screenshot" + counter.ToString("D6") + ".bmp", ImageFormat.Bmp);
               bmp1.Dispose();
               g.Dispose();
               if (counter == 500)//1200)
               {
                   timer1.Stop();
                   this.Close();
               }
           }

    The timer1 is set now to 100ms interval in the designer.
    But what is a reasonable speed to take screenshots from animation in the pictureBox1 ? In this case I have a game I show in the pictureBox1 and I want to take a screenshots of each frame from the pictureBox1 and in real time to create mp4 video file on the hard disk from each frame I took.

    So instead saving the bmp1 to the hard disk I need somehow to save each frame I capture in memory and build mp4 video file in real time.

    I created a ffmpeg class for that :

    using System;
    using System.Windows.Forms;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Drawing;
    using System.IO.Pipes;
    using System.Runtime.InteropServices;
    using System.Diagnostics;
    using System.IO;
    using DannyGeneral;

    namespace ffmpeg
    {
       public class Ffmpeg
       {
           NamedPipeServerStream p;
           String pipename = "mytestpipe";
           System.Diagnostics.Process process;
           string ffmpegFileName = "ffmpeg.exe";
           string workingDirectory;

           public Ffmpeg()
           {
               workingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
               Logger.Write("workingDirectory: " + workingDirectory);
               if (!Directory.Exists(workingDirectory))
               {
                   Directory.CreateDirectory(workingDirectory);
               }
               ffmpegFileName = Path.Combine(workingDirectory, ffmpegFileName);
               Logger.Write("FfmpegFilename: " + ffmpegFileName);
           }

           public void Start(string pathFileName, int BitmapRate)
           {
               try
               {

                   string outPath = pathFileName;
                   p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
                   ProcessStartInfo psi = new ProcessStartInfo();
                   psi.WindowStyle = ProcessWindowStyle.Hidden;
                   psi.UseShellExecute = false;
                   psi.CreateNoWindow = false;
                   psi.FileName = ffmpegFileName;
                   psi.WorkingDirectory = workingDirectory;
                   psi.Arguments = @"-f rawvideo -pix_fmt bgra -video_size 1920x1080 -i \\.\pipe\mytestpipe -c:v mpeg2video -crf 20 -r " + BitmapRate + " " + outPath;
                   process = Process.Start(psi);
                   process.EnableRaisingEvents = false;
                   psi.RedirectStandardError = true;
                   p.WaitForConnection();
               }
               catch (Exception err)
               {
                   Logger.Write("Exception Error: " + err.ToString());
               }
           }

           public void PushFrame(Bitmap bmp)
           {
               try
               {
                   int length;
                   // Lock the bitmap's bits.
                   //bmp = new Bitmap(1920, 1080);
                   Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
                   //Rectangle rect = new Rectangle(0, 0, 1280, 720);
                   System.Drawing.Imaging.BitmapData bmpData =
                       bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly,
                       bmp.PixelFormat);

                   int absStride = Math.Abs(bmpData.Stride);
                   // Get the address of the first line.
                   IntPtr ptr = bmpData.Scan0;

                   // Declare an array to hold the bytes of the bitmap.
                   //length = 3 * bmp.Width * bmp.Height;
                   length = absStride * bmpData.Height;
                   byte[] rgbValues = new byte[length];

                   //Marshal.Copy(ptr, rgbValues, 0, length);
                   int j = bmp.Height - 1;
                   for (int i = 0; i < bmp.Height; i++)
                   {
                       IntPtr pointer = new IntPtr(bmpData.Scan0.ToInt32() + (bmpData.Stride * j));
                       System.Runtime.InteropServices.Marshal.Copy(pointer, rgbValues, absStride * (bmp.Height - i - 1), absStride);
                       j--;
                   }
                   p.Write(rgbValues, 0, length);
                   bmp.UnlockBits(bmpData);
               }
               catch(Exception err)
               {
                   Logger.Write("Error: " + err.ToString());
               }

           }

           public void Close()
           {
               p.Close();
           }
       }
    }

    And using the ffmpeg class like this :

    public static Ffmpeg fmpeg;

    Then

    fmpeg = new Ffmpeg();
    fmpeg.Start(@"e:\screenshots\test.mp4", 25);

    And

    fmpeg.PushFrame(_screenShot);

    My main question is first how to get the screenshots(frames) from the pictureBox1 directly no matter what screen i’m in now ?

    And how to use on each frame with the fmpeg to get a fine mp4 speed video file I mean that I will not miss a frame to capture all frames and also that the mp4 video file will when I play it later will not display a fast video or too slow ?

  • When using ffmpeg to compress and create in real time mpeg4 video file from bathc of images getting low quality video how can i improve quality ?

    30 juin 2015, par Brubaker Haim

    The goal here is to create a compressed mp4 video file in real time. I’m saving screenshots as bitmaps type on my hard disk. And i want to create mp4 file and compress the mp4 video file in real time.

    using System;
    using System.Windows.Forms;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Drawing;
    using System.IO.Pipes;
    using System.Runtime.InteropServices;
    using System.Diagnostics;
    using System.IO;
    using DannyGeneral;

    namespace Youtube_Manager
    {
       class Ffmpeg
       {
           NamedPipeServerStream p;
           String pipename = "mytestpipe";
           System.Diagnostics.Process process;
           string ffmpegFileName = "ffmpeg.exe";
           string workingDirectory;

           public Ffmpeg()
           {
               workingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
               Logger.Write("workingDirectory: " + workingDirectory);
               if (!Directory.Exists(workingDirectory))
               {
                   Directory.CreateDirectory(workingDirectory);
               }
               ffmpegFileName = Path.Combine(workingDirectory, ffmpegFileName);
               Logger.Write("FfmpegFilename: " + ffmpegFileName);
           }

           public void Start(string pathFileName, int BitmapRate)
           {
               try
               {

                   string outPath = pathFileName;
                   p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);

                   ProcessStartInfo psi = new ProcessStartInfo();
                   psi.WindowStyle = ProcessWindowStyle.Hidden;
                   psi.UseShellExecute = false;
                   psi.CreateNoWindow = false;
                   psi.FileName = ffmpegFileName;
                   psi.WorkingDirectory = workingDirectory;
                   psi.Arguments = @"-f rawvideo -vcodec rawvideo -pix_fmt rgb24 -video_size 1920x1080 -i \\.\pipe\mytestpipe -map 0 -c:v mpeg4 -r " + BitmapRate + " " + outPath;
                   process = Process.Start(psi);
                   process.EnableRaisingEvents = false;
                   psi.RedirectStandardError = true;
                   p.WaitForConnection();
               }
               catch (Exception err)
               {
                   Logger.Write("Exception Error: " + err.ToString());
               }
           }

           public void PushFrame(Bitmap bmp)
           {
               try
               {
                   int length;
                   // Lock the bitmap's bits.
                   //bmp = new Bitmap(1920, 1080);
                   Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
                   //Rectangle rect = new Rectangle(0, 0, 1280, 720);
                   System.Drawing.Imaging.BitmapData bmpData =
                       bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly,
                       bmp.PixelFormat);

                   int absStride = Math.Abs(bmpData.Stride);
                   // Get the address of the first line.
                   IntPtr ptr = bmpData.Scan0;

                   // Declare an array to hold the bytes of the bitmap.
                   //length = 3 * bmp.Width * bmp.Height;
                   length = absStride * bmpData.Height;
                   byte[] rgbValues = new byte[length];

                   //Marshal.Copy(ptr, rgbValues, 0, length);
                   int j = bmp.Height - 1;
                   for (int i = 0; i < bmp.Height; i++)
                   {
                       IntPtr pointer = new IntPtr(bmpData.Scan0.ToInt32() + (bmpData.Stride * j));
                       System.Runtime.InteropServices.Marshal.Copy(pointer, rgbValues, absStride * (bmp.Height - i - 1), absStride);
                       j--;
                   }
                   p.Write(rgbValues, 0, length);
                   bmp.UnlockBits(bmpData);
               }
               catch(Exception err)
               {
                   Logger.Write("Error: " + err.ToString());
               }

           }

           public void Close()
           {
               p.Close();
           }
       }
    }

    The Bitmaps images files on my hard disk each one is 1920x1080 and Bit depth 32.

    The video file is on the hard disk at size 1.24MB

    This is a screenshot i took from the video file when playing it.
    You can see how bad the quality is.

    screenshot from video bad quality

    This is a link for 10 images of the screenshots i’m using creating from the video file. They are Bitmaps.

    Screenshots rar

    Its something with the arguments :
    This line dosen’t work when i run the program the command prompt window close at once. I can’t even see if there is any erorr/s the command prompt window close too fast.

    psi.Arguments = @"-f libx264 -vcodec libx264 -pix_fmt bgra -video_size 1920x1080 -i \\.\pipe\mytestpipe -map 0 -c:v mpeg4 -r " + BitmapRate + " " + outPath;

    When i’m using this arguments it’s working but making bad quality video :

    psi.Arguments = @"-f rawvideo -pix_fmt bgra -video_size 1920x1080 -i \\.\pipe\mytestpipe -map 0 -c:v mpeg4 -r " + BitmapRate + " " + outPath;
  • Compiling qt project with use of ffmpeg on x64 system

    5 juin 2013, par Srv19

    I have a qt project that uses some ffmpeg functionality, that i have compiled previously on windows (x86) and ubuntu. However, its x86 binaries do not work correctly on x64 windows machine. I have tried compiling it but have run into a strange problem.

    All ffmpeg functions i use are listed as unresolved exgternals ; and the most pecicular thing is, their names all ahve a leading underscore attached to them (so, avformat_close_input -> _avformat_close_input etc). To be sure, i have downloaded latest ffmpeg libraries for x64 machines and run them through a dependency walker - no leading underscores anywhere.

    How to fix this problem ?

    Here is my .pro file :

    #-------------------------------------------------
    #
    # Project created by QtCreator 2013-05-17T10:55:01
    #
    #-------------------------------------------------


    QT       += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = LPR_Demo
    TEMPLATE = app
    # The application version
    VERSION = 1.0

    # Define the preprocessor macro to get the application version in our application.
    DEFINES += APP_VERSION=\\\"$$VERSION\\\"
    SOURCES += main.cpp\
           mainwindow.cpp \
       imgProcessor.cpp \
       qpicturelabel.cpp \
       aboutdialog.cpp \
       state.cpp \
       qt_videoreader.cpp \
       roidialog.cpp \
       recognitionresult.cpp \
       ffmpeg_reader.cpp \
       label_videoplayer.cpp

    HEADERS  += mainwindow.h \
       imgProcessor.h \
       qpicturelabel.h \
       aboutdialog.h \
       state.h \
       qt_videoreader.h \
       roidialog.h \
       recognitionresult.h \
       global.h \
       ffmpeg_reader.h \
       label_videoplayer.h

    FORMS    += mainwindow.ui \
       aboutdialog.ui \
       roidialog.ui
    LPRDIR = $$PWD/LPR
    win32: LIBS += -L$$LPRDIR/bin/ -lliblpr
    unix:LIBS += -L$$LPRDIR/bin -lLPR

    INCLUDEPATH += $$LPRDIR/include

    DEPENDPATH += $$LPRDIR/include

    INCLUDEPATH += $$PWD/
    DEPENDPATH += $$PWD/

    #OTHER_FILES += \
    #    ffmpeg.pri
    include(ffmpeg.pri)
    #LIBS += -lavformat -lavcodec -lavutil -lswscale

    RESOURCES += \
       lpr_Res.qrc

    win32 {
    dlls_to_move.path += $$OUT_PWD/bin

    dlls_to_move.files += $$LPRDIR/bin/liblpr.dll

    QTDIR=C:/Qt/4.8.4/

    CONFIG (debug, debug|release) {

    dlls_to_move.files += $$QTDIR/bin/QtCored4.dll \
       $$QTDIR/bin/QtGuid4.dll

    }
    CONFIG (release, debug|release) {

    dlls_to_move.files += $$QTDIR/bin/QtCore4.dll \
       $$QTDIR/bin/QtGui4.dll
    }
    img_format.path += $$OUT_PWD/bin/imageformats
    CONFIG (debug, debug|release) {

    img_format.files += $$QTDIR/plugins/imageformats/qgifd4.dll \
       $$QTDIR/plugins/imageformats/qicod4.dll \
       $$QTDIR/plugins/imageformats/qjpegd4.dll \
       $$QTDIR/plugins/imageformats/qmngd4.dll \
       $$QTDIR/plugins/imageformats/qsvgd4.dll \
       $$QTDIR/plugins/imageformats/qtgad4.dll \
       $$QTDIR/plugins/imageformats/qtiffd4.dll

    }
    CONFIG (release, debug|release) {

    img_format.files += $$QTDIR/plugins/imageformats/qgif4.dll \
       $$QTDIR/plugins/imageformats/qico4.dll \
       $$QTDIR/plugins/imageformats/qjpeg4.dll \
       $$QTDIR/plugins/imageformats/qmng4.dll \
       $$QTDIR/plugins/imageformats/qsvg4.dll \
       $$QTDIR/plugins/imageformats/qtga4.dll \
       $$QTDIR/plugins/imageformats/qtiff4.dll
    }

    ffmpeg_dll.path += $$OUT_PWD/bin

    ffmpeg_dll.files += $$FFMPEG_LIBRARY_PATH/avutil-*.dll \
       $$FFMPEG_LIBRARY_PATH/avcodec-*.dll \
       $$FFMPEG_LIBRARY_PATH/avformat-*.dll \
       $$FFMPEG_LIBRARY_PATH/swscale-*.dll

    main_exe.path += $$OUT_PWD/bin
    CONFIG (debug, debug|release) {

    main_exe.files += $$OUT_PWD/debug/LPR_Demo.exe

    }
    CONFIG (release, debug|release) {
    main_exe.files += $$OUT_PWD/release/LPR_Demo.exe

    }
    INSTALLS += dlls_to_move img_format ffmpeg_dll main_exe
    }

    unix {
    CONFIG (release, debug|release) {
       QMAKE_PRE_LINK += rm LPR_Demo_cmpr LPR_Demo$$escape_expand(\n\t)
       QMAKE_POST_LINK += upx -9 -oLPR_Demo_cmpr LPR_Demo$$escape_expand(\n\t)
       QMAKE_POST_LINK += cp -v -u LPR_Demo_cmpr $$OUT_PWD/../artifacts/examples/qt_demo/bin/unix
    }
    }

    and here is pri file for ffmpeg :

    # Include the configuration file below in the QT .pro file, and modify the path accordingly.


    # ##############################################################################
    # ##############################################################################
    # FFMPEG: START OF CONFIGURATION BELOW ->
    # Copy these lines into your own project
    # Make sure to set the path variables for:
    # 1) ffmpeg_reader,
    # 2) FFMPEG include path (i.e. where the directories libavcodec, libavutil, etc. lie),
    # 3) the binary FFMPEG libraries (that must be compiled separately).
    # Under Linux path 2 and 3 may not need to be set as these are usually in the standard include and lib path.
    # Under Windows, path 2 and 3 must be set to the location where you placed the FFMPEG includes and compiled binaries
    # Note that the FFMPEG dynamic librairies (i.e. the .dll files) must be in the PATH
    # ##############################################################################
    # ##############################################################################

    # ##############################################################################
    # Modify here: set FFMPEG_LIBRARY_PATH and FFMPEG_INCLUDE_PATH
    # ##############################################################################

    # Set FFMPEG_LIBRARY_PATH to point to the directory containing the FFmpeg import libraries (if needed - typically for Windows), i.e. the dll.a files
    win32:FFMPEG_LIBRARY_PATH = $$PWD/ffmpeg/lib

    unix: FFMPEG_LIBRARY_PATH = /usr/local/lib

    # Set FFMPEG_INCLUDE_PATH to point to the directory containing the FFMPEG includes (if needed - typically for Windows)
    win32:FFMPEG_INCLUDE_PATH = $$PWD/ffmpeg/include
    unix:FFMPEG_INCLUDE_PATH = /usr/local/include
    # ##############################################################################
    # Do not modify: FFMPEG default settings
    # ##############################################################################


    # Set list of required FFmpeg libraries
    #unix:LIBS += -L$$FFMPEG_LIBRARY_PATH
    unix:LIBS += -lavformat -lavcodec -lavutil -lswscale
    # Add the path
    win32:LIBS += -L$$FFMPEG_LIBRARY_PATH
    win32:LIBS += -lavformat -lavcodec -lavutil -lswscale
    INCLUDEPATH += $$FFMPEG_INCLUDE_PATH

    # Requied for some C99 defines
    DEFINES += __STDC_CONSTANT_MACROS

    # ##############################################################################
    # FFMPEG: END OF CONFIGURATION
    # ##############################################################################