Recherche avancée

Médias (0)

Mot : - Tags -/albums

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

Autres articles (105)

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

  • Script d’installation automatique de MediaSPIP

    25 avril 2011, par

    Afin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
    Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
    La documentation de l’utilisation du script d’installation (...)

  • Utilisation et configuration du script

    19 janvier 2011, par

    Informations spécifiques à la distribution Debian
    Si vous utilisez cette distribution, vous devrez activer les dépôts "debian-multimedia" comme expliqué ici :
    Depuis la version 0.3.1 du script, le dépôt peut être automatiquement activé à la suite d’une question.
    Récupération du script
    Le script d’installation peut être récupéré de deux manières différentes.
    Via svn en utilisant la commande pour récupérer le code source à jour :
    svn co (...)

Sur d’autres sites (10915)

  • FFMPEG With PHP Upload

    27 décembre 2014, par Will S.

    I’ve created an upload form that uses Ajax to dynamically upload image files to my webserver, and then uses shell_exec and ffmpeg to resize the images (and convert them to jpg, if they are already the correct size), and then save the resulting file. I’m getting really strange behaviour with it. It works about 50% of the time (so far I’ve only tested with JPG and PNG files). Whenever it fails, I get this results :

    ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
     built on Dec 23 2014 16:55:38 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
     configuration:
     libavutil      54. 15.100 / 54. 15.100
     libavcodec     56. 13.100 / 56. 13.100
     libavformat    56. 15.102 / 56. 15.102
     libavdevice    56.  3.100 / 56.  3.100
     libavfilter     5.  2.103 /  5.  2.103
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
    /tmp/phpU0pnje: Invalid data found when processing input

    Here’s the PHP code :

    if ($file_info[0] == 'image'){
           $image_info = getimagesize($_FILES['upload_media_hidden']['tmp_name'][$i]);
           $longest_edge = ($image_info[0] > $image_info[1]) ? $image_info[0] : $image_info[1];
           $aspect_ratio = $image_info[0]/$image_info[1];
           $aspect_ratio_s = ($image_info[0] > $image_info[1]) ? '200x' . (int)(200/$aspect_ratio) : (int)(200*$aspect_ratio) . 'x200';
           $aspect_ratio_m = ($image_info[0] > $image_info[1]) ? '400x' . (int)(400/$aspect_ratio) : (int)(400*$aspect_ratio) . 'x400';
           $aspect_ratio_l = ($image_info[0] > $image_info[1]) ? '700x' . (int)(700/$aspect_ratio) : (int)(700*$aspect_ratio) . 'x700';

           if ($longest_edge > 200){
                   $file_s = shell_exec('ffmpeg -i ' . escapeshellarg($_FILES['upload_media_hidden']['tmp_name'][$i]) . ' -f image2 -s ' . $aspect_ratio_s . ' - 2>&1');
           }

         ................more processing below

    So the ffmpeg command essentially looks like this :

    ffmpeg -i ’SOMEFILE.jpg’ -f image2 -s 400x200 -

    When I run that command in bash to the actual file (not the temporary file when I upload it to my form), it works fine. I’m guessing the issue is with the pipe, but I’m not sure. Any ideas ?

    Thanks !

    Update :
    When I run this code :

    if ($file_info[0] == 'image'){
           $image_info = getimagesize($_FILES['upload_media_hidden']['tmp_name'][$i]);
           $longest_edge = ($image_info[0] > $image_info[1]) ? $image_info[0] : $image_info[1];
           $aspect_ratio = $image_info[0]/$image_info[1];
           $aspect_ratio_s = ($image_info[0] > $image_info[1]) ? '200x' . (int)(200/$aspect_ratio) : (int)(200*$aspect_ratio) . 'x200';
           $aspect_ratio_m = ($image_info[0] > $image_info[1]) ? '400x' . (int)(400/$aspect_ratio) : (int)(400*$aspect_ratio) . 'x400';
           $aspect_ratio_l = ($image_info[0] > $image_info[1]) ? '700x' . (int)(700/$aspect_ratio) : (int)(700*$aspect_ratio) . 'x700';

           if ($longest_edge > 200){
                   move_uploaded_file($_FILES['upload_media_hidden']['tmp_name'][$i],'/tmp/TEST.jpg');
                   system('ffmpeg -i /tmp/TEST.jpg -f image2 -s ' . $aspect_ratio_s . ' - 2>&1');

                   $file_s = system('ffmpeg -i ' . escapeshellarg($_FILES['upload_media_hidden']['tmp_name'][$i]) . ' -f image2 -s ' . $aspect_ratio_s . ' - 2>&1');

    I get this result from php :

    ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
     built on Dec 23 2014 16:55:38 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
     configuration:
     libavutil      54. 15.100 / 54. 15.100
     libavcodec     56. 13.100 / 56. 13.100
     libavformat    56. 15.102 / 56. 15.102
     libavdevice    56.  3.100 / 56.  3.100
     libavfilter     5.  2.103 /  5.  2.103
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
    Input #0, image2, from '/tmp/TEST.jpg':
     Duration: 00:00:00.04, start: 0.000000, bitrate: 54530 kb/s
       Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1024x1432 [SAR 1:1 DAR 128:179], 25 tbr, 25 tbn, 25 tbc
    [swscaler @ 0x2bce0c0] deprecated pixel format used, make sure you did set range correctly
    Output #0, image2, to 'pipe:':
     Metadata:
       encoder         : Lavf56.15.102
       Stream #0:0: Video: mjpeg, yuvj420p(pc), 143x200 [SAR 25600:25597 DAR 128:179], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
       Metadata:
         encoder         : Lavc56.13.100 mjpeg
    Stream mapping:
     Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))
    Press [q] to stop, [?] for help
    �����JFIF��d�c������Lavc56.13.100����C�    
    ----FILE OUTPUT...edited out for clarity---
    ���frame=    1 fps=0.0 q=3.7 Lsize=N/A time=00:00:00.04 bitrate=N/A    
    video:5kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:     unknown
    ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
     built on Dec 23 2014 16:55:38 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
     configuration:
     libavutil      54. 15.100 / 54. 15.100
     libavcodec     56. 13.100 / 56. 13.100
     libavformat    56. 15.102 / 56. 15.102
     libavdevice    56.  3.100 / 56.  3.100
     libavfilter     5.  2.103 /  5.  2.103
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
    /tmp/phpxqYzHN: No such file or directory
    /tmp/phpxqYzHN: No such file or directory

    So it seems to work if I move the file first ? It’s really important that I don’t have any extra disk io, so this solution wouldn’t be acceptable...

    SOLUTION :
    So the problem was that ffmpeg was not able to recognize the input file type, since PHP’s tmp files don’t end with an extension (seems like a bug that ffmpeg looks at the extension rather than the internal mime type/headers). The solution was that I needed to add "-f image2" to the beginning of my command, so it ended up looking something like this :

    ffmpeg -f image2 -i '/tmp/PHP_TMP_FILE' -f image2 -s 400x200 -

    Hopefully this will save someone the many hours it took me to figure this out...

  • Python-FFMPEG Corruption Problems

    11 juillet 2023, par Gabriel Ruben Guzman

    I'm repurposing some python code to generate gifs/mp4s showcasing nba player movements dot form. (With the 'frames' used in the gifs being generated by matplotlib).

    


    The repo comes with two different functions for generating the gifs, watch_play and animate_play. Both of which use python command line functionalities to run ffmpeg and generate the mp4s.
I've been able to use the watch_play succesfully, bot every time I try using animate_play, which according to the documention is meant to be significantly faster than watch play, I run into the error showcased here.(I printed the cmd string being passed into the pipe, in the hopes it would make debugging easier) Error FFMPEG

    


    I've tried generating gifs/mp4s of various size and added a decent bit of code to lessen the volume of data being processed. (I'm essentially repurposing the code just to generate clips, so I've been able to remove a lot of the pbp/tracking data logs to speed up the run time) But no matter what I've done, gotten some variation of the screenshotted error.

    


    pipe: : corrupt input packet in stream 0&#xA;[rawvideo @ 0x55ccc0e2bb80] Invalid buffer size, packet size 691200 < expected frame_size 921600&#xA;Error while decoding stream #0:0 : Invalid argument

    &#xA;

    The code for animate_play

    &#xA;

    def animate_play(self, game_time=None, length=None, highlight_player=None,&#xA;                 commentary=True, show_spacing=None):&#xA;    """&#xA;    Method for animating plays in game.&#xA;    Outputs video file of play in {cwd}/temp.&#xA;    Individual frames are streamed directly to ffmpeg without writing them&#xA;    to the disk, which is a great speed improvement over watch_play&#xA;&#xA;    Args:&#xA;        game_time (int): time in game to start video&#xA;            (seconds into the game).&#xA;            Currently game_time can also be an tuple of length two&#xA;            with (starting_frame, ending_frame)if you want to&#xA;            watch a play using frames instead of game time.&#xA;        length (int): length of play to watch (seconds)&#xA;        highlight_player (str): If not None, video will highlight&#xA;            the circle of the inputed player for easy tracking.&#xA;        commentary (bool): Whether to include play-by-play commentary in&#xA;            the animation&#xA;        show_spacing (str) in [&#x27;home&#x27;, &#x27;away&#x27;]: show convex hull&#xA;            spacing of home or away team.&#xA;            If None, does not show spacing.&#xA;&#xA;    Returns: an instance of self, and outputs video file of play&#xA;    """&#xA;    if type(game_time) == tuple:&#xA;        starting_frame = game_time[0]&#xA;        ending_frame = game_time[1]&#xA;    else:&#xA;        game_time= self.start &#x2B;(self.quarter*720)&#xA;        end_time= self.end &#x2B;(self.quarter*720)&#xA;        length = end_time-game_time&#xA;        # Get starting and ending frame from requested &#xA;        # game_time and length&#xA;        print(&#x27;hit&#x27;)&#xA;        print(len(self.moments))&#xA;        print(game_time)&#xA;        print(end_time)&#xA;        print(length)&#xA;        print(game_time&#x2B;length)&#xA;        &#xA;        print(self.moments.game_time.min())&#xA;        print(self.moments.game_time.max())&#xA;&#xA;        sys.exit()&#xA;        starting_frame = self.moments[self.moments.game_time.round() ==&#xA;                                      game_time].index.values[0]&#xA;        ending_frame = self.moments[self.moments.game_time.round() ==&#xA;                                    game_time &#x2B; length].index.values[0]&#xA;&#xA;    # Make video of each frame&#xA;    filename = "./temp/{game_time}.mp4".format(game_time=game_time)&#xA;    if commentary:&#xA;        size = (960, 960)&#xA;    else:&#xA;        size = (480, 480)&#xA;    cmdstring = (&#x27;ffmpeg&#x27;,&#xA;                 &#x27;-y&#x27;, &#x27;-r&#x27;, &#x27;20&#x27;,  # fps&#xA;                 &#x27;-s&#x27;, &#x27;%dx%d&#x27; % size,  # size of image string&#xA;                 &#x27;-pix_fmt&#x27;, &#x27;argb&#x27;,  # Stream argb data from matplotlib&#xA;                 &#x27;-f&#x27;, &#x27;rawvideo&#x27;,&#x27;-i&#x27;, &#x27;-&#x27;,&#xA;                 &#x27;-vcodec&#x27;, &#x27;libx264&#x27;, filename)&#xA;    #print(pipe)&#xA;    #print(cmdstring)&#xA;    &#xA;    &#xA;&#xA;    # Stream plots to pipe&#xA;    pipe = Popen(cmdstring, stdin=PIPE)&#xA;    print(cmdstring)&#xA;    for frame in range(starting_frame, ending_frame):&#xA;        print(frame)&#xA;        self.plot_frame(frame, highlight_player=highlight_player,&#xA;                        commentary=commentary, show_spacing=show_spacing,&#xA;                        pipe=pipe)&#xA;    print(cmdstring)&#xA;    pipe.stdin.close()&#xA;    pipe.wait()&#xA;    return self&#xA;

    &#xA;

    The code for watch play

    &#xA;

    def watch_play(self, game_time=None, length=None, highlight_player=None,&#xA;               commentary=True, show_spacing=None):&#xA;&#xA;    """&#xA;    DEPRECIATED.  See animate_play() for similar (fastere) method&#xA;&#xA;    Method for viewing plays in game.&#xA;    Outputs video file of play in {cwd}/temp&#xA;&#xA;    Args:&#xA;        game_time (int): time in game to start video&#xA;            (seconds into the game).&#xA;            Currently game_time can also be an tuple of length&#xA;            two with (starting_frame, ending_frame) if you want&#xA;            to watch a play using frames instead of game time.&#xA;        length (int): length of play to watch (seconds)&#xA;        highlight_player (str): If not None, video will highlight&#xA;            the circle of the inputed player for easy tracking.&#xA;        commentary (bool): Whether to include play-by-play&#xA;            commentary underneath video&#xA;        show_spacing (str in [&#x27;home&#x27;, &#x27;away&#x27;]): show convex hull&#xA;            of home or away team.&#xA;            if None, does not display any convex hull&#xA;&#xA;    Returns: an instance of self, and outputs video file of play&#xA;    """&#xA;    print(&#x27;hit this point &#x27;)&#xA;    warnings.warn(("watch_play is extremely slow. "&#xA;                   "Use animate_play for similar functionality, "&#xA;                   "but greater efficiency"))&#xA;&#xA;    if type(game_time) == tuple:&#xA;        starting_frame = game_time[0]&#xA;        ending_frame = game_time[1]&#xA;    else:&#xA;        # Get starting and ending frame from requested game_time and length&#xA;        game_time= self.start &#x2B;(self.quarter*720)&#xA;        end_time= self.end &#x2B;(self.quarter*720)&#xA;        length = end_time-game_time&#xA;&#xA;&#xA;        starting_frame = self.moments[self.moments.game_time.round() ==&#xA;                                      game_time].index.values[0]&#xA;        ending_frame = self.moments[self.moments.game_time.round() ==&#xA;                                    game_time &#x2B; length].index.values[0]&#xA;    #print(self.moments.head(2))&#xA;    #print(starting_frame)&#xA;    #print(ending_frame)&#xA;    print(len(self.moments))&#xA;    # Make video of each frame&#xA;    title = str(starting_frame)&#x2B;&#x27;-&#x27;&#x2B;str(ending_frame)&#xA;    for frame in range(starting_frame, ending_frame):&#xA;        print(frame)&#xA;        self.plot_frame(frame, highlight_player=highlight_player,&#xA;                        commentary=commentary, show_spacing=show_spacing)&#xA;    command = (&#x27;ffmpeg -framerate 20 -start_number {starting_frame} &#x27;&#xA;               &#x27;-i %d.png -c:v libx264 -r 30 -pix_fmt yuv420p -vf &#x27;&#xA;               &#x27;"scale=trunc(iw/2)*2:trunc(ih/2)*2" {title}&#x27;&#xA;               &#x27;.mp4&#x27;).format(starting_frame=starting_frame,title=title)&#xA;    os.chdir(&#x27;temp&#x27;)&#xA;    os.system(command)&#xA;    os.chdir(&#x27;..&#x27;)&#xA;&#xA;    # Delete images&#xA;    for file in os.listdir(&#x27;./temp&#x27;):&#xA;        if os.path.splitext(file)[1] == &#x27;.png&#x27;:&#xA;            os.remove(&#x27;./temp/{file}&#x27;.format(file=file))&#xA;&#xA;    return self&#x27;&#xA;

    &#xA;

  • How to send time stamps to ffmpeg when encoding uncompressed video frames via stdin ?

    7 août 2023, par Spacy

    I'm writing a C# application, but this question applies to any programming language.&#xA;I know it is possible to pass uncompressed video frames (in yuv420p format) via stdin to ffmpeg.exe, but I recorded these frames to RAM from a webcam that has a variable frame rate. I have the exact time stamps for each frame. How do I send the time stamps to ffmpeg.exe together with the uncompressed frame data ?

    &#xA;

    I would prefer if it was possible to send them within the stdin byte stream, but I could also provide them up front when invoking ffmpeg.exe (this might become a very long argument list though). I could also write them to a text file on disk if nothing else works.

    &#xA;