Recherche avancée

Médias (0)

Mot : - Tags -/performance

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

Autres articles (82)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (10448)

  • Revision 36317 : Il y a certains cas où l’on ne peut pas passer par revision_mot notamment ...

    16 mars 2010, par kent1@… — Log

    Il y a certains cas où l’on ne peut pas passer par revision_mot notamment si on s’insère dans un formulaire d’édition d’article dans un pipeline pre_edition ... On ne passe pas la gestion des conflits dans ce cas là

  • How to stream video from Node.js

    7 mai 2014, par Sunrising

    i am trying to request a video stored on server and receive a stream of data to show in a html tag

    From the client i request the streaming of a particular file i know exists in my server

    Then in node i use this :

    function streamvideo(response, request) {

    // here i simply read from the response the path and the name of the file i want
    var queryparts = url.parse(request.url, true).query;
    var path = queryparts.query;

    var path = 'tmp/' + path
       , stat = fs.statSync(path)
       , total = stat.size;

    var origin = (request.headers.origin || "*");

    // still not sure it is correct to manage range this way but it works
    // if i request a range....
    if (request.headers['range']) {
       var range = request.headers.range
           , parts = range.replace(/bytes=/, "").split("-")
           , partialstart = parts[0]
           , partialend = parts[1]
           , start = parseInt(partialstart, 10)
           , end = partialend ? parseInt(partialend, 10) : total - 1
           , chunksize = (end - start) + 1;

       console.log('RANGE: ' + start + ' - ' + end + ' = ' + chunksize + "\n")

       response.writeHead(
           206
           , {
               'Access-Control-Allow-Credentials': true,
               'Access-Control-Allow-Origin': origin,
               'Content-Range': 'bytes ' + start + '-' + end + '/' + total,
               'Accept-Ranges': 'bytes',
               'Content-Length': chunksize,
               'Content-Type': 'video/mp4'
           });

    } else {
    // if i request all the video
       console.log('ALL: ' + total);

       response.writeHead(
           200,
           {
               'Access-Control-Allow-Credentials': true,
               'Access-Control-Allow-Origin': origin,
               'Content-Length': total,
               'Content-Type': 'video/mp4'
           }
       );
    }

    // on-the-fly encoding
    var ffmpeg = child_process.spawn("ffmpeg",[
       "-i", path,             // path
       "-b:v" , "64k",         // bitrate to 64k
       "-bufsize", "64k",
       "pipe:1"               // Output to STDOUT
    ]);

    //pack-up everything and send back the response with the stream
    var file = fs.createReadStream(path);
    file.pipe(response);

    it may be not the best code ever but it works because i receive on the client a stream of something !
    BUT how can i verify this ? how can i actually ’see’ the video in the page ?

    now in the client page i have a tag like this :

    <div>
       <video class="mejs-wmp" width="320" height="240" src="test.mp4" type="video/mp4" controls="controls" preload="none"></video>
    </div>

    but i can only see a black screen in my player...

    Why ?

    Thanks !

    (feel free to correct any imprecision you see)

  • Wrap audio data of the pcm_alaw type into an MKA audio file using the ffmpeg API

    19 septembre 2020, par bbdd

    Imagine that in my project, I receive RTP packets with the payload type-8, for later saving this load as the Nth part of the audio track. I extract this load from the RTP packet and save it to a temporary buffer :

    &#xA;

    ...&#xA;&#xA;while ((rtp = receiveRtpPackets()).withoutErrors()) {&#xA;   payloadData.push(rtp.getPayloadData());&#xA;}&#xA;&#xA;audioGenerator.setPayloadData(payloadData);&#xA;audioGenerator.recordToFile();&#xA;&#xA;...&#xA;

    &#xA;

    After filling a temporary buffer of a certain size with this payload, I process this buffer, namely, extract the entire payload and encode it using ffmpeg for further saving to an audio file in Matroska format. But I have a problem. Since the payload of the RTP packet is type 8, I have to save the raw audio data of the pcm_alaw format to mka audio format. But when saving raw data pcm_alaw to an audio file, I get these messages from the library :

    &#xA;

    ...&#xA;&#xA;[libopus @ 0x18eff60] Queue input is backward in time&#xA;[libopus @ 0x18eff60] Queue input is backward in time&#xA;[libopus @ 0x18eff60] Queue input is backward in time&#xA;[libopus @ 0x18eff60] Queue input is backward in time&#xA;&#xA;...&#xA;

    &#xA;

    When you open an audio file in vlc, nothing is played (the audio track timestamp is missing).

    &#xA;

    The task of my project is to simply take pcm_alaw data and pack it in a container, in mka format. The best way to determine the codec is to use the av_guess_codec() function, which in turn automatically selects the desired codec ID. But how do I pack the raw data into the container correctly, I do not know.

    &#xA;

    It is important to note that I can get as raw data any format of this data (audio formats only) defined by the RTP packet type (All types of RTP packet payload). All I know is that in any case, I have to pack the audio data in an mka container.

    &#xA;

    I also attach the code (borrowed from this resource) that I use :

    &#xA;

    audiogenerater.h

    &#xA;

    extern "C"&#xA;{&#xA;#include "libavformat/avformat.h"&#xA;#include "libavcodec/avcodec.h"&#xA;#include "libswresample/swresample.h"&#xA;}&#xA;&#xA;class AudioGenerater&#xA;{&#xA;public:&#xA;&#xA;    AudioGenerater();&#xA;   ~AudioGenerater() = default;&#xA;&#xA;    void generateAudioFileWithOptions(&#xA;            QString        fileName,&#xA;            QByteArray     pcmData,&#xA;            int            channel,&#xA;            int            bitRate,&#xA;            int            sampleRate,&#xA;            AVSampleFormat format);&#xA;            &#xA;private:&#xA;&#xA;    // init Format&#xA;    bool initFormat(QString audioFileName);&#xA;&#xA;private:&#xA;&#xA;    AVCodec         *m_AudioCodec        = nullptr;&#xA;    AVCodecContext  *m_AudioCodecContext = nullptr;&#xA;    AVFormatContext *m_FormatContext     = nullptr;&#xA;    AVOutputFormat  *m_OutputFormat      = nullptr;&#xA;};&#xA;

    &#xA;

    audiogenerater.cpp

    &#xA;

    AudioGenerater::AudioGenerater()&#xA;{&#xA;    av_register_all();&#xA;    avcodec_register_all();&#xA;}&#xA;&#xA;AudioGenerater::~AudioGenerater()&#xA;{&#xA;    // ... &#xA;}&#xA;&#xA;bool AudioGenerater::initFormat(QString audioFileName)&#xA;{&#xA;    // Create an output Format context&#xA;    int result = avformat_alloc_output_context2(&amp;m_FormatContext, nullptr, nullptr, audioFileName.toLocal8Bit().data());&#xA;    if (result &lt; 0) {&#xA;        return false;&#xA;    }&#xA;&#xA;    m_OutputFormat = m_FormatContext->oformat;&#xA;&#xA;    // Create an audio stream&#xA;    AVStream* audioStream = avformat_new_stream(m_FormatContext, m_AudioCodec);&#xA;    if (audioStream == nullptr) {&#xA;        avformat_free_context(m_FormatContext);&#xA;        return false;&#xA;    }&#xA;&#xA;    // Set the parameters in the stream&#xA;    audioStream->id = m_FormatContext->nb_streams - 1;&#xA;    audioStream->time_base = { 1, 8000 };&#xA;    result = avcodec_parameters_from_context(audioStream->codecpar, m_AudioCodecContext);&#xA;    if (result &lt; 0) {&#xA;        avformat_free_context(m_FormatContext);&#xA;        return false;&#xA;    }&#xA;&#xA;    // Print FormatContext information&#xA;    av_dump_format(m_FormatContext, 0, audioFileName.toLocal8Bit().data(), 1);&#xA;&#xA;    // Open file IO&#xA;    if (!(m_OutputFormat->flags &amp; AVFMT_NOFILE)) {&#xA;        result = avio_open(&amp;m_FormatContext->pb, audioFileName.toLocal8Bit().data(), AVIO_FLAG_WRITE);&#xA;        if (result &lt; 0) {&#xA;            avformat_free_context(m_FormatContext);&#xA;            return false;&#xA;        }&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;void AudioGenerater::generateAudioFileWithOptions(&#xA;    QString _fileName,&#xA;    QByteArray _pcmData,&#xA;    int _channel,&#xA;    int _bitRate,&#xA;    int _sampleRate,&#xA;    AVSampleFormat _format)&#xA;{&#xA;    AVFormatContext* oc;&#xA;    if (avformat_alloc_output_context2(&#xA;            &amp;oc, nullptr, nullptr, _fileName.toStdString().c_str())&#xA;        &lt; 0) {&#xA;        qDebug() &lt;&lt; "Error in line: " &lt;&lt; __LINE__;&#xA;        return;&#xA;    }&#xA;    if (!oc) {&#xA;        printf("Could not deduce output format from file extension: using mka.\n");&#xA;        avformat_alloc_output_context2(&#xA;            &amp;oc, nullptr, "mka", _fileName.toStdString().c_str());&#xA;    }&#xA;    if (!oc) {&#xA;        qDebug() &lt;&lt; "Error in line: " &lt;&lt; __LINE__;&#xA;        return;&#xA;    }&#xA;    AVOutputFormat* fmt = oc->oformat;&#xA;    if (fmt->audio_codec == AV_CODEC_ID_NONE) {&#xA;        qDebug() &lt;&lt; "Error in line: " &lt;&lt; __LINE__;&#xA;        return;&#xA;    }&#xA;&#xA;    AVCodecID codecID = av_guess_codec(&#xA;        fmt, nullptr, _fileName.toStdString().c_str(), nullptr, AVMEDIA_TYPE_AUDIO);&#xA;    // Find Codec&#xA;    m_AudioCodec = avcodec_find_encoder(codecID);&#xA;    if (m_AudioCodec == nullptr) {&#xA;        qDebug() &lt;&lt; "Error in line: " &lt;&lt; __LINE__;&#xA;        return;&#xA;    }&#xA;    // Create an encoder context&#xA;    m_AudioCodecContext = avcodec_alloc_context3(m_AudioCodec);&#xA;    if (m_AudioCodecContext == nullptr) {&#xA;        qDebug() &lt;&lt; "Error in line: " &lt;&lt; __LINE__;&#xA;        return;&#xA;    }&#xA;&#xA;    // Setting parameters&#xA;    m_AudioCodecContext->bit_rate = _bitRate;&#xA;    m_AudioCodecContext->sample_rate = _sampleRate;&#xA;    m_AudioCodecContext->sample_fmt = _format;&#xA;    m_AudioCodecContext->channels = _channel;&#xA;&#xA;    m_AudioCodecContext->channel_layout = av_get_default_channel_layout(_channel);&#xA;    m_AudioCodecContext->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;    // Turn on the encoder&#xA;    int result = avcodec_open2(m_AudioCodecContext, m_AudioCodec, nullptr);&#xA;    if (result &lt; 0) {&#xA;        avcodec_free_context(&amp;m_AudioCodecContext);&#xA;        if (m_FormatContext != nullptr)&#xA;            avformat_free_context(m_FormatContext);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create a package&#xA;    if (!initFormat(_fileName)) {&#xA;        avcodec_free_context(&amp;m_AudioCodecContext);&#xA;        if (m_FormatContext != nullptr)&#xA;            avformat_free_context(m_FormatContext);&#xA;        return;&#xA;    }&#xA;&#xA;    // write to the file header&#xA;    result = avformat_write_header(m_FormatContext, nullptr);&#xA;    if (result &lt; 0) {&#xA;        avcodec_free_context(&amp;m_AudioCodecContext);&#xA;        if (m_FormatContext != nullptr)&#xA;            avformat_free_context(m_FormatContext);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create Frame&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    if (frame == nullptr) {&#xA;        avcodec_free_context(&amp;m_AudioCodecContext);&#xA;        if (m_FormatContext != nullptr)&#xA;            avformat_free_context(m_FormatContext);&#xA;        return;&#xA;    }&#xA;&#xA;    int nb_samples = 0;&#xA;    if (m_AudioCodecContext->codec->capabilities &amp; AV_CODEC_CAP_VARIABLE_FRAME_SIZE) {&#xA;        nb_samples = 10000;&#xA;    }&#xA;    else {&#xA;        nb_samples = m_AudioCodecContext->frame_size;&#xA;    }&#xA;&#xA;    // Set the parameters of the Frame&#xA;    frame->nb_samples = nb_samples;&#xA;    frame->format = m_AudioCodecContext->sample_fmt;&#xA;    frame->channel_layout = m_AudioCodecContext->channel_layout;&#xA;&#xA;    // Apply for data memory&#xA;    result = av_frame_get_buffer(frame, 0);&#xA;    if (result &lt; 0) {&#xA;        av_frame_free(&amp;frame);&#xA;        {&#xA;            avcodec_free_context(&amp;m_AudioCodecContext);&#xA;            if (m_FormatContext != nullptr)&#xA;                avformat_free_context(m_FormatContext);&#xA;            return;&#xA;        }&#xA;    }&#xA;&#xA;    // Set the Frame to be writable&#xA;    result = av_frame_make_writable(frame);&#xA;    if (result &lt; 0) {&#xA;        av_frame_free(&amp;frame);&#xA;        {&#xA;            avcodec_free_context(&amp;m_AudioCodecContext);&#xA;            if (m_FormatContext != nullptr)&#xA;                avformat_free_context(m_FormatContext);&#xA;            return;&#xA;        }&#xA;    }&#xA;&#xA;    int perFrameDataSize = frame->linesize[0];&#xA;    int count = _pcmData.size() / perFrameDataSize;&#xA;    bool needAddOne = false;&#xA;    if (_pcmData.size() % perFrameDataSize != 0) {&#xA;        count&#x2B;&#x2B;;&#xA;        needAddOne = true;&#xA;    }&#xA;&#xA;    int frameCount = 0;&#xA;    for (int i = 0; i &lt; count; &#x2B;&#x2B;i) {&#xA;        // Create a Packet&#xA;        AVPacket* pkt = av_packet_alloc();&#xA;        if (pkt == nullptr) {&#xA;            avcodec_free_context(&amp;m_AudioCodecContext);&#xA;            if (m_FormatContext != nullptr)&#xA;                avformat_free_context(m_FormatContext);&#xA;            return;&#xA;        }&#xA;        av_init_packet(pkt);&#xA;&#xA;        if (i == count - 1)&#xA;            perFrameDataSize = _pcmData.size() % perFrameDataSize;&#xA;&#xA;        // Synthesize WAV files&#xA;        memset(frame->data[0], 0, perFrameDataSize);&#xA;        memcpy(frame->data[0], &amp;(_pcmData.data()[perFrameDataSize * i]), perFrameDataSize);&#xA;&#xA;        frame->pts = frameCount&#x2B;&#x2B;;&#xA;        // send Frame&#xA;        result = avcodec_send_frame(m_AudioCodecContext, frame);&#xA;        if (result &lt; 0)&#xA;            continue;&#xA;&#xA;        // Receive the encoded Packet&#xA;        result = avcodec_receive_packet(m_AudioCodecContext, pkt);&#xA;        if (result &lt; 0) {&#xA;            av_packet_free(&amp;pkt);&#xA;            continue;&#xA;        }&#xA;&#xA;        // write to file&#xA;        av_packet_rescale_ts(pkt, m_AudioCodecContext->time_base, m_FormatContext->streams[0]->time_base);&#xA;        pkt->stream_index = 0;&#xA;        result = av_interleaved_write_frame(m_FormatContext, pkt);&#xA;        if (result &lt; 0)&#xA;            continue;&#xA;&#xA;        av_packet_free(&amp;pkt);&#xA;    }&#xA;&#xA;    // write to the end of the file&#xA;    av_write_trailer(m_FormatContext);&#xA;    // Close file IO&#xA;    avio_closep(&amp;m_FormatContext->pb);&#xA;    // Release Frame memory&#xA;    av_frame_free(&amp;frame);&#xA;&#xA;    avcodec_free_context(&amp;m_AudioCodecContext);&#xA;    if (m_FormatContext != nullptr)&#xA;        avformat_free_context(m_FormatContext);&#xA;}&#xA;

    &#xA;

    main.cpp

    &#xA;

    int main(int argc, char **argv)&#xA;{&#xA;    av_log_set_level(AV_LOG_TRACE);&#xA;&#xA;    QFile file("rawDataOfPcmAlawType.bin");&#xA;    if (!file.open(QIODevice::ReadOnly)) {&#xA;        return EXIT_FAILURE;&#xA;    }&#xA;    QByteArray rawData(file.readAll());&#xA;&#xA;    AudioGenerater generator;&#xA;    generator.generateAudioFileWithOptions(&#xA;               "test.mka",&#xA;               rawData,&#xA;               1, &#xA;               64000, &#xA;               8000,&#xA;               AV_SAMPLE_FMT_S16);&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    It is IMPORTANT you help me find the most appropriate way to record pcm_alaw or a different data format in an MKA audio file.

    &#xA;

    I ask everyone who knows anything to help (there is too little time left to implement this project)

    &#xA;