Recherche avancée

Médias (91)

Autres articles (105)

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

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • MediaSPIP Player : problèmes potentiels

    22 février 2011, par

    Le lecteur ne fonctionne pas sur Internet Explorer
    Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
    Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)

Sur d’autres sites (12949)

  • proc_open hangs when trying to read from a stream

    7 juillet 2015, par eithedog

    I’ve encountered the issue with proc_open on Windows, when trying to convert a wmv file (to flv), using ffmpeg, however I suspect I’ll encounter the same scenario whenever certain conditions occur.
    Basically my code is as follows :

    $descriptorspec = array
    (
       array("pipe", "r"),
       array("pipe", "w"),
       array("pipe", "w")
    );

    $pipes = array();
    $procedure = proc_open('cd "C:/Program Files/ffmpeg/bin" && "ffmpeg.exe" -i "C:/wamp/www/project/Wildlife.wmv" -deinterlace -qdiff 2 -ar 22050 "C:/wamp/www/project/Wildlife.flv"', $descriptorspec, $pipes);
    var_dump(stream_get_contents($pipes[1]));

    Now, this code will cause PHP to hang indefinitely (it doesn’t matter if instead of stream_get_contents I’ll use fgets or stream_select, the behavior is consistent).

    The reason for it (I suspect) is that, while STDOUT stream is open succesfully, the process doesn’t write anything to it (even though running the same command in cmd displays output) and as such, trying to read from such stream, would cause the same issue as described here, so - PHP waits for the stream to have anything in it, process doesn’t write anything to it.

    However (additional fun), setting stream_set_timeout or stream_set_blocking doesn’t have any effect.

    As such - can somebody confirm/deny on what is going on, and, if possible, show how can I cater for such situation ? I’ve looked at PHP bugs, and all proc_open hangs ones seem to be fixed.

    For time being I’ve implemented such solution :

    $timeout = 60;
    while (true) {
       sleep(1);

       $status = proc_get_status($procedure);
       if (!$status['running'] || $timeout == 0) break;

       $timeout--;
    }

    However, I’d really not like to rely on something like this as :

    1. I will have processes that run for longer than a minute - such processes will be falsely reported to be of the above mentioned type
    2. I want to know when the ffmpeg has finished converting the video - currently I’ll only know that process is still running after a minute, and I can’t really do anything to check if there’s any output (as it will hang PHP).

    Also, I don’t really want to wait a full minute for the process to be checked (for example - converting the given video from command line takes <10s), and I’ll have videos that take more time to be converted.


    Per comment from @Sjon, here’s stream_select I was using, which blocks due to same issue - STDOUT not being written to :

    $descriptorspec = array
    (
       array("pipe", "r"),
       array("pipe", "w"),
       array("pipe", "w")
    );

    $pipes = array();
    $procedure = proc_open('cd "C:/Program Files/ffmpeg/bin" &amp;&amp; "ffmpeg.exe" -i "C:/wamp/www/sandbox/Wildlife.wmv" -deinterlace -qdiff 2 -ar 22050 "C:/wamp/www/sandbox/Wildlife.flv"', $descriptorspec, $pipes);

    $read = array($pipes[0]);
    $write = array($pipes[1], $pipes[2]);
    $except = array();

    while(true)
    if(($num_changed_streams = stream_select($read, $write, $except, 10)) !== false)
    {
       foreach($write as $stream)
           var_dump(stream_get_contents($stream));

       exit;
    }
    else
       break;

    Per conversation with @Sjon - reading from buffered streams on Windows is broken. The solution in the end is to use stream redirection via shell, and then read the created files - as such

    $descriptorspec = array
    (
       array("pipe", "r"),
       array("pipe", "w"),
       array("pipe", "w")
    );

    $pipes = array();
    $procedure = proc_open('cd "C:/Program Files/ffmpeg/bin" &amp;&amp; "ffmpeg.exe" -i "C:/wamp/www/sandbox/Wildlife.mp4" -deinterlace -qdiff 2 -ar 22050 "C:/wamp/www/sandbox/Wildlife.flv" > C:/stdout.log 2> C:/stderr.log', $descriptorspec, $pipes);

    proc_close($procedure);

    $output = file_get_contents("C:/stdout.log");
    $error = file_get_contents("C:/stderr.log");

    unlink("C:/stdout.log");
    unlink("C:/stderr.log");

    As the stream is buffered, in the file we will get unbuffered output (something I was after as well). And we don’t need to check if the file changes, because the result from shell is unbuffered and synchronous.

  • ffmpeg exported file is broken

    11 août 2020, par Zhanho Shing

    I am using using ffmpeg to trim and join several audio files. The ouput audio file can be played as a normal file, but when I open it in some C# codes, exceptions are always throwing, says "MP3 Header is missing". I am new to ffmpeg and I googled for many times but seems no one is encountering this problem.

    &#xA;

    Here is my ffmpeg command to trim an audio file :

    &#xA;

    ffmpeg -i input_1.mp3 -ss 00:00:00.000 -to 00:00:01.000 -acodec libmp3lame 1.mp3&#xA;

    &#xA;

    (The input audio format can be mp3/wma/wav/m4a/aac)

    &#xA;

    And the following is for joining all the audio files :

    &#xA;

    ffmpeg -safe 0 -f concat -i list.txt -acodec libmp3lame join.mp3&#xA;

    &#xA;

    The list.txt contents :

    &#xA;

    file C:\\1.mp3&#xA;file C:\\2.mp3&#xA;file C:\\3.mp3&#xA;

    &#xA;

  • Python and ffmpeg audio sync and screen recording issues

    9 août 2020, par odddollar

    I'm using ffmpeg and python to record my desktop screen. When the program is run, it starts recording, then when I press a key-combo it cuts off the last x amount of seconds and saves it then starts recording again ; similar to the "record that" functionality of windows game bar.

    &#xA;

    I have it working so it records video just fine, but then I change the ffmpeg command to record audio from my desktop and I get an error saying ValueError: could not convert string to float: &#x27;N/A&#x27; occurring when I try to calculate the length of the recorded video. It appears as though the recording isn't being stopped until after I try to calculate the video length, even though this exact same code works fine when not recording audio.

    &#xA;

    Additionally, I also have an issue when recording audio in that the audio is a couple hundred milliseconds in front of the video. It's not a lot but it's enough to be noticeable.

    &#xA;

    What I'm overall asking, is there a way I can modify the ffmpeg command to prevent the audio desync issues, and what might be causing the problems I'm getting when attempting to find the length of the video with audio ?

    &#xA;

    import keyboard, signal&#xA;from os import remove&#xA;from os.path import isfile&#xA;from subprocess import Popen, getoutput&#xA;from datetime import datetime&#xA;import configparser&#xA;&#xA;class Main:&#xA;    def __init__(self, save_location, framerate, duration):&#xA;        self.save_location = save_location&#xA;        self.framerate = int(framerate)&#xA;        self.duration = int(duration)&#xA;        self.working = self.save_location &#x2B; &#x27;\\&#x27; &#x2B; &#x27;working.avi&#x27;&#xA;        self.start_recording()&#xA;&#xA;    def start_recording(self):&#xA;        if isfile(self.working):&#xA;            remove(self.working)&#xA;&#xA;        # start recording to working file at set framerate&#xA;        self.process = Popen(f&#x27;ffmpeg -thread_queue_size 578 -f gdigrab -video_size 1920x1080 -i desktop -f dshow -i audio="Stereo Mix (Realtek High Definition Audio)" -b:v 7M -minrate 4M -framerate {self.framerate} {self.working}&#x27;)&#xA;        #self.process = Popen(f&#x27;ffmpeg -f gdigrab -framerate {self.framerate} -video_size 1920x1080 -i desktop -b:v 7M -minrate 2M {self.working}&#x27;)&#xA;&#xA;    def trim_video(self):&#xA;        # stop recording working file&#xA;        self.process.send_signal(signal.CTRL_C_EVENT)&#xA;&#xA;        # call &#x27;cause I have to&#xA;        getoutput(f"ffprobe -i {self.working}")&#xA;&#xA;        # get length of working video&#xA;        length = getoutput(f&#x27;ffprobe -i {self.working} -show_entries format=duration -v quiet -of csv="p=0"&#x27;)&#xA;&#xA;        # get time before desired recording time&#xA;        start = float(length) - self.duration&#xA;&#xA;        # get save location and title&#xA;        title = self.save_location&#x2B;&#x27;\\&#x27;&#x2B;self.get_time()&#x2B;&#x27;.avi&#x27;&#xA;&#xA;        # cut to last amount of desired time&#xA;        Popen(f"ffmpeg -ss {start} -i {self.working} -c copy -t {self.duration} {title}")&#xA;        getoutput(f"ffprobe -i {self.working}")&#xA;&#xA;        self.start_recording()&#xA;&#xA;    def get_time(self):&#xA;        now = datetime.now()&#xA;        return now.strftime("%Y_%m_%d#%H-%M-%S")&#xA;&#xA;&#xA;if __name__ == "__main__":&#xA;    config = configparser.ConfigParser()&#xA;    config.read("settings.ini")&#xA;    config = config["DEFAULT"]&#xA;&#xA;    run = Main(config["savelocation"].replace("\\", "\\\\"), config["framerate"], config["recordlast"])&#xA;    keyboard.add_hotkey("ctrl&#x2B;shift&#x2B;alt&#x2B;g", lambda:run.trim_video())&#xA;&#xA;    while True:&#xA;        try:&#xA;            keyboard.wait()&#xA;        except KeyboardInterrupt:&#xA;            pass&#xA;

    &#xA;

    The contents of the settings.ini file are listed below

    &#xA;

    [DEFAULT]&#xA;savelocation = C:\&#xA;framerate = 30&#xA;recordlast = 10&#xA;

    &#xA;

    In the code block, the first line with self.process = Popen is the one that records audio and has the issues, the second line (the commented out one below) is the one that works fine.

    &#xA;