Recherche avancée

Médias (91)

Autres articles (1)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

Sur d’autres sites (2834)

  • ffmpeg output to opencv

    28 juin 2018, par 徐立派

    I am currently writing a simple script to pipe the output of ffmpeg to opencv, but it keeps yelling me error.

    My entire command line is

    ffmpeg -flags output_corrupt -analyzeduration 32 -probesize 32 -i temp_file.h264 -updatefirst 1 -y -qscale:v 2 -vf scale="240 :-1" -f image2pipe - | python cap.py

    My code for the python script is below

    import sys
    import cv2 as cv
    import numpy as np


    while True:
       img = sys.stdin
       # print img
       # img = cv.imdecode(img, 1)
       if img is not None:
           cv.imshow("Video", img)
           cv.waitkey(1)
       else:
           print "No image"

    After I execute the command line, I got the following messages :

    ffmpeg version 3.4.2-2 Copyright (c) 2000-2018 the FFmpeg developers
     built with gcc 7 (Ubuntu 7.3.0-16ubuntu2)
     configuration: --prefix=/usr --extra-version=2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
     libavutil      55. 78.100 / 55. 78.100
     libavcodec     57.107.100 / 57.107.100
     libavformat    57. 83.100 / 57. 83.100
     libavdevice    57. 10.100 / 57. 10.100
     libavfilter     6.107.100 /  6.107.100
     libavresample   3.  7.  0 /  3.  7.  0
     libswscale      4.  8.100 /  4.  8.100
     libswresample   2.  9.100 /  2.  9.100
     libpostproc    54.  7.100 / 54.  7.100
    [h264 @ 0x557ea6b01a60] Stream #0: not enough frames to estimate rate; consider increasing probesize
    [h264 @ 0x557ea6b01a60] decoding for stream 0 failed
    Input #0, h264, from 'temp_file.h264':
     Duration: N/A, bitrate: N/A
       Stream #0:0: Video: h264 (High), yuvj420p(pc, progressive), 1280x720, 29.97 tbr, 1200k tbn, 59.94 tbc
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
    Press [q] to stop, [?] for help
    [h264 @ 0x557ea6b22a60] error while decoding MB 54 2, bytestream -16
    [h264 @ 0x557ea6b22a60] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6b22a60] error while decoding MB 2 9, bytestream 6907
    [h264 @ 0x557ea6b22a60] concealing 1275 DC, 1275 AC, 1275 MV errors in P frame
    [h264 @ 0x557ea6b28740] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6b28740] error while decoding MB 27 0, bytestream 5564
    [h264 @ 0x557ea6b28740] deblocking filter parameters 7 13 out of range
    [h264 @ 0x557ea6b28740] decode_slice_header error
    [h264 @ 0x557ea6b28740] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
    [h264 @ 0x557ea6ba5be0] deblocking filter parameters 7 -14 out of range
    [h264 @ 0x557ea6ba5be0] decode_slice_header error
    [swscaler @ 0x557ea7159ba0] deprecated pixel format used, make sure you did set range correctly
    [mpeg2video @ 0x557ea6b2ecc0] too many threads/slices (10), reducing to 9
    [h264 @ 0x557ea6ba5be0] concealing 1387 DC, 1387 AC, 1387 MV errors in P frame
    Output #0, mpegts, to 'pipe:':
     Metadata:
       encoder         : Lavf57.83.100
       Stream #0:0: Video: mpeg2video (Main), yuv420p, 240x135, q=2-31, 200 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
       Metadata:
         encoder         : Lavc57.107.100 mpeg2video
       Side data:
         cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
    [h264 @ 0x557ea6bc1b60] deblocking filter parameters -7 0 out of range
    [h264 @ 0x557ea6bc1b60] decode_slice_header error
    [h264 @ 0x557ea6bc1b60] concealing 1413 DC, 1413 AC, 1413 MV errors in P frame
    [h264 @ 0x557ea6bddae0] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6bddae0] error while decoding MB 9 0, bytestream 6647
    [h264 @ 0x557ea6bddae0] concealing 1186 DC, 1186 AC, 1186 MV errors in P frame
    [h264 @ 0x557ea6bf9a60] top block unavailable for requested intra mode
    [h264 @ 0x557ea6bf9a60] error while decoding MB 16 9, bytestream 6182
    [h264 @ 0x557ea6bf9a60] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6bf9a60] error while decoding MB 6 18, bytestream 7043
    [h264 @ 0x557ea6bf9a60] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
    [h264 @ 0x557ea6c159e0] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6c159e0] error while decoding MB 12 9, bytestream 6863
    [h264 @ 0x557ea6c159e0] concealing 1342 DC, 1342 AC, 1342 MV errors in P frame
    [h264 @ 0x557ea6c31d40] top block unavailable for requested intra mode
    [h264 @ 0x557ea6c31d40] error while decoding MB 29 18, bytestream 6611
    [h264 @ 0x557ea6c31d40] concealing 1405 DC, 1405 AC, 1405 MV errors in P frame
    [h264 @ 0x557ea6c4e0a0] top block unavailable for requested intra mode
    [h264 @ 0x557ea6c4e0a0] error while decoding MB 25 9, bytestream 6051
    [h264 @ 0x557ea6c4e0a0] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6c4e0a0] error while decoding MB 70 18, bytestream 5088
    [h264 @ 0x557ea6c4e0a0] concealing 1419 DC, 1419 AC, 1419 MV errors in P frame
    [h264 @ 0x557ea6c6a400] top block unavailable for requested intra mode
    [h264 @ 0x557ea6c6a400] error while decoding MB 14 9, bytestream 6071
    [h264 @ 0x557ea6c6a400] deblocking filter parameters -9 0 out of range
    [h264 @ 0x557ea6c6a400] decode_slice_header error
    [h264 @ 0x557ea6c6a400] concealing 1440 DC, 1440 AC, 1440 MV errors in P frame
    [h264 @ 0x557ea6c86760] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6c86760] error while decoding MB 54 9, bytestream 4422
    [h264 @ 0x557ea6c86760] concealing 1256 DC, 1256 AC, 1256 MV errors in P frame
    [h264 @ 0x557ea6ca2ac0] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6ca2ac0] error while decoding MB 22 9, bytestream 5862
    [h264 @ 0x557ea6ca2ac0] concealing 1335 DC, 1335 AC, 1335 MV errors in P frame
    [h264 @ 0x557ea6b2f180] deblocking filter parameters 7 -4 out of range
    [h264 @ 0x557ea6b2f180] decode_slice_header error
    [h264 @ 0x557ea6b2f180] concealing 1430 DC, 1430 AC, 1430 MV errors in P frame
    Traceback (most recent call last):
     File "cap.py", line 11, in <module>
       cv.imshow("Video", img)
    TypeError: mat is not a numpy array, neither a scalar
    [h264 @ 0x557ea6b22a60] concealing 1319 DC, 1319 AC, 1319 MV errors in P frame
    [h264 @ 0x557ea6b28740] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6b28740] error while decoding MB 16 9, bytestream 6218
    [h264 @ 0x557ea6b28740] concealing 1416 DC, 1416 AC, 1416 MV errors in P frame
    [h264 @ 0x557ea6ba5be0] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6ba5be0] error while decoding MB 12 0, bytestream 6854
    [h264 @ 0x557ea6ba5be0] top block unavailable for requested intra mode -1
    [h264 @ 0x557ea6ba5be0] error while decoding MB 2 9, bytestream 7092
    </module>

    It seems that opencv doesn’t recognize the image that I pipe to it with

    Traceback (most recent call last):
     File "cap.py", line 11, in <module>
       cv.imshow("Video", img)
    TypeError: mat is not a numpy array, neither a scalar
    </module>

    Anyone know where the problem is ? Any help is appreciated, thanks in advance.

  • ValueError : I/O operation on closed file when making animation

    3 juillet 2018, par user3851187

    I am using matplotlib and ffmpeg to do some animations. I usually code on a remote server because the code runs faster ; we are having some issues making animations on the remote server. Here is an example of code that works perfectly on my local mac but does not work remotely.

    import matplotlib as mpl
    mpl.use('agg')
    import matplotlib as mpl
    from matplotlib import animation
    import pylab

    def init():
       pylab.plot(pylab.arange(10), [0]*10)

    def redraw(frame):
       pylab.plot(pylab.arange(10), pylab.arange(10) * frame)

    fig = pylab.figure()
    ani = animation.FuncAnimation(fig, redraw, frames=10, interval=1000, init_func=init)
    ani.save('animation.mp4')

    I get the animation I want on my local machine (macOS Sierra). When I run it on the remote host (Debian GNU/Linux 8 (jessie)), I get the following error message after 5 frames

    Traceback (most recent call last):
     File "animation.py", line 14, in <module>
       ani.save('animation.mp4')
     File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 1200, in save
       writer.grab_frame(**savefig_kwargs)
     File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
       self.gen.throw(type, value, traceback)
     File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 241, in saving
       self.finish()
     File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 367, in finish
       self.cleanup()
     File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 405, in cleanup
       out, err = self._proc.communicate()
     File "/usr/local/lib/python2.7/dist-packages/subprocess32.py", line 724, in communicate
       stdout, stderr = self._communicate(input, endtime, timeout)
     File "/usr/local/lib/python2.7/dist-packages/subprocess32.py", line 1535, in _communicate
       orig_timeout)
     File "/usr/local/lib/python2.7/dist-packages/subprocess32.py", line 1591, in _communicate_with_poll
       register_and_append(self.stdout, select_POLLIN_POLLPRI)
     File "/usr/local/lib/python2.7/dist-packages/subprocess32.py", line 1570, in register_and_append
       poller.register(file_obj.fileno(), eventmask)
    ValueError: I/O operation on closed file
    </module>

    My local machine uses matplotlib version 2.0.0 ; the remote machine uses matplotlib version 2.2.2

    On my local machine I have ffmpeg version 3.2.4

    $ ffmpeg -version
    ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
    built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
    configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.4 --enable-shared -
    -enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables
    --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
    libavutil      55. 34.101 / 55. 34.101
    libavcodec     57. 64.101 / 57. 64.101
    libavformat    57. 56.101 / 57. 56.101
    libavdevice    57.  1.100 / 57.  1.100
    libavfilter     6. 65.100 /  6. 65.100
    libavresample   3.  1.  0 /  3.  1.  0
    libswscale      4.  2.100 /  4.  2.100
    libswresample   2.  3.100 /  2.  3.100
    libpostproc    54.  1.100 / 54.  1.100

    On the remote host i have ffmpeg version 4.0.1

    ffmpeg -version
    ffmpeg version 4.0.1 Copyright (c) 2000-2018 the FFmpeg developers
    built with gcc 4.9.2 (Debian 4.9.2-10+deb8u1)
    configuration: --prefix=/usr/local
    libavutil      56. 14.100 / 56. 14.100
    libavcodec     58. 18.100 / 58. 18.100
    libavformat    58. 12.100 / 58. 12.100
    libavdevice    58.  3.100 / 58.  3.100
    libavfilter     7. 16.100 /  7. 16.100
    libswscale      5.  1.100 /  5.  1.100
    libswresample   3.  1.100 /  3.  1.100

    If I recall correctly I installed ffmpeg locally through homebrew ; I have the anaconda distribution of python. On the remote machine we have the default version of python that comes with Jessie ; I’m not sure how the sysadmin installed ffmpeg.

    I am by no means an expert on ffmpeg, but I have generally never had issues with making animations in matplotlib on my local machine and I would really like to be able to make videos more quickly on the remote machine. Any help would be appreciated !

    Edit
    On the remote machine, the animation works if I use avconv as the writer instead of ffmpeg. I installed avconv locally...which led me to get the same ffmpeg issues locally (probably due to updating shared dependencies). However, I uninstalled ffmpeg and reinstalled it with x264 codec enables Animations in ipython (jupyter) notebook - ValueError : I/O operation on closed file

  • ffmpeg error or success

    3 juillet 2018, par user1867151

    I have a file sample.aif on which I want to apply the below filters :

    1. Trim sample to a maximum duration of 2 seconds

    2. Compression applied with settings : threshold 0.1,ratio=2,attack=5

    3. 20 milliseconds fade out at end .

    I am running the below ffmpeg command : ffmpeg -i kick.aif -af atrim=0:120 -af acompressor=threshold=0.1:ratio=2:attack=5 -af afade=d=0.02 kick.ogg 2>error.out

    When I check the return code I see it is 0 however my error. Out file has the below output :

    cat error.out
    ffmpeg version 2.8.14-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
     built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
     configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
     libavutil      54. 31.100 / 54. 31.100
     libavcodec     56. 60.100 / 56. 60.100
     libavformat    56. 40.101 / 56. 40.101
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 40.101 /  5. 40.101
     libavresample   2.  1.  0 /  2.  1.  0
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  2.101 /  1.  2.101
     libpostproc    53.  3.100 / 53.  3.100
    Guessed Channel Layout for  Input Stream #0.0 : stereo
    Input #0, aiff, from 'kick.aif':
     Duration: 00:00:01.54, start: 0.000000, bitrate: 3072 kb/s
       Stream #0:0: Audio: pcm_f32be (fl32 / 0x32336C66), 48000 Hz, 2 channels, flt, 3072 kb/s
    Output #0, ogg, to 'kick.ogg':
     Metadata:
       encoder         : Lavf56.40.101
       Stream #0:0: Audio: vorbis (libvorbis), 48000 Hz, stereo, fltp
       Metadata:
         encoder         : Lavc56.60.100 libvorbis
    Stream mapping:
     Stream #0:0 -> #0:0 (pcm_f32be (native) -> vorbis (libvorbis))
    Press [q] to stop, [?] for help
    size=       6kB time=00:00:01.52 bitrate=  33.9kbits/s
    video:0kB audio:2kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 175.053040%

    I am absolutely new to ffmpeg. Can someone tell me where I am going wrong ?

    Many thanks in advance.