Recherche avancée

Médias (1)

Mot : - Tags -/punk

Autres articles (106)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (15801)

  • ffmpeg/libavcodec memory management

    23 juillet 2015, par Jason C

    The libavcodec documentation is not very specific about when to free allocated data and how to free it. After reading through documentation and examples, I’ve put together the sample program below. There are some specific questions inlined in the source but my general question is, am I freeing all memory properly in the code below ? I realize the program below doesn’t do any cleanup after errors — the focus is on final cleanup.

    The testfile() function is the one in question.

    extern "C" {
    #include "libavcodec/avcodec.h"
    #include "libavformat/avformat.h"
    #include "libswscale/swscale.h"
    }

    #include <cstdio>

    using namespace std;


    void AVFAIL (int code, const char *what) {
       char msg[500];
       av_strerror(code, msg, sizeof(msg));
       fprintf(stderr, "failed: %s\nerror: %s\n", what, msg);
       exit(2);
    }

    #define AVCHECK(f) do { int e = (f); if (e &lt; 0) AVFAIL(e, #f); } while (0)
    #define AVCHECKPTR(p,f) do { p = (f); if (!p) AVFAIL(AVERROR_UNKNOWN, #f); } while (0)


    void testfile (const char *filename) {

       AVFormatContext *format;
       unsigned streamIndex;
       AVStream *stream = NULL;
       AVCodec *codec;
       SwsContext *sws;
       AVPacket packet;
       AVFrame *rawframe;
       AVFrame *rgbframe;
       unsigned char *rgbdata;

       av_register_all();

       // load file header
       AVCHECK(av_open_input_file(&amp;format, filename, NULL, 0, NULL));
       AVCHECK(av_find_stream_info(format));

       // find video stream
       for (streamIndex = 0; streamIndex &lt; format->nb_streams &amp;&amp; !stream; ++ streamIndex)
           if (format->streams[streamIndex]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
               stream = format->streams[streamIndex];
       if (!stream) {
           fprintf(stderr, "no video stream\n");
           exit(2);
       }

       // initialize codec
       AVCHECKPTR(codec, avcodec_find_decoder(stream->codec->codec_id));
       AVCHECK(avcodec_open(stream->codec, codec));
       int width = stream->codec->width;
       int height = stream->codec->height;

       // initialize frame buffers
       int rgbbytes = avpicture_get_size(PIX_FMT_RGB24, width, height);
       AVCHECKPTR(rawframe, avcodec_alloc_frame());
       AVCHECKPTR(rgbframe, avcodec_alloc_frame());
       AVCHECKPTR(rgbdata, (unsigned char *)av_mallocz(rgbbytes));
       AVCHECK(avpicture_fill((AVPicture *)rgbframe, rgbdata, PIX_FMT_RGB24, width, height));

       // initialize sws (for conversion to rgb24)
       AVCHECKPTR(sws, sws_getContext(width, height, stream->codec->pix_fmt, width, height, PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL));

       // read all frames fromfile
       while (av_read_frame(format, &amp;packet) >= 0) {      

           int frameok = 0;
           if (packet.stream_index == (int)streamIndex)
               AVCHECK(avcodec_decode_video2(stream->codec, rawframe, &amp;frameok, &amp;packet));

           av_free_packet(&amp;packet); // Q: is this necessary or will next av_read_frame take care of it?

           if (frameok) {
               sws_scale(sws, rawframe->data, rawframe->linesize, 0, height, rgbframe->data, rgbframe->linesize);
               // would process rgbframe here
           }

           // Q: is there anything i need to free here?

       }

       // CLEANUP: Q: am i missing anything / doing anything unnecessary?
       av_free(sws); // Q: is av_free all i need here?
       av_free_packet(&amp;packet); // Q: is this necessary (av_read_frame has returned &lt; 0)?
       av_free(rgbframe);
       av_free(rgbdata);
       av_free(rawframe); // Q: i can just do this once at end, instead of in loop above, right?
       avcodec_close(stream->codec); // Q: do i need av_free(codec)?
       av_close_input_file(format); // Q: do i need av_free(format)?

    }


    int main (int argc, char **argv) {

       if (argc != 2) {
           fprintf(stderr, "usage: %s filename\n", argv[0]);
           return 1;
       }

       testfile(argv[1]);

    }
    </cstdio>

    Specific questions :

    1. Is there anything I need to free in the frame processing loop ; or will libav take care of memory management there for me ?
    2. Is av_free the correct way to free an SwsContext ?
    3. The frame loop exits when av_read_frame returns < 0. In that case, do I still need to av_free_packet when it’s done ?
    4. Do I need to call av_free_packet every time through the loop or will av_read_frame free/reuse the old AVPacket automatically ?
    5. I can just av_free the AVFrames at the end of the loop instead of reallocating them each time through, correct ? It seems to be working fine, but I’d like to confirm that it’s working because it’s supposed to, rather than by luck.
    6. Do I need to av_free(codec) the AVCodec or do anything else after avcodec_close on the AVCodecContext ?
    7. Do I need to av_free(format) the AVFormatContext or do anything else after av_close_input_file ?

    I also realize that some of these functions are deprecated in current versions of libav. For reasons that are not relevant here, I have to use them.

  • How to use ffmpeg capture screen (not command) ?

    16 novembre 2022, par Tom

    I am looking for example on the Internet, but none of the relevant examples can be run. Always I compile the no match ffmpeg version. Could someone share a example to learn ?

    &#xA;

  • varying RTP stream result from custom SIP implementation

    1er février, par Nik Hendricks

    I am in the process of creating my own SIP implementation in Node.js. As well as a b2bua as a learning project.

    &#xA;

    Finding people wise in the ways of SIP has proved to be difficult elsewhere but here I have had good results

    &#xA;

    this is the GitHub of my library so far node.js-sip

    &#xA;

    this is the GitHub of my PBX so far FlowPBX

    &#xA;

    Currently, everything is working as I expect. Although I really have some questions on possible errors in my implementation.

    &#xA;

    My main issue is with RTP streams. Currently I am utilizing ffmpeg.

    &#xA;

    my function goes as follows

    &#xA;

    start_stream(call_id, sdp){&#xA;        console.log(&#x27;Starting Stream&#x27;)&#xA;        let port = sdp.match(/m=audio (\d&#x2B;) RTP/)[1];&#xA;        let ip = sdp.match(/c=IN IP4 (\d&#x2B;\.\d&#x2B;\.\d&#x2B;\.\d&#x2B;)/)[1];&#xA;        let codec_ids = sdp.match(/m=audio \d&#x2B; RTP\/AVP (.&#x2B;)/)[1].split(&#x27; &#x27;);&#xA;        let ffmpeg_codec_map = {&#xA;            &#x27;opus&#x27;: &#x27;libopus&#x27;,&#xA;            &#x27;PCMU&#x27;: &#x27;pcm_mulaw&#x27;,&#xA;            &#x27;PCMA&#x27;: &#x27;pcm_alaw&#x27;,&#xA;            &#x27;telephone-event&#x27;: &#x27;pcm_mulaw&#x27;,&#xA;            &#x27;speex&#x27;: &#x27;speex&#x27;,&#xA;            &#x27;G722&#x27;: &#x27;g722&#x27;,&#xA;            &#x27;G729&#x27;: &#x27;g729&#x27;,&#xA;            &#x27;GSM&#x27;: &#x27;gsm&#x27;,&#xA;            &#x27;AMR&#x27;: &#x27;amr&#x27;,&#xA;            &#x27;AMR-WB&#x27;: &#x27;amr_wb&#x27;,&#xA;            &#x27;iLBC&#x27;: &#x27;ilbc&#x27;,&#xA;            &#x27;iSAC&#x27;: &#x27;isac&#x27;,&#xA;        }&#xA;&#xA;        let codecs = [];&#xA;        sdp.split(&#x27;\n&#x27;).forEach(line => {&#xA;            if(line.includes(&#x27;a=rtpmap&#x27;)){&#xA;                let codec = line.match(/a=rtpmap:(\d&#x2B;) (.&#x2B;)/)[2];&#xA;                let c_id = line.match(/a=rtpmap:(\d&#x2B;) (.&#x2B;)/)[1];&#xA;                codecs.push({                    &#xA;                    name: codec.split(&#x27;/&#x27;)[0],&#xA;                    rate: codec.split(&#x27;/&#x27;)[1],&#xA;                    channels: codec.split(&#x27;/&#x27;)[2] !== undefined ? codec.split(&#x27;/&#x27;)[2] : 1,&#xA;                    id: c_id&#xA;                })&#xA;            }&#xA;        })&#xA;&#xA;        console.log(&#x27;codecs&#x27;)&#xA;        console.log(codecs)&#xA;&#xA;        let selected_codec = codecs[0]&#xA;        if(selected_codec.name == &#x27;telephone-event&#x27;){&#xA;            selected_codec = codecs[1]&#xA;            console.log(selected_codec)&#xA;        }&#xA;&#xA;        //see if opus is available&#xA;        codecs.forEach(codec => {&#xA;            if(codec.name == &#x27;opus&#x27;){&#xA;                selected_codec = codec;&#xA;            }&#xA;        })&#xA;&#xA;        if(selected_codec.name != &#x27;opus&#x27;){&#xA;            //check if g729 is available&#xA;            codecs.forEach(codec => {&#xA;                if(codec.name == &#x27;G729&#x27;){&#xA;                    selected_codec = codec;&#xA;                }&#xA;            })&#xA;        }&#xA;&#xA;        console.log(&#x27;selected_codec&#x27;)&#xA;        console.log(selected_codec)&#xA;&#xA;        let spawn = require(&#x27;child_process&#x27;).spawn;&#xA;        let ffmpegArgs = [&#xA;            &#x27;-re&#x27;,&#xA;            &#x27;-i&#x27;, &#x27;song.mp3&#x27;,&#xA;            &#x27;-acodec&#x27;, ffmpeg_codec_map[selected_codec.name],&#xA;            &#x27;-ar&#x27;, selected_codec.rate,&#xA;            &#x27;-ac&#x27;, selected_codec.channels,&#xA;            &#x27;-payload_type&#x27;, selected_codec.id,&#xA;            &#x27;-f&#x27;, &#x27;rtp&#x27;, `rtp://${ip}:${port}`&#xA;        ];&#xA;&#xA;        let ffmpeg = spawn(&#x27;ffmpeg&#x27;, ffmpegArgs);&#xA;&#xA;        ffmpeg.stdout.on(&#x27;data&#x27;, (data) => {&#xA;            console.log(`stdout: ${data}`);&#xA;        });&#xA;        ffmpeg.stderr.on(&#x27;data&#x27;, (data) => {&#xA;            console.error(`stderr: ${data}`);&#xA;        });&#xA;&#xA;&#xA;&#xA;&#xA;}&#xA;

    &#xA;

    When using zoiper to test it works great. I have seen the mobile version negotiate speex&#xA;and the desktop version negotiate opus mostly for the codec.

    &#xA;

    today I tried to register a grandstream phone to my pbx and the rtp stream is blank audio.&#xA;opus is available and I have tried to prefer that in my stream but still even when selecting that I cannot get audio to the grandstream phone. This is the same case for a yealink phone. I can only get zoiper to work so far.

    &#xA;

    what could be causing this behavior ? there is a clear path of communication between everything just like the zoiper client's I have used.

    &#xA;

    Additionally in my sip implementation,&#xA;how important is the concept of a dialog ? currently, I just match messages by Call-ID

    &#xA;

    and then choose what to send based on the method or response. is there any other underlying dialog functionality that I may need to implement ?

    &#xA;

    It would just be awesome to get someone who really knows what they are talking about eyes on some of my code to direct this large codebase in the right direction but I realize that a big ask lol.

    &#xA;