Recherche avancée

Médias (0)

Mot : - Tags -/formulaire

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

Autres articles (56)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

Sur d’autres sites (6367)

  • C# Bitmap to AVI / WMV with Compression

    18 juillet 2016, par Digitalsa1nt

    Prelude :

    I’m going to preface this with, I have been learning C# in my spare time at work, and that I have been staring at code for a solid two days trying to wrap my head around this problem. I am developing some software to be used with a visualiser that connects by USB to a standard Desktop PC, the software detects the capture device and loads frames into bitmap using a New Frame Event, this is then displayed in a ’picture box’ as a live video stream. The problem as it sits is trying to encorporate the ability to record the stream and save to file, preferably a WMV or a compressed AVI.

    What’s been tried :

    I have considered and looked into the following :

    SharpAVI - cant seem to get this to compress or save the frames properly as it appears to mainly look at existing AVI files.

    AForge.Video.VFW - AVI files can be created but are far too large to be used, due to restrictions on the user areas of the individuals who will be using this software.

    AForge.Video.FFMPEG - Again due to considerations of those using this software I can’t have unmanaged DLL’s sat in the output folder with the Executable file, and unfortunately this particular DLL cant be compiled properly using Costura Fody.

    AVIFile Library Wrapper (From Code Project) - Again can’t seem to get this to compress a stream correctly from Bitmaps from the New Frame Events.

    DirectShow - Appears to use C++ and unfortunately is beyond my skill level at this time.

    The Relevant Code Snippets :

    Current References :

    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Resources;
    using System.Drawing.Imaging;
    using System.IO;
    //Aforge Video DLL's
    using AForge.Video;
    using AForge.Video.VFW;
    using AForge.Video.DirectShow;
    //Aforge Image DLL's
    using AForge.Imaging;
    using AForge.Imaging.Formats;
    using AForge.Imaging.Filters;
    //AviLibrary
    using AviFile;

    Global Variables :

       #region Global Variables

       private FilterInfoCollection CaptureDevice; // list of available devices
       private VideoCaptureDevice videoSource;
       public System.Drawing.Image CapturedImage;

       bool toggleMic = false;

       bool toggleRec = false;
       //aforge
       AVIWriter aviWriter;
       Bitmap image;


       #endregion

    Code for Displaying Stream

       #region Displays the Stream

       void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
       {
           picBoxStream.SizeMode = PictureBoxSizeMode.Zoom;
           picBoxStream.Image = (Bitmap)eventArgs.Frame.Clone();// clones the bitmap


           if (toggleRec == true)
           {
               image = (Bitmap)eventArgs.Frame.Clone();
               aviWriter.AddFrame(image);
           }
       }

       #endregion

    Current Code for Recording Stream

       #region Record Button

       private void btnRecord_Click(object sender, EventArgs e)
       {
           if (toggleRec == false)
           {
               saveAVI = new SaveFileDialog();
               saveAVI.Filter = "AVI Files (*.avi)|*.avi";

               if (saveAVI.ShowDialog() == DialogResult.OK)
               {
                   aviWriter = new AVIWriter();
                   aviWriter.Open(saveAVI.FileName, 1280, 720);

                   toggleRec = true;
                   Label lblRec = new Label();
               }

           }
           else if (toggleRec == true)
           {
               aviWriter.Close();
               toggleRec = false;
           }
       }

       #endregion

    I apoligise if the above code doesn’t look quite right, I have been swapping, changing and recoding those three sections a lot in order to find a working combination. This means that it’s rather untidy but I didn’t see the point in cleaning it all up until I had the code working. That being said really any help that you can provide is greatfully recieved, even if it’s a case of what I want to do just cannot be done.

    Thank you in advance.

    EDIT : PostScript :

    I will be actively working on this monday to friday, so If I make any breakthroughs I will update this Question accordingly, this seems to be a frequently sort after answer so hopefully we can overcome the issues.

  • FFMpeg cannot start using Process API

    8 juin 2021, par Prophet Lamb

    So I am trying to use FFProbe to retrieve media information using the Process API, I am on Net 5 and wish to stay cross-platform compatible.
