Recherche avancée

Médias (0)

Mot : - Tags -/alertes

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (111)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

Sur d’autres sites (9079)

  • Unknown input format : 'rawvideo' when trying to save animation

    8 juin 2022, par John Klint

    So, I get a strange error trying to save animations created with matplotlib.FuncAnimation using FFMpegWriter.

    


    /home/j/PycharmProjects/venvtest/venv/bin/python /home/j/PycharmProjects/venvtest/main.py&#xA;MovieWriter stderr:&#xA;Unknown input format: &#x27;rawvideo&#x27;&#xA;&#xA;Traceback (most recent call last):&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/animation.py", line 234, in saving&#xA;    yield self&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/animation.py", line 1093, in save&#xA;    writer.grab_frame(**savefig_kwargs)&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/animation.py", line 351, in grab_frame&#xA;    self.fig.savefig(self._proc.stdin, format=self.frame_format,&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/figure.py", line 3046, in savefig&#xA;    self.canvas.print_figure(fname, **kwargs)&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 2319, in print_figure&#xA;    result = print_method(&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/backend_bases.py", line 1648, in wrapper&#xA;    return func(*args, **kwargs)&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/_api/deprecation.py", line 415, in wrapper&#xA;    return func(*inner_args, **inner_kwargs)&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py", line 486, in print_raw&#xA;    fh.write(renderer.buffer_rgba())&#xA;BrokenPipeError: [Errno 32] Broken pipe&#xA;&#xA;During handling of the above exception, another exception occurred:&#xA;&#xA;Traceback (most recent call last):&#xA;  File "/home/j/PycharmProjects/venvtest/main.py", line 24, in <module>&#xA;    anim.save(&#x27;basic_animation.mp4&#x27;, writer=FFwriter)&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/animation.py", line 1093, in save&#xA;    writer.grab_frame(**savefig_kwargs)&#xA;  File "/usr/lib/python3.9/contextlib.py", line 137, in __exit__&#xA;    self.gen.throw(typ, value, traceback)&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/animation.py", line 236, in saving&#xA;    self.finish()&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/animation.py", line 342, in finish&#xA;    self._cleanup()  # Inline _cleanup() once cleanup() is removed.&#xA;  File "/home/j/PycharmProjects/venvtest/venv/lib/python3.9/site-packages/matplotlib/animation.py", line 373, in _cleanup&#xA;    raise subprocess.CalledProcessError(&#xA;subprocess.CalledProcessError: Command &#x27;[&#x27;/usr/bin/ffmpeg&#x27;, &#x27;-f&#x27;, &#x27;rawvideo&#x27;, &#x27;-vcodec&#x27;, &#x27;rawvideo&#x27;, &#x27;-s&#x27;, &#x27;640x480&#x27;, &#x27;-pix_fmt&#x27;, &#x27;rgba&#x27;, &#x27;-r&#x27;, &#x27;5&#x27;, &#x27;-loglevel&#x27;, &#x27;error&#x27;, &#x27;-i&#x27;, &#x27;pipe:&#x27;, &#x27;-vcodec&#x27;, &#x27;h264&#x27;, &#x27;-pix_fmt&#x27;, &#x27;yuv420p&#x27;, &#x27;-y&#x27;, &#x27;basic_animation.mp4&#x27;]&#x27; returned non-zero exit status 1.&#xA;&#xA;Process finished with exit code 1&#xA;</module>

    &#xA;

    I am confident it has nothing to do with the animation data, the error occurs even when I create a simple test animation :

    &#xA;

    import numpy as np&#xA;from matplotlib import pyplot as plt&#xA;from matplotlib import animation&#xA;# plt.rcParams[&#x27;animation.ffmpeg_path&#x27;] = &#x27;/usr/bin/ffmpeg&#x27;&#xA;&#xA;fig = plt.figure()&#xA;ax = plt.axes(xlim=(0, 2), ylim=(-2, 2))&#xA;line, = ax.plot([], [], lw=2)&#xA;&#xA;&#xA;def init():&#xA;    line.set_data([], [])&#xA;    return line,&#xA;&#xA;&#xA;def animate(i):&#xA;    x = np.linspace(0, 2, 1000)&#xA;    y = np.sin(2 * np.pi * (x - 0.01 * i))&#xA;    line.set_data(x, y)&#xA;    return line,&#xA;&#xA;&#xA;anim = animation.FuncAnimation(fig, animate, init_func=init,&#xA;                           frames=200, interval=20, blit=True)&#xA;&#xA;FFwriter = animation.FFMpegWriter()&#xA;anim.save(&#x27;basic_animation.mp4&#x27;, writer=FFwriter)&#xA;

    &#xA;

    I am currently using PyCharm in LinuxMint and I have a fairly new version of FFMpeg (4.2.4) installed. Given that FFMpeg complains about 'rawvideo' which as far as I understand it is just a bunch of images in series, it seems unlikely this has anything to do with codecs. If I run ffmpeg -formats, sure enough rawvideo is in the list.

    &#xA;

    I have tried manually setting plt.rcParams, like in the commented line in the code above, with no success. I have also tried setting up both anaconda and venv environments, but I get the same error.&#xA;Annoyingly, I did not have this problem a few months ago when I was using Ubuntu. I have also verified that it works on my friends Ubuntu desktop, using the same simple venv as I set up for myself.

    &#xA;

    Any ideas ?

    &#xA;

    EDIT : I use the fish shell, if that is relevant...

    &#xA;

    Well this is peculiar. If I start a terminal from within PyCharm and check supported formats, I get the following :

    &#xA;

    (venv) ffmpeg -formats&#xA;ffmpeg version 4.3.4 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with gcc 11.3.0 (GCC)&#xA;  configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-debug --disable-doc --disable-static --enable-optimizations --enable-shared --disable-everything --enable-ffplay --enable-ffprobe --enable-gnutls --enable-libaom --enable-libdav1d --enable-libfdk-aac --enable-libmp3lame --enable-libfontconfig --enable-libfreetype --enable-libopus --enable-libpulse --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-openal --enable-opengl --enable-sdl2 --enable-vulkan --enable-zlib --enable-libv4l2 --enable-libxcb --enable-vdpau --enable-vaapi --enable-encoder=&#x27;ac3,alac,flac,libfdk_aac,g723_1,mp2,libmp3lame,libopus,libspeex,pcm_alaw,pcm_mulaw,pcm_f32le,pcm_s16be,pcm_s24be,pcm_s16le,pcm_s24le,pcm_s32le,pcm_u8,tta,libvorbis,wavpack,&#x27; --enable-encoder=&#x27;ass,ffv1,libaom_av1,libvpx_vp8,libvpx_vp9,mjpeg_vaapi,rawvideo,theora,vp8_vaapi,libopenh264&#x27; --enable-decoder=&#x27;adpcm_g722,alac,flac,g723_1,g729,libfdk_aac,libopus,libspeex,mp2,mp3,m4a,pcm_alaw,pcm_mulaw,pcm_f16le,pcm_f24le,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_s16be,pcm_s16be_planar,pcm_s24be,pcm_s16le,pcm_s16le_planar,pcm_s24le,pcm_s24le_planar,pcm_s32le,pcm_s32le_planar,pcm_s64be,pcm_s64le,pcm_s8,pcm_s8_planar,pcm_u8,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,tta,vorbis,wavpack,&#x27; --enable-decoder=&#x27;ass,ffv1,mjpeg,mjpegb,libaom_av1,libdav1d,libvpx_vp8,libvpx_vp9,rawvideo,theora,vp8,vp9,libopenh264&#x27; --enable-encoder=&#x27;bmp,gif,jpegls,png,tiff,webp,&#x27; --enable-decoder=&#x27;bmp,gif,jpegls,png,tiff,webp,&#x27; --enable-hwaccel=&#x27;vp8_vaapi,mjpeg_vaapi,&#x27; --enable-parser=&#x27;aac,ac3,flac,mjpeg,mpegaudio,mpeg4video,opus,vp3,vp8,vp9,vorbis,&#x27; --enable-muxer=&#x27;ac3,ass,flac,g722,gif,matroska,mp3,mpegvideo,rtp,ogg,opus,pcm_s16be,pcm_s16le,wav,webm,&#x27; --enable-demuxer=&#x27;aac,ac3,ass,flac,g722,gif,image_jpeg_pipe,image_png_pipe,image_webp_pipe,matroska,mjpeg,mov,mp3,mpegvideo,ogg,pcm_mulaw,pcm_alaw,pcm_s16be,pcm_s16le,rtp,wav,&#x27; --enable-filter=&#x27;crop,scale,overlay,amix,amerge,aresample,format,aformat,fps,transpose,pad,&#x27; --enable-protocol=&#x27;crypto,file,pipe,rtp,srtp,rtsp,tcp,udp,unix,&#x27; --arch=x86_64 --enable-libopenh264&#xA;  libavutil      56. 51.100 / 56. 51.100&#xA;  libavcodec     58. 91.100 / 58. 91.100&#xA;  libavformat    58. 45.100 / 58. 45.100&#xA;  libavdevice    58. 10.100 / 58. 10.100&#xA;  libavfilter     7. 85.100 /  7. 85.100&#xA;  libswscale      5.  7.100 /  5.  7.100&#xA;  libswresample   3.  7.100 /  3.  7.100&#xA;File formats:&#xA; D. = Demuxing supported&#xA; .E = Muxing supported&#xA; --&#xA; D  aac             raw ADTS AAC (Advanced Audio Coding)&#xA; DE ac3             raw AC-3&#xA; D  alaw            PCM A-law&#xA; D  asf             ASF (Advanced / Active Streaming Format)&#xA; DE ass             SSA (SubStation Alpha) subtitle&#xA; DE flac            raw FLAC&#xA; DE g722            raw G.722&#xA; DE gif             CompuServe Graphics Interchange Format (GIF)&#xA; D  jpeg_pipe       piped jpeg sequence&#xA;  E matroska        Matroska&#xA; D  matroska,webm   Matroska / WebM&#xA; D  mjpeg           raw MJPEG video&#xA; D  mov,mp4,m4a,3gp,3g2,mj2 QuickTime / MOV&#xA; DE mp3             MP3 (MPEG audio layer 3)&#xA; D  mpegts          MPEG-TS (MPEG-2 Transport Stream)&#xA; D  mpegvideo       raw MPEG video&#xA; D  mulaw           PCM mu-law&#xA; DE ogg             Ogg&#xA;  E opus            Ogg Opus&#xA; D  png_pipe        piped png sequence&#xA; D  rm              RealMedia&#xA; DE rtp             RTP output&#xA; DE s16be           PCM signed 16-bit big-endian&#xA; DE s16le           PCM signed 16-bit little-endian&#xA; D  sdp             SDP&#xA; DE wav             WAV / WAVE (Waveform Audio)&#xA;  E webm            WebM&#xA; D  webp_pipe       piped webp sequence&#xA;&#xA;

    &#xA;

    As is evident, there is no support for 'rawvideo' in the list above ! Very strange indeed, I do not know which ffmpeg this list belongs to, perhaps it is a version integrated into matplotlib's animation class ?

    &#xA;

    Anyway, if I uncomment the line setting the ffmpeg_path I am back at the old error. I did get it to work however, by changing the path from '/usr/bin/ffmpeg' to '/home/j/.conda/envs/venvtest/bin/ffmpeg'. Then I get the file to run, create the animation and save it. This works for my real files as well, which do not even run that particular conda-environment. They do not recognize or find the ffmpeg I have in /usr/bin though. I have no clue why but at least I have a workaround now.

    &#xA;

    Final edit :&#xA;It is solved. It was flatpak's fault. Lesson is, don't use flatpak (or snap for that matter) to install Pycharm.

    &#xA;

  • Tv box failed to open encoded videos using x265 HEVC encoder

    3 juin 2022, par Constadinos Chatzis

    I have Zidoo X9S tv box and it has support for x265 HEVC codec. Every single video i throw in it, HDR 4K or standard x264 videos, it plays perfectly except my encoded x265 video when i select it to play, it freezes and it doesn't load. I believe it has something to do with my encoding settings. The encoding command i use with ffmpeg, is this :

    &#xA;

    -c:v libx265 -crf 10 -preset veryfast output.mkv&#xA;

    &#xA;

    Any ideas why this is happening ?

    &#xA;

  • FFmpeg Autogen and Unity C# to generate video from screenshots (FFmpeg.Autogen)

    1er juin 2022, par cameron gibbs

    I've taken the FFmpegHelper, VideoFrameConverter, H264VideoStreamEncoder classes straight from the FFmpeg.AutoGen.Example, rolled my own FFmpegBinariesHelper class and Size struct and mangled the EncodeImagesToH264 from Program.cs to look like the below code. I capture a bunch of frames into textures and feed them into Encoder.EncodeImagesToH264. It produces a file I'm calling outputFileName.h264 just fine, no errors. I've changed H264VideoStreamEncoder a little based on ffmpeg's own c++ examples because they had a few things it seemed the C# example was missing but that hasn't made any difference.

    &#xA;

    The video is weird :

    &#xA;

      &#xA;
    1. it only plays in VLC, is there another AVPixelFormat I should be using for the destinationPixelFormat so that anything can play ?
    2. &#xA;

    3. VLC is unable to detect the video length or show current time
    4. &#xA;

    5. it plays back weird as if the first few seconds are all the same frame then starts playing what appears to be some of the frames I'd expect
    6. &#xA;

    &#xA;

        public static class Encoder&#xA;    {&#xA;        public static unsafe void EncodeImagesToH264(Texture2D[] images, int fps, string outputFileName)&#xA;        {&#xA;            FFmpegBinariesHelper.RegisterFFmpegBinaries();&#xA;&#xA;            var fistFrameImage = images[0];&#xA;            outputFileName = Path.ChangeExtension(outputFileName, ".h264");&#xA;            var sourceSize = new Size(fistFrameImage.width, fistFrameImage.height);&#xA;            var sourcePixelFormat = AVPixelFormat.AV_PIX_FMT_RGB24;&#xA;            var destinationSize = sourceSize;&#xA;            var destinationPixelFormat = AVPixelFormat.AV_PIX_FMT_YUV420P;&#xA;&#xA;            try&#xA;            {&#xA;                using (var vfc = new VideoFrameConverter(&#xA;                    sourceSize,&#xA;                    sourcePixelFormat,&#xA;                    destinationSize,&#xA;                    destinationPixelFormat))&#xA;                {&#xA;                    using var fs = File.Open(outputFileName, FileMode.Create);&#xA;                    using var vse = new H264VideoStreamEncoder(fs, fps, destinationSize);&#xA;                    var frameNumber = 0;&#xA;                    foreach (var frameFile in images)&#xA;                    {&#xA;                        var bitmapData = GetBitmapData(frameFile);&#xA;&#xA;                        //var pBitmapData = (byte*)NativeArrayUnsafeUtility&#xA;                        //    .GetUnsafeBufferPointerWithoutChecks(bitmapData);&#xA;&#xA;                        fixed (byte* pBitmapData = bitmapData)&#xA;                        {&#xA;                            var data = new byte_ptrArray8 { [0] = pBitmapData };&#xA;                            var linesize = new int_array8 { [0] = bitmapData.Length / sourceSize.Height };&#xA;                            var frame = new AVFrame&#xA;                            {&#xA;                                data = data,&#xA;                                linesize = linesize,&#xA;                                height = sourceSize.Height&#xA;                            };&#xA;&#xA;                            var convertedFrame = vfc.Convert(frame);&#xA;                            convertedFrame.pts = frameNumber;&#xA;&#xA;                            vse.Encode(convertedFrame);&#xA;&#xA;                            Debug.Log($"frame: {frameNumber}");&#xA;                            frameNumber&#x2B;&#x2B;;&#xA;                        }&#xA;                    }&#xA;                    byte[] endcode = { 0, 0, 1, 0xb7 };&#xA;                    fs.Write(endcode, 0, endcode.Length);&#xA;                }&#xA;                Debug.Log(outputFileName);&#xA;            }&#xA;            catch (Exception ex)&#xA;            {&#xA;                Debug.LogException(ex);&#xA;            }&#xA;        }&#xA;&#xA;        private static byte[] GetBitmapData(Texture2D frameBitmap)&#xA;        {&#xA;            return frameBitmap.GetRawTextureData();&#xA;        }&#xA;    }&#xA;&#xA;    public sealed unsafe class H264VideoStreamEncoder : IDisposable&#xA;    {&#xA;        private readonly Size _frameSize;&#xA;        private readonly int _linesizeU;&#xA;        private readonly int _linesizeV;&#xA;        private readonly int _linesizeY;&#xA;        private readonly AVCodec* _pCodec;&#xA;        private readonly AVCodecContext* _pCodecContext;&#xA;        private readonly Stream _stream;&#xA;        private readonly int _uSize;&#xA;        private readonly int _ySize;&#xA;&#xA;        public H264VideoStreamEncoder(Stream stream, int fps, Size frameSize)&#xA;        {&#xA;            _stream = stream;&#xA;            _frameSize = frameSize;&#xA;&#xA;            var codecId = AVCodecID.AV_CODEC_ID_H264;&#xA;            _pCodec = ffmpeg.avcodec_find_encoder(codecId);&#xA;            if (_pCodec == null)&#xA;                throw new InvalidOperationException("Codec not found.");&#xA;&#xA;            _pCodecContext = ffmpeg.avcodec_alloc_context3(_pCodec);&#xA;            _pCodecContext->bit_rate = 400000;&#xA;            _pCodecContext->width = frameSize.Width;&#xA;            _pCodecContext->height = frameSize.Height;&#xA;            _pCodecContext->time_base = new AVRational { num = 1, den = fps };&#xA;            _pCodecContext->gop_size = 10;&#xA;            _pCodecContext->max_b_frames = 1;&#xA;            _pCodecContext->pix_fmt = AVPixelFormat.AV_PIX_FMT_YUV420P;&#xA;&#xA;            if (codecId == AVCodecID.AV_CODEC_ID_H264)&#xA;                ffmpeg.av_opt_set(_pCodecContext->priv_data, "preset", "veryslow", 0);&#xA;&#xA;            ffmpeg.avcodec_open2(_pCodecContext, _pCodec, null).ThrowExceptionIfError();&#xA;&#xA;            _linesizeY = frameSize.Width;&#xA;            _linesizeU = frameSize.Width / 2;&#xA;            _linesizeV = frameSize.Width / 2;&#xA;&#xA;            _ySize = _linesizeY * frameSize.Height;&#xA;            _uSize = _linesizeU * frameSize.Height / 2;&#xA;        }&#xA;&#xA;        public void Dispose()&#xA;        {&#xA;            ffmpeg.avcodec_close(_pCodecContext);&#xA;            ffmpeg.av_free(_pCodecContext);&#xA;        }&#xA;&#xA;        public void Encode(AVFrame frame)&#xA;        {&#xA;            if (frame.format != (int)_pCodecContext->pix_fmt)&#xA;                throw new ArgumentException("Invalid pixel format.", nameof(frame));&#xA;            if (frame.width != _frameSize.Width)&#xA;                throw new ArgumentException("Invalid width.", nameof(frame));&#xA;            if (frame.height != _frameSize.Height)&#xA;                throw new ArgumentException("Invalid height.", nameof(frame));&#xA;            if (frame.linesize[0] &lt; _linesizeY)&#xA;                throw new ArgumentException("Invalid Y linesize.", nameof(frame));&#xA;            if (frame.linesize[1] &lt; _linesizeU)&#xA;                throw new ArgumentException("Invalid U linesize.", nameof(frame));&#xA;            if (frame.linesize[2] &lt; _linesizeV)&#xA;                throw new ArgumentException("Invalid V linesize.", nameof(frame));&#xA;            if (frame.data[1] - frame.data[0] &lt; _ySize)&#xA;                throw new ArgumentException("Invalid Y data size.", nameof(frame));&#xA;            if (frame.data[2] - frame.data[1] &lt; _uSize)&#xA;                throw new ArgumentException("Invalid U data size.", nameof(frame));&#xA;&#xA;            var pPacket = ffmpeg.av_packet_alloc();&#xA;            try&#xA;            {&#xA;                int error;&#xA;                do&#xA;                {&#xA;                    ffmpeg.avcodec_send_frame(_pCodecContext, &amp;frame).ThrowExceptionIfError();&#xA;                    ffmpeg.av_packet_unref(pPacket);&#xA;                    error = ffmpeg.avcodec_receive_packet(_pCodecContext, pPacket);&#xA;                } while (error == ffmpeg.AVERROR(ffmpeg.EAGAIN));&#xA;&#xA;                error.ThrowExceptionIfError();&#xA;&#xA;                using var packetStream = new UnmanagedMemoryStream(pPacket->data, pPacket->size);&#xA;                packetStream.CopyTo(_stream);&#xA;            }&#xA;            finally&#xA;            {&#xA;                ffmpeg.av_packet_free(&amp;pPacket);&#xA;            }&#xA;        }&#xA;    }&#xA;

    &#xA;