Recherche avancée

Médias (2)

Mot : - Tags -/map

Autres articles (45)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Changer son thème graphique

    22 février 2011, par

    Le thème graphique ne touche pas à la disposition à proprement dite des éléments dans la page. Il ne fait que modifier l’apparence des éléments.
    Le placement peut être modifié effectivement, mais cette modification n’est que visuelle et non pas au niveau de la représentation sémantique de la page.
    Modifier le thème graphique utilisé
    Pour modifier le thème graphique utilisé, il est nécessaire que le plugin zen-garden soit activé sur le site.
    Il suffit ensuite de se rendre dans l’espace de configuration du (...)

  • Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs

    12 avril 2011, par

    La manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
    Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras.

Sur d’autres sites (3753)

  • How can I open a program using PYTHON with Mutliprocessing, and send it strings from the main process ?

    12 février 2018, par Just Askin

    I have a program that sends frames as strings to FFMPEG using something similar to :

    Working script that streams without using multiprocessing module currently on Ubuntu

    #!/usr/bin/python
    import sys, os
    import subprocess as sp
    import pygame
    from pygame.locals import QUIT, KEYUP, K_ESCAPE
    import pygame.display

    pygame.init()
    os.environ['SDL_VIDEODRIVER'] = 'dummy'
    pygame.display.init()
    Display_Surface = pygame.display.set_mode([1280,720], 0, 32)

    # FFMPEG command and settings
    command = ['ffmpeg', '-framerate', '25', '-s', '1280x720', '-pix_fmt', 'rgba', '-f', 'rawvideo', '-i', '-',
              '-f', 'lavfi', '-i', 'anullsrc=cl=mono',
              '-pix_fmt', 'yuv420p','-s', 'hd720', '-r', '25', '-g', '50',
              '-f', 'flv', 'rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx']

    pipe = sp.Popen(command, bufsize=0, stdin=sp.PIPE)

    while True:
       # Quit event handling
       for event in pygame.event.get():
           if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
               pygame.quit()
               sys.exit()

       pipe.stdin.write(pygame.image.tostring(Display_Surface, "RGBA"))

    pipe.stdin.close()
    pygame.display.quit()
    os._exit()

    This works fine, except for the fact that it is killing my CPU, which in turn causes my live stream to freeze often. The stupid GIL won’t let FFMPEG run on another CPU/Core while I have 3 perfectly good cores doing nothing.

    I just whipped up some code to open FFMPEG in another process. (By the way, I’m familiar with threading.Thread, but not Multiprocessing).

    import os
    import subprocess as sp
    import multiprocessing

    class FFMPEG_Consumer():

       def __init__(self):
           proc = multiprocessing.Process(target=self.start_ffmpeg)
           proc.start()

       def start_ffmpeg(self):
           command = ['ffmpeg','-pix_fmt', 'rgba', '-f', 'rawvideo', '-i', '-',
                      '-f, 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=44100',
                      '-pix_fmt', 'yuv420p','-s', 'hd720', '-f', 'flv', 'rtmp://example.com']

           pipe = sp.Popen(command, bufsize=-1, stdin=sp.PIPE)

       def send_down_the_pipe(self, frame):
           pipe.stdin.write(frame)

    ffmpeg = FFMPEG_Consumer()

    For anyone that knows how to use multiprocessing, I’m sure you will immediately see that this does not work because I can’t share variables this way across processes. But, it does open FFMPEG on another core.

    Most online tutorials and resources focus creating pools of workers and queues to send those workers something to be processed until a job is finished. I am however trying to send a new string repeatedly to FFMPEG through each iteration.

    How can I pipe my string to that process/instance of FFMPEG ?

    Or is what I’m trying to do not possible ?

    This was the working solution (with dumbed down FFMPEG settings) :

    #!/usr/bin/python
    import sys, os, multiprocessing
    import subprocess as sp
    import pygame
    from pygame.locals import QUIT, KEYUP, K_ESCAPE
    import pygame.display

    pygame.init()
    os.environ['SDL_VIDEODRIVER'] = 'dummy'
    pygame.display.init()
    Display_Surface = pygame.display.set_mode([1280,720], 0, 32)

    class FFMPEGConsumer(object):
       def __init__(self):
           self._r, self._w = multiprocessing.Pipe()
           self.reader = os.fdopen(self._r.fileno(), 'r')
           self.writer = os.fdopen(self._w.fileno(), 'w', 0)
           self.proc = None

       def start_ffmpeg(self):

           command = ['ffmpeg', '-framerate', '25', '-s', '1280x720', '-pix_fmt', 'rgba', '-f', 'rawvideo', '-i', '-',
              '-f', 'lavfi', '-i', 'anullsrc=cl=mono',
              '-pix_fmt', 'yuv420p','-s', 'hd720', '-r', '25', '-g', '50',
              '-f', 'flv', 'rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx']

           self.proc = sp.Popen(command, bufsize=-1, stdin=self.reader)

       def send_down_the_pipe(self, frame):
           self.writer.write(frame)
           #print self._stdin.read()

       def __del__(self):
           self.reader.close()
           self.writer.close()

    ffmpeg = FFMPEGConsumer()

    while True:
       # Quit event handling
       for event in pygame.event.get():
           if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
               pygame.quit()
               sys.exit()

       ffmpeg.send_down_the_pipe(pygame.image.tostring(Display_Surface, "RGBA"))
       proc.join()

    pipe.stdin.close()
    pygame.display.quit()
    os._exit()

    All cores are firing and no lags so far !!!

  • avformat/wavdec : Consider AV_INPUT_BUFFER_PADDING_SIZE in set_spdif()

    24 novembre 2020, par Michael Niedermayer
    avformat/wavdec : Consider AV_INPUT_BUFFER_PADDING_SIZE in set_spdif()
    

    The buffer is read by using the bit reader
    Fixes : out of array read
    Fixes : 27539/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-5650565572591616

    Found-by : continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
    Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>

    • [DH] libavformat/wavdec.c
  • How to show a watermark for 3 second on a MP4 using FFmpeg

    6 février 2014, par b1izzard

    I need to add a 3-second watermark to a Camera recorded video in Android. I'm using FFmpeg static build to execute the commands.

    Approach I

    I had tried the below command using latest version of FFmpeg(version N-60108-gda25a65) in my Desktop running Linux Mint, the command works fine.

    ffmpeg -y -itsoffset 3 -i input.mp4 -i myImage.jpg -filter_complex "[0:v][1:v]overlay=0:0:enable=between(t\,0\,3)"  -codec:a copy output.mp4

    In Android I'm using the FFmpegv1.2 with below config to execute the command.

    *******Starting FFMPEG
       ***ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers***
       ***  built on Mar 31 2013 23:44:57 with gcc 4.6 (GCC) 20120106 (prerelease)***
       ***  configuration: --arch=arm --target-os=linux --enable-runtime-cpudetect --enable-pic --disable-shared --enable-static --cross-prefix=/opt/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --sysroot=/opt/android-ndk-r8e/platforms/android-8/arch-arm --extra-cflags=&#39;-march=armv6&#39; --extra-ldflags= --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-network***
       ***  libavutil      52. 18.100 / 52. 18.100***
       ***  libavcodec     54. 92.100 / 54. 92.100***
       ***  libavformat    54. 63.104 / 54. 63.104***
       ***  libavdevice    54.  3.103 / 54.  3.103***
       ***  libavfilter     3. 42.103 /  3. 42.103***
       ***  libswscale      2.  2.100 /  2.  2.100***
       ***  libswresample   0. 17.102 /  0. 17.102***

    Java Code to run the FFmpeg command :

    String[] ffmpegCommandToAddWatermark = {
               mFfmpegInstallPath, "-y", "-itsoffset","3",
                "-i", INPUT_VIDEO_PATH, "-i", WATERMARK_IMAGE_PATH,
                "-filter_complex","[0:v][1:v]overlay=0:0:between(t\\,0\\,3)",
                "-strict","-2",
                "-codec:a","copy",OUTPUT_VIDEO_PATH};          
           try {
           Process ffmpegProcess = new ProcessBuilder(ffmpegCommandToAddWatermark)
               .redirectErrorStream(true).start();

           String line;

           BufferedReader reader = new BufferedReader(
               new InputStreamReader(ffmpegProcess.getInputStream()));
           Log.d(TAG, "*******Starting FFMPEG");
           while ((line = reader.readLine()) != null ) {

               Log.d(TAG, "***" + line + "***");
           }
           Log.d(null, "****ending FFMPEG****");

           } catch (Exception e) {
           e.printStackTrace();
           }

    The command execution failed with following error :

    ***[overlay @ 0x271f770] No option name near &#39;between(t,0,3)&#39;***
    ***[AVFilterGraph @ 0x2711530] Error initializing filter &#39;overlay&#39; with args &#39;0:0:between(t,0,3)&#39;***
    ***Error configuring filters.***

    The same command executes successfully when :enable=between(t\,0\,3) is removed, but the resulting output video has the watermark throughout the timeline, but I need watermark only for the starting 3 seconds.

    Approach II :

    I tried to convert WaterMarkImage to WaterMarkVideo

    ffmpeg -y -loop 1 -r 30 -i WaterMarkImage.jpg -b:v "4096k" -vf "scale=640:480" -t 3 WaterMarkVideo.mp4

    And then merge the WaterMarkVideo.mp4+CameraRecordedVideo.mp4 using the concat command :

    ffmpeg -y -f concat -i inputs.txt -c copy output.mp4

    The resulting output is corrupt due to BitRate,FrameRate,etc., mismatch. Any idea to solve the problem ?.