Recherche avancée

Médias (1)

Mot : - Tags -/artwork

Autres articles (101)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Configuration spécifique d’Apache

    4 février 2011, par

    Modules spécifiques
    Pour la configuration d’Apache, il est conseillé d’activer certains modules non spécifiques à MediaSPIP, mais permettant d’améliorer les performances : mod_deflate et mod_headers pour compresser automatiquement via Apache les pages. Cf ce tutoriel ; mode_expires pour gérer correctement l’expiration des hits. Cf ce tutoriel ;
    Il est également conseillé d’ajouter la prise en charge par apache du mime-type pour les fichiers WebM comme indiqué dans ce tutoriel.
    Création d’un (...)

Sur d’autres sites (9174)

  • Revision 4d9b9fa508 : Neon match to vp8 temporal denoiser fix Now match the "C" version of "Fix to re

    28 mai 2014, par Scott LaVarnway

    Changed Paths :
     Modify /vp8/encoder/arm/neon/denoising_neon.c



    Neon match to vp8 temporal denoiser fix

    Now match the "C" version of "Fix to reduce block
    artifacts from vp8 temporal denoiser."
    (see change id Id9b56e59e33f3c22e79d2f89f763bdde246fdf3f)

    Change-Id : I99e569bb6af4ae3532621127e12bf917a48ba08e

  • Revision 40019 : Toujours avoir 2 digits pour les minutes et les secondes même si elles ...

    23 août 2010, par kent1@… — Log

    Toujours avoir 2 digits pour les minutes et les secondes même si elles valent 0

  • Broken pipe when closing subprocess pipe with FFmpeg

    5 avril 2021, par Shawn

    First, I'm a total noob with ffmpeg. That said, similar to this question, I'm trying to read a video file as bytes and extract 1 frame as a thumbnail image, as bytes, so I can upload the thumbnail to AWS S3. I don't want to save files to disk and then have to delete them. I modified the accepted answer in the aforementioned question for my purposes, which is to handle different file formats, not just video. Image files work just fine with this code, but an mp4 breaks the pipe at byte_command.stdin.close(). I'm sure I'm missing something simple, but can't figure it out.

    


    The input bytes are a valid mp4, as I'm getting the following in the Terminal :

    


      Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isom
  Duration: 00:02:48.48, start: 0.000000, bitrate: N/A
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x480, 486 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))


    


    from FFmpeg when I write to stdin.

    



    


    My FFmpeg command I'm passing in :
ffmpeg -i /dev/stdin -f image2pipe -frames:v 1 -

    


    I've tried numerous variations of this command, with -f nut, -f ... etc, to no avail.

    



    


    At the command line, without using python or subprocess, I've tried :
ffmpeg -i /var/www/app/thumbnail/movie.mp4 -frames:v 1 output.png and I get a nice png image of the video.

    



    


    My method :

    


    def get_converted_bytes_from_bytes(input_bytes: bytes, command: str) -> bytes or None:
    byte_command = subprocess.Popen(
        shlex.split(command),
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        shell=False,
        bufsize=10 ** 8,
    )
    b = b""

    byte_command.stdin.write(input_bytes)
    byte_command.stdin.close()
    while True:
        output = byte_command.stdout.read()
        if len(output) > 0:
            b += output
        else:
            error_msg = byte_command.poll()
            if error_msg is not None:
                break
    return b


    


    What am I missing ? Thank you !

    



    


    UPDATE, AS REQUESTED :

    


    Code Sample :

    


    import shlex
import subprocess


def get_converted_bytes_from_bytes(input_bytes: bytes, command: str) -> bytes or None:
    byte_command = subprocess.Popen(
        shlex.split(command),
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        shell=False,
        bufsize=10 ** 8,
    )
    b = b""
    # write bytes to processe's stdin and close the pipe to pass
    # data to piped process
    byte_command.stdin.write(input_bytes)
    byte_command.stdin.close()
    while True:
        output = byte_command.stdout.read()
        if len(output) > 0:
            b += output
        else:
            error_msg = byte_command.poll()
            if error_msg is not None:
                break
    return b


def run():
    subprocess.run(
        shlex.split(
            "ffmpeg -y -f lavfi -i testsrc=size=640x480:rate=1 -vcodec libx264 -pix_fmt yuv420p -crf 23 -t 5 test.mp4"
        )
    )
    with open("test.mp4", "rb") as mp4:
        b1 = mp4.read()
        b = get_converted_bytes_from_bytes(
            b1,
            "ffmpeg -y -loglevel error -i /dev/stdin -f image2pipe -frames:v 1 -",
        )
        print(b)


if __name__ == "__main__":
    run()