Recherche avancée

Médias (0)

Mot : - Tags -/optimisation

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

Autres articles (70)

  • 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 (...)

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

Sur d’autres sites (5362)

  • FFmpeg encoding aac audio, encoded file can not be played

    9 décembre 2020, par cs guy

    I am trying to encodea aac audio. Example of MP2 here. I followed this documentation. I encode the audio with the code below by calling startEncoding and after 2 seconds I call stopEncoding. Everything seems to work fine I get an file with some size but the problem is I can not open or play it. I dont know why. I must be doing something wrong in the code.

    


    header :

    


    class MediaEncoder {&#xA;public:&#xA;    MediaEncoder(char *filePath);&#xA;&#xA;    void startEncoding();&#xA;    void stopEncoding();&#xA;&#xA;    void encode(AVFrame *frame);&#xA;    bool isEncoding() const;&#xA;&#xA;    void startEncoderWorker();&#xA;&#xA;    int32_t check_sample_fmt(enum AVSampleFormat sample_fmt);&#xA;    &#xA;    bool signalExitFuture = false;&#xA;    int32_t ret;&#xA;&#xA;private:&#xA;    std::future<void> encodingFuture;&#xA;    AVCodecContext *avCodecContext;&#xA;    AVFrame *avFrame;&#xA;    AVPacket *avPacket;&#xA;    AVCodec *codec;&#xA;    FILE* file;&#xA;};&#xA;</void>

    &#xA;

    cpp :

    &#xA;

    MediaEncoder::MediaEncoder(char *filePath){&#xA;    buffer = std::make_unique>(recorderBufferSize);&#xA;&#xA;    /* find the encoder */&#xA;    codec = avcodec_find_encoder(AV_CODEC_ID_AAC);&#xA;    avCodecContext = avcodec_alloc_context3(codec);&#xA;&#xA;    avCodecContext->bit_rate = 64000;&#xA;&#xA;    /* check that the encoder supports given sample format */&#xA;    avCodecContext->sample_fmt = AVSampleFormat::AV_SAMPLE_FMT_FLTP;&#xA;    &#xA;    /* select other audio parameters supported by the encoder */&#xA;    avCodecContext->sample_rate = defaultSampleRate;&#xA;    avCodecContext->channel_layout = AV_CH_LAYOUT_STEREO;&#xA;    avCodecContext->channels = av_get_channel_layout_nb_channels(avCodecContext->channel_layout);&#xA;&#xA;    /* open it */&#xA;    avcodec_open2(avCodecContext, codec, nullptr)&#xA;    &#xA;    file = fopen(filePath, "wb");&#xA;    &#xA;    /* packet for holding encoded output */&#xA;    avPacket = av_packet_alloc();&#xA;    &#xA;    /* frame containing input raw audio */&#xA;    avFrame = av_frame_alloc();&#xA;    &#xA;    avFrame->nb_samples = avCodecContext->frame_size;&#xA;    avFrame->format = avCodecContext->sample_fmt;&#xA;    avFrame->channel_layout = avCodecContext->channel_layout;&#xA;&#xA;    /* allocate the data buffers */&#xA;    av_frame_get_buffer(avFrame, 0);&#xA;}&#xA;&#xA;&#xA;void MediaEncoder::startEncoding() {&#xA;    // set flags for decoding thread&#xA;    signalExitFuture = false;&#xA;&#xA;    encodingFuture = std::async(std::launch::async, &amp;MediaEncoder::startEncoderWorker, this);&#xA;}&#xA;&#xA;void MediaEncoder::stopEncoding() {&#xA;    signalExitFuture = true;&#xA;}&#xA;&#xA;bool MediaEncoder::isEncoding() const {&#xA;    return !signalExitFuture;&#xA;}&#xA;&#xA;void MediaEncoder::encode(AVFrame *frame) {&#xA;    /* send the frame for encoding */&#xA;    ret = avcodec_send_frame(avCodecContext, frame);&#xA;    if (ret &lt; 0) {&#xA;        LOGE("Error sending the frame to the encoder %s",&#xA;             av_err2str(ret));&#xA;        *recorderStatePointer = MediaEncoderState::RUNTIME_FAIL;&#xA;        return;&#xA;    }&#xA;&#xA;    /* read all the available output packets (in general there may be any&#xA;     * number of them */&#xA;    while (ret >= 0) {&#xA;        ret = avcodec_receive_packet(avCodecContext, avPacket);&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;            return;&#xA;        } else if (ret &lt; 0) {&#xA;            LOGE("Error encoding audio frame %s",&#xA;                 av_err2str(ret));&#xA;            *recorderStatePointer = MediaEncoderState::RUNTIME_FAIL;&#xA;            return;&#xA;        }&#xA;       &#xA;        /* Solution begins here&#xA;        int aac_profile = 2;           // AAC LC&#xA;        int frequencey_index = 4;      // 44,100Hz&#xA;        int channel_configuration = 2; // stereo (left, right)&#xA;&#xA;        int frame_length = avPacket->size &#x2B; 7;              // your frame length&#xA;     &#xA;        unsigned char adts_header[7];&#xA;&#xA;        // fill in ADTS data&#xA;        adts_header[0] = (unsigned char) 0xFF;&#xA;        adts_header[1] = (unsigned char) 0xF9;&#xA;        adts_header[2] = (unsigned char) (((aac_profile -1) &lt;&lt; 6 ) &#x2B; (frequencey_index &lt;&lt; 2) &#x2B; (channel_configuration >> 2));&#xA;        adts_header[3] = (unsigned char) (((channel_configuration &amp; 3) &lt;&lt; 6) &#x2B; (frame_length >> 11));&#xA;        adts_header[4] = (unsigned char) ((frame_length &amp; 0x7FF) >> 3);&#xA;        adts_header[5] = (unsigned char) (((frame_length &amp; 7) &lt;&lt; 5) &#x2B; 0x1F);&#xA;        adts_header[6] = (unsigned char) 0xFC;&#xA;&#xA;        fwrite(adts_header, 1, 7, file); &#xA;        Solution ends here */ &#xA;        fwrite(avPacket->data, 1, avPacket->size, file);&#xA;        av_packet_unref(avPacket);&#xA;    }&#xA;}&#xA;&#xA;void MediaEncoder::startEncoderWorker() {&#xA;    try {&#xA;        float *leftChannel;&#xA;        float *rightChannel;&#xA;        float val;&#xA;&#xA;        while (!signalExitFuture) {&#xA;            ret = av_frame_make_writable(avFrame);&#xA;            if (ret &lt; 0) {&#xA;                LOGE("av_frame_make_writable Can not Ensure that the frame data is writable. %s",&#xA;                     av_err2str(ret));&#xA;                *recorderStatePointer = MediaEncoderState::RUNTIME_FAIL;&#xA;                return;&#xA;            }&#xA;&#xA;            leftChannel = (float *) avFrame->data[0];&#xA;            rightChannel = (float *) avFrame->data[1];&#xA;&#xA;            for (int32_t i = 0; i &lt; avCodecContext->frame_size; &#x2B;&#x2B;i) {&#xA;               &#xA;                leftChannel[i] = 0.4;&#xA;                rightChannel[i] = 0.4;&#xA;            }&#xA;&#xA;            encode(avFrame);&#xA;        }&#xA;&#xA;        /* flush the encoder */&#xA;        encode(nullptr);&#xA;&#xA;        fclose(file);&#xA;        LOGE("Encoding finished!");&#xA;&#xA;        av_frame_free(&amp;avFrame);&#xA;        av_packet_free(&amp;avPacket);&#xA;        avcodec_free_context(&amp;avCodecContext);&#xA;    } catch (std::exception &amp;e) {&#xA;        LOGE("startEncoderWorker uncaught exception %s", e.what());&#xA;    }&#xA;&#xA;    LOGE("Deleting Media Encoder!");&#xA;&#xA;}&#xA;

    &#xA;

    Here is an recorded 11 seconds of an aac file recorded with real float pcm data rather than 0.4 as it is in the code I posted. Google Drive Link

    &#xA;

    The code above works. Thanks to the legend @Markus-Schumann

    &#xA;

  • Revision 30148 : On pousse encore un peu plus loin la conf (toujours pas utilisable dans ...

    24 juillet 2009, par kent1@… — Log

    On pousse encore un peu plus loin la conf (toujours pas utilisable dans l’état)

  • Revision 30775 : Installation et désinstallation plus propre

    10 août 2009, par kent1@… — Log

    Installation et désinstallation plus propre