Before I started fiddling around I tried FFMpeg Core to retrieve metadata, but it works only on windows, and cannot handle multiline tags, only the last line is parsed.
So I tried to manually pipe the output to my application.
Initially I've used CliWrap to neatly pipe the output to a StringBuilder as I usually do in other repositories.

    


    var output = new StringBuilder();
var args = new[] { "-i", filePath };
var pResult = await Cli.Wrap(GetFFProbeFilePath())
    .WithArguments(args)
    .WithStandardOutputPipe(PipeTarget.ToStringBuilder(output))
    .ExecuteAsync(cancellationToken);


    


      

    • filePath : any media file.
    • 


    • GetFFProbeFilePath() : scrubbs %PATH% for ffmpeg, returns "C :\ProgramData\chocolatey\bin\ffprobe.exe".
    • 


    • cancellationToken : None for test-cases.
    • 


    


    But that did not work. The output always stays empty.
So I ran the following command using non-elevated cmd : C:\\ProgramData\\chocolatey\\bin\\ffprobe.exe -i my/lovely/file.mp3
and the console displays the output fully, with no error.

    


    Naturally it's the fault of CliWrap cause I am perfect ; that's why I replaced it with a plain Process API call :

    


    var output = new StringBuilder();
using (var p = new Process())
{
    p.StartInfo.FileName = "C:\\ProgramData\\chocolatey\\bin\\ffprobe.exe";
    p.StartInfo.Arguments = String.Join(' ', args);
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.Start();
    output.Append(await p.StandardOutput.ReadToEndAsync());
    await p.WaitForExitAsync(cancellationToken);
}


    


    Still the output is empty. So instead of using a pipe that I write to the output of a file :

    


    using var p = new Process();
p.StartInfo.FileName = "C:\\ProgramData\\chocolatey\\bin\\ffprobe.exe";
p.StartInfo.Arguments = " -i \"" + filePath + "\" 2> " + "\"C:\\temp\\metadata.log\"";
if (!p.Start())
    throw new Exception();
await p.WaitForExitAsync(cancellationToken);


    


      

    • C:\temp\ : 777
    • 


    


    The temporary file is not created, from that I conclude that the process has not exited successfully. Even though no exception is thrown (I tried piping the errors as well : nothing).

    


    Then I proceed to run this command 20x and wonder why it works in ps & cmd, but not in C# :

    


    C:\ProgramData\chocolatey\bin\ffprobe.exe -i  my/lovely/file.mp3 2> "C:\temp\metadata.log"

    


    Until I ran it using [Win]+[R], and I got a graphic glich and Windows Error Reporting instead of the process completing, the file was not created. After some experimenting I found that the same behaviour for start + the command in cmd.

    


    Why in (insert deity of preference) name is there a difference between [Win]+[R] and cmd, and why does it crash when run from C# ? How do I overcome this weird behaviour, while still being cross-platform compatible ?

    


    This entire affair works just fine in linux by the way.

    


    Edit :
When starting the cmd process manually, FFProbe is called correctly, but I still do not retrieve any data on the output pipeline, since cmd.exe doesn't write anything, and I can't pipe FFProbe.

    


    var output = new StringBuilder();
_ = await Cli.Wrap("cmd.exe")
   .WithArguments("/C ffprobe -i \"my/lovely/file.mp3\" 2> \"C:\\temp\\metadata.log\"") 
   .WithStandardOutputPipe(PipeTarget.ToStringBuilder(output))
   .ExecuteAsync(cancellationToken);


    


    This actually creates the metadata.log file, but no output since I only redirect the output of cmd.exe, not ffprobe.
My current thought is, that I could open a conhost and manually pipe the ffprobe output to the console input by providing the pipeline explicitly in the command arguments which again would not work in linux the same way, that kind of defeats the purpose.

    


  • when ffpmeg drops frames some things aren't played back in real time

    8 février 2024, par Alex028502

    I am trying to run a bunch of ffpmeg processes that act as simulators for cameras, and something funny is happening when I the processor can't keep up with the configured frame rate.

    


    I have replaced the rtsp stream with an output file, and managed to reproduce the issue, so will just show that to keep it simple.

    


    First here is a makefile that creates my source movie :

    


    clock.mp4: Makefile
    rm -f $@
    ffmpeg -f lavfi -i color=c=black:s=4096x2160:r=25 -vf \
"drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:fontsize=72:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2: \
text='%{eif\:trunc(n/25)\:d}':start_number=0:rate=25" \
-t 60 -r 25 $@


    


    that gives me a one minute long movie that prints the second number to the screen. I have tested it out and the seconds are close enough. I put a lot of pixels to make it easier to jam up my CPU.

    


    Here is the script that creates a processes similar to the one I am trying to debug (called experiment.sh)

    


    I am actually using H.264, but H.265 is easier to overwhelm the processor with

    


    #! /usr/bin/env bash

set -e

echo starting > message$1.txt

rm -f superclock$1.mp4
ffmpeg -re -stream_loop -1 -i clock.mp4 \
       -an -vcodec libx265 -preset ultrafast -sc_threshold -1 -x265-params repeat-headers=1 \
       -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:fontsize=24:fontcolor=white:x=10:y=10:text='%{localtime\:%X}', \
            drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:fontsize=24:fontcolor=white:x=10:y=(h-text_h-10):textfile=message$1.txt:reload=1, \
            scale=1920x1080,fps=25" \
       -b:v 3M -minrate 3M -maxrate 3M \
       -bufsize 6M -g 25 superclock$1.mp4 &
pid=$!

for x in $(seq 0 10)
do
    echo $x > message$1.txt
    sleep 10
done

kill -INT $pid || true


    


    It should

    


      

    • put the second in the middle of the screen - 'cause it gets it from the source video
    • 


    • put the approximate sixth of minute in the lower left corner
(only approximate because of the sleep but close enough)
    • 


    • put the the wall clock time in the upper left corner
    • 


    


    and it works

    


    make clock.mpg
./experiment.sh 0
vlc superclock0.mp4


    


    shows something like this
working video

    


    Now here is the interesting part

    


    If I run the script in four different terminals at the same time

    


    ./experiment.sh 1
./experiment.sh 2
./experiment.sh 3
./experiment.sh 4


    


    It can't keep up with the frame rate, and I see this in the output :

    


    frame= 1515 fps= 16 q=0.0 size=     768kB time=00:00:59.96 bitrate= 104.9k


    


    I was hoping the end result would all look ok when I watch it except with fewer frames, but the timestamps of the frames would make it all work as expected

    


    However...

    


      

    • The time in the middle, that is inherited from the source video, the seconds in the middle of the screen, stays in sync with VLC's clock.
    • 


    • the wall clock in the upper left seems play at 150% speed
    • 


    • the every ten seconds incrementor in the lower left seems to increment every 7 seconds
    • 


    • the video is only 1:25 long even though it was recording for at least 1:40 according to sleeps
    • 


    • the wall clock in the upper right hand corner makes it more than 1'40" and then counter in the lower left makes it to 10.
    • 


    


    30 seconds in

    


    Here are four states to compare

    


    |                  | Start    | 30" in   | end      |
|------------------+----------+----------|----------|
| Video Time       | 00:00    | 00:30    | 01:24    |
| Wall Clock Time  | 15:05:50 | 15:06:39 | 15:07:39 |
| sixth of minute  | 0        | 4        | 10       |
| seconds counter  | 0        | 30       | 24       |


    


    end of the movie

    


    So you can see the vlc clock keeps pace with the original clock from the source movie.. even when it is only able to produce frames at 2/3 of the rate. However, the it is taking 50% long to get through the whole source movie I guess ?

    


    I am having trouble coming up with a theory that can explain exactly how this happens.

    


    Does anybody know how I can "correct" this ? (make it so that the movie is played at the same rate that it is recorded)

    


    I am thinking of using a lower frame rate and size as the input video.. but it would be nice to have something that will always work as expected, just with a lower frame rate, no matter how busy the processor is.