Recherche avancée

Médias (91)

Autres articles (28)

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (3271)

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

  • 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>&amp;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>&amp;1');

                   $file_s = system('ffmpeg -i ' . escapeshellarg($_FILES['upload_media_hidden']['tmp_name'][$i]) . ' -f image2 -s ' . $aspect_ratio_s . ' - 2>&amp;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...

  • Where does FFMPEG store temporary files in Linux ?

    8 juillet 2023, par 001121100

    I canceled the conversion of a very large file in ffmpeg. The incomplete file is taking up almost 200GB on my disk but it does not exist in the directory I was working in and I can't find it anywhere. Where does ffmpeg store temporary, incomplete, or canceled files ?

    &#xA;

    (I've had a similar problem in the past when running a file recovery program - I canceled the recovery and the files disappeared. They are simply taking up "ghost" space on the directory and can't be located.)

    &#xA;

    I've tried searching for the filename, clearing the trash, rebooting.

    &#xA;