Recherche avancée

Médias (16)

Mot : - Tags -/mp3

Autres articles (33)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

Sur d’autres sites (6261)

  • Memory leak using FFmpeg

    3 août 2020, par kichma

    I found out that my application has a memory leak coming from a C++ function. It seems this function is called for each frame and it leak is proportional to the size of a frame. It's called from a python code but the leak is somewhere in the C++ code.
    
I don't have much experience with ffmpeg or C++ and I'm not author of this code. Does anyone see what is causing leak here or can provide some advice how to debug this ? I tried to use the code (windows part) from this answer https://stackoverflow.com/a/64166/10046424 to find which part of the code uses memory but I always got 0.

    


     static py::object video_encode_frame(py::object self)   
{

    video_encode_helper *vec = py::cppobject < video_encode_helper > (self.attr("_encoder_state")).value();

    int image_id = 0;
    RTIConfig rti;
    ViewerBase *bs = base(self);
    Py_BEGIN_ALLOW_THREADS;
    renderToExistingImage(&rti, vec->img_key, image_id, bs, vec->c->width, vec->c->height);
    Py_END_ALLOW_THREADS;

    static int i = 0;
    float dummy;
    int h, w;
    char buf[MVO_BUFFER_SIZE];

    HC_Show_Image(vec->img_key, &dummy, &dummy, &dummy, buf, &w, &h, vec->data);
    struct SwsContext *sws_ctx = sws_getContext(vec->c->width, vec->c->height, PIX_FMT_RGB24,
                                                vec->c->width, vec->c->height, (PixelFormat) vec->picture->format,  
                                                SWS_FAST_BILINEAR, NULL, NULL, NULL);

    int src_linesize[] = { vec->c->width * 3, 0, 0, 0 };
    const uint8_t *src_data[] = { (const uint8_t *) vec->data, 0, 0, 0 };
    sws_scale(sws_ctx, (const uint8_t * const *) src_data, src_linesize, 0, vec->c->height, vec->picture->data,
              vec->picture->linesize);
    sws_freeContext(sws_ctx);

    int repeat = vec->FPS / vec->TPS;
    if (repeat == 0)
        repeat = 1;


    int ret = -1;

    AVPacket pkt = { 0 };
    int got_packet;
    av_init_packet(&pkt);

    /* encode the image */
    ret = avcodec_encode_video2(vec->c, &pkt, vec->picture, &got_packet);
    if (ret < 0) 
        return py::bool_(false);

    for (int r = 0; r < repeat; r++) {
        /* If size is zero, it means the image was buffered. */
        if (!ret && got_packet && pkt.size) {
            pkt.stream_index = vec->video_st->index;

            /* Write the compressed frame to the media file. */
            ret = av_interleaved_write_frame(vec->oc, &pkt);

        } else
            ret = 0;

        vec->picture->pts += av_rescale_q(1, vec->video_st->codec->time_base, vec->video_st->time_base);
        vec->frame_count++;
        }
    return py::bool_(true);
}


    


    There is also a cleanup function that is called at the end. Perhaps something should be deallocated there ?

    


    static py::object video_encode_finalize(py::object self)
{
    if (self.attr("_encoder_state") == py::none())
        return py::bool_(false);

    video_encode_helper *vec = py::cppobject < video_encode_helper > (self.attr("_encoder_state")).value();

    /* Write the trailer, if any. The trailer must be written before you
     * close the CodecContexts open when you wrote the header; otherwise
     * av_write_trailer() may try to use memory that was freed on
     * av_codec_close(). */
    av_write_trailer(vec->oc);
    /* Close each codec. */

    avcodec_close(vec->video_st->codec);
    av_freep(&(vec->picture->data[0]));
    av_free(vec->picture);

    if (!(vec->fmt->flags & AVFMT_NOFILE))
        /* Close the output file. */
        avio_close(vec->oc->pb);

    /* free the stream */
    avformat_free_context(vec->oc);

    vec->initialized = false;
    vec->frame_count = 0;

    return py::bool_(true);
}


    


  • FFmpeg with MacOS-recorded WEBM : itsoffset argument for audio synchronization

    12 juillet 2020, par Igniter

    Getting quite a weird error while trying to synchronize audio using a simple command :

    


    ffmpeg -i in.webm -itsoffset 1.5 -i in.webm -map 0:v -map 1:a -c copy out.webm


    


    I know that the video was recorded by webcam (MediaRecorder API) in Chrome on MacOS Catalina.

    


    ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers                                                           
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)                                                                                                   
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --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 --enab
le-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfrib
idi --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 --ena
ble-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                                                                                                      
Input #0, matroska,webm, from 'in.webm':                                                                                                 
  Metadata:                                                                                                                                   
    encoder         : Chrome                                                                                                                  
  Duration: N/A, start: 0.000000, bitrate: N/A                                                                                                
    Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)                                                                             
    Stream #0:1(eng): Video: h264 (Baseline), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 2k tbc (default)     
