Recherche avancée

Médias (1)

Mot : - Tags -/book

Autres articles (63)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • (Dés)Activation de fonctionnalités (plugins)

    18 février 2011, par

    Pour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
    SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
    Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
    MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...)

  • Activation de l’inscription des visiteurs

    12 avril 2011, par

    Il est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
    Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
    Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)

Sur d’autres sites (11102)

  • FFMpeg Command work in command line, but not in python script

    20 février 2015, par Fooldj

    Okay, kind of a weird problem. But I’m not sure whether it’s python, ffmpeg, or some stupid thing I’m doing wrong.

    I’m trying to take a video, and take 1 frame a second, and output that frame to an image. Right now, if i use the command line with ffmpeg :

    ffmpeg -i test.avi -r 1 -f image2 image-%3d.jpeg -pix_fmt rgb24 -vcodec rawrvideo

    It outputs about 10 images, the images look fine, awesome. Now I have this code (right now some code from some github, as I wanted stuff that i was relatively sure would work, and mine is allll convoluted)

    import subprocess as sp
    import numpy as np
    import re
    import cv2
    import time

    FFMPEG_BIN = r'ffmpeg.exe'
    INPUT_VID = 'test.avi'

    def getInfo():
       command = [FFMPEG_BIN,'-i', INPUT_VID, '-']
       pipe = sp.Popen(command, stdout=sp.PIPE, stderr=sp.PIPE)
       pipe.stdout.readline()
       pipe.terminate()
       infos = pipe.stderr.read()
       infos_list = infos.split('\r\n')
       res = re.search(' \d+x\d+ ',infos)
       res = [int(x) for x in res.group(0).split('x')]
       return res
    res = getInfo()
    command = [ FFMPEG_BIN,
           '-i', INPUT_VID,
           '-f', 'image2pipe',
           '-pix_fmt', 'rgb24',
           '-vcodec', 'rawvideo', '-']
    pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)
    n = 0
    im2 = []
    try:
       mog = cv2.BackgroundSubtractorMOG2(120,2,True)
       while True:
           raw_image = pipe.stdout.read(res[0]*res[1]*3)
           # transform the byte read into a numpy array
           image =  np.fromstring(raw_image, dtype='uint8')
           image = image.reshape((res[1],res[0],3))
           rgbImg = image.copy()

           fname = ('_tmp%03d.png'%time.time())
           cv2.imwrite(fname, rgbImg)
           # throw away the data in the pipe's buffer.
           #pipe.stdout.flush()
           n += 1
           print n
    except:
       print 'done',n
       pipe.kill()
       cv2.destroyAllWindows()

    When I run this, I get 10 images, but they all have a Blue Tint ! I cannot for the life of me figure out why. I’ve done tons of searches, I’ve tried quite a few different codecs (usually just messes things up worse). The media info for the video file is here :

    General
    Complete name                            : test.avi
    Format                                   : AVI
    Format/Info                              : Audio Video Interleave
    File size                                : 85.0 KiB
    Duration                                 : 133ms
    Overall bit rate                         : 5 235 Kbps

    Video
    ID                                       : 0
    Format                                   : JPEG
    Codec ID                                 : MJPG
    Duration                                 : 133ms
    Bit rate                                 : 1 240 Kbps
    Width                                    : 640 pixels
    Height                                   : 480 pixels
    Display aspect ratio                     : 4:3
    Frame rate                               : 30.000 fps
    Color space                              : YUV
    Chroma subsampling                       : 4:2:2
    Bit depth                                : 8 bits
    Compression mode                         : Lossy
    Bits/(Pixel*Frame)                       : 0.135
    Stream size                              : 20.1 KiB (24%)

    Any suggestions ? It seems like it should be an RGB mixup...just not sure where at...

  • FFmpeg : encoding in webm (vp9) for windows

    2 juillet 2015, par Seltymar

    I’m trying to encode jpegs to a webm video in vp9 on windows 7.

    I followed the instructions from webmproject in 2 pass.
    I changed \dev\nul by NUL.

    ffmpeg.exe -i %4d.jpg -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 8 -speed 4 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 -an -f webm NUL

    ffmpeg.exe -i %4d.jpg  -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 8 -speed 1 -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 -c:a libopus -b:a 64k -f webm out.webm

    but after the first pass, it tells me "output file is empty, nothing was encoded". But the second pass create the video.

    I also tryed in one pass :

    ffmpeg -i %4d.jpg -c:v libvpx-vp9 -crf 10 -b:v 0 output.webm

    Then I want to use the output video using html5 video and canvas tags as below.

       




    <canvas>
           Your browser does not support the canvas tag.
    </canvas>
    <code class="echappe-js">&lt;script&gt;<br />
    <br />
    <br />
           var videos = document.createElement('video');<br />
           videos.src = &quot;output.webm&quot;;<br />
           videos.type = &quot;video/webm&quot;;<br />
           videos.load(); <br />
           videos.play();<br />
           videos.playbackRate = 1;<br />
           var videoImage0 = document.getElementById('canvas');        <br />
           videoImage0.width = 2700;<br />
           videoImage0.height = 1350;<br />
    <br />
           var videoImageContexts =videoImage0.getContext('2d');<br />
           //// background color if no video present<br />
           videoImageContexts.fillStyle = '#0000ff';<br />
           videoImageContexts.fillRect(0, 0, videoImage0.width, videoImage0.height);       <br />
           animate();<br />
    <br />
       function animate() {<br />
           requestAnimationFrame(animate);<br />
           update();<br />
    <br />
       }<br />
    <br />
       function update() {<br />
    <br />
           if (videos.readyState === videos.HAVE_ENOUGH_DATA) {<br />
               videoImageContexts.drawImage(videos, 0, 0);<br />
           }<br />
       }<br />
    &lt;/script&gt;

    result :

    1. With both methods the output video can’t be read in VLC but it can be read if I drag and drop in firefox or chrome or using the video tag only.
    2. The html page above works correctly on chrome but not in firefox. In firefox, the color is not correct like if the blue channel was translated.
      enter image description here

    I think the problem is the encoding with FFmpeg. I’m using the static build from zeranoe. Here is the version FFmpeg version

    and libvpx is enable.

    My questions :

    • Is there a problem on my command line ?

    • Is there a problem in my JS code that could lead to error in the decoding process ?

  • Trying to encode video file as hevc error in python

    29 juin 2022, par jatt

    I am getting a syntax error when trying to run this code with it saying the end quotes being the error. process = sp.Popen(shlex.split(f&#x27;usr/bin/ffmpeg -y -s {width}x{height} -pixel_format bgr24 -f rawvideo -r {fps} -i pipe: -vcodec libx265 -pix_fmt yuv420p -crf 24 {output_filename}&#x27;) stdin=sp.PIPE)

    &#xA;

    I don't know why because the end quote is supposed to be there and I am not sure how to fix it.&#xA;The original code is from here : How to output x265 compressed video with cv2.VideoWriter

    &#xA;

    import cv2&#xA;import numpy as np&#xA;import subprocess as sp&#xA;import shlex&#xA;&#xA;width, height, n_frames, fps = 1344, 756, 50, 25  # 50 frames, resolution 1344x756, and 25 fps&#xA;&#xA;output_filename = &#x27;output.mp4&#x27;&#xA;&#xA;# Open ffmpeg application as sub-process&#xA;# FFmpeg input PIPE: RAW images in BGR color format&#xA;# FFmpeg output MP4 file encoded with HEVC codec.&#xA;# Arguments list:&#xA;# -y                   Overwrite output file without asking&#xA;# -s {width}x{height}  Input resolution width x height (1344x756)&#xA;# -pixel_format bgr24  Input frame color format is BGR with 8 bits per color component&#xA;# -f rawvideo          Input format: raw video&#xA;# -r {fps}             Frame rate: fps (25fps)&#xA;# -i pipe:             ffmpeg input is a PIPE&#xA;# -vcodec libx265      Video codec: H.265 (HEVC)&#xA;# -pix_fmt yuv420p     Output video color space YUV420 (saving space compared to YUV444)&#xA;# -crf 24              Constant quality encoding (lower value for higher quality and larger output file).&#xA;# {output_filename}    Output file name: output_filename (output.mp4)&#xA;process = sp.Popen(shlex.split(f&#x27;usr/bin/ffmpeg -y -s {width}x{height} -pixel_format bgr24 -f rawvideo -r {fps} -i pipe: -vcodec libx265 -pix_fmt yuv420p -crf 24 {output_filename}&#x27;) stdin=sp.PIPE)&#xA;&#xA;# Build synthetic video frames and write them to ffmpeg input stream.&#xA;for i in range(n_frames):&#xA;    # Build synthetic image for testing ("render" a video frame).&#xA;    img = np.full((height, width, 3), 60, np.uint8)&#xA;    cv2.putText(img, str(i&#x2B;1), (width//2-100*len(str(i&#x2B;1)), height//2&#x2B;100), cv2.FONT_HERSHEY_DUPLEX, 10, (255, 30, 30), 20)  # Blue number&#xA;&#xA;    # Write raw video frame to input stream of ffmpeg sub-process.&#xA;    process.stdin.write(img.tobytes())&#xA;&#xA;# Close and flush stdin&#xA;process.stdin.close()&#xA;&#xA;# Wait for sub-process to finish&#xA;process.wait()&#xA;&#xA;# Terminate the sub-process&#xA;process.terminate()&#xA;

    &#xA;