Input #1, matroska,webm, from 'in.webm':                                                                                                 
  Metadata:                                                                                                                                   
    encoder         : Chrome                                                                                                                  
  Duration: N/A, start: 0.000000, bitrate: N/A                                                                                                
    Stream #1:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)                                                                             
    Stream #1:1(eng): Video: h264 (Baseline), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 2k tbc (default)     
Output #0, webm, to 'in.webm':                                                                                                    
  Metadata:                                                                                                                                   
    encoder         : Lavf57.83.100                                                                                                           
    Stream #0:0(eng): Video: h264 (Baseline), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 tbr, 1k tbn, 1k tbc (defau
lt)                                                                                                                                           
    Stream #0:1(eng): Audio: opus, 48000 Hz, mono, fltp (default)                                                                             
Stream mapping:                                                                                                                               
  Stream #0:1 -> #0:0 (copy)                                                                                                                  
  Stream #0:0 -> #0:1 (copy)                                                                                                                  
Press [q] to stop, [?] for help                                                                                                               
[webm @ 0x7fffbcce15e0] Only VP8 or VP9 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.                           
av_interleaved_write_frame(): Invalid argument                                                                                                
Error writing trailer of out.webm: Invalid argument                                                                                
frame=    1 fps=0.0 q=-1.0 Lsize=       0kB time=00:00:00.50 bitrate=   5.7kbits/s speed= 728x                                                
video:27kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown                                               
Conversion failed!                                                                                                                            


    


    I get the same error for ffmpeg v. 4.2.3 (gcc 9.3.1) as well. Original file is not corrupted, just 1 sec audio desync.
    
When trying to convert it to MP4, I get lots of warnings and the output file without the audio track.

    


    Where do I start to deal with such cases ?

    


  • Programmatically terminate ffmpeg child process on Raspberry Pi

    16 août 2020, par McGuireV10

    Is it possible to cleanly terminate ffmpeg when it's running as a child process under Linux (specifically on a Raspberry Pi 4B) ? I have a .NET Core 3.1 application which spawns ffmepg with the following command, which should encode an h.264 stream to an MP4 file :

    


    ffmpeg -framerate 24 -i - -b:v 2500k -c copy video.mp4


    


    After some arbitrary period of time I want to terminate ffmpeg, but everything I try is either ignored or causes ffmpeg to exit immediately — it never writes the MOOV chunk to the end of the MP4 file, which results in a corrupted file that cannot be played. I realize this chunk can take awhile to generate, and I've tried leaving the process alone for up to 60 seconds, which is far longer than h.264 to MP4 encoding requires interactively on the same device. For the record, I know how to create a "fragmented" MP4 which is mostly playable (using the -movflags switch and others), but I'm trying to generate a correct MP4.

    


    I've tried sending a Q key with or without various CR+LF combos, which I've seen mentioned in similar questions, but I think that's a Windows-only thing.

    


    I've tried every Unix signal as well as combinations of two signals. I saw somewhere (I think the ffmpeg site itself) that SIGINT should be sent twice, but that does nothing. In another SO post, somebody suggested sending SIGQUIT which also does nothing. Interestingly, sending SIGINT followed by SIGQUIT is the only combination that actually terminates the process, but it ends immediately with the following output :

    


    Error writing trailer of /media/ramdisk/video.mp4: Immediate exit requested
frame=  236 fps= 29 q=-1.0 Lsize=   28928kB time=00:00:09.79 bitrate=24201.9kbits/s speed= 1.2x
video:29167kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.


    


    I've tried a long delay between the two, nothing happens until the SIGQUIT at which point it responds as shown above. Oddly, sometimes it says received signal 3 instead of 2.

    


    There has to be some trick I'm missing.