Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

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

Autres articles (91)

  • À propos des documents

    21 juin 2013, par

    Que faire quand un document ne passe pas en traitement, dont le rendu ne correspond pas aux attentes ?
    Document bloqué en file d’attente ?
    Voici une liste d’actions ordonnée et empirique possible pour tenter de débloquer la situation : Relancer le traitement du document qui ne passe pas Retenter l’insertion du document sur le site MédiaSPIP Dans le cas d’un média de type video ou audio, retravailler le média produit à l’aide d’un éditeur ou un transcodeur. Convertir le document dans un format (...)

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

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

  • fate : test only demuxing in asf-repldata

    20 août 2015, par Janne Grunau
    fate : test only demuxing in asf-repldata
    
    • [DBH] tests/fate/microsoft.mak
    • [DBH] tests/ref/fate/asf-repldata
  • fate : Add test for mss1 codec

    18 avril 2016, par Petru Rares Sincraian
    fate : Add test for mss1 codec
    

    Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>

    • [DH] tests/fate/microsoft.mak
    • [DH] tests/ref/fate/mss1-pal
  • FFmpeg Opus choppy sound UPDATED DESCRIPTION

    2 juin 2020, par easy_breezy

    I'm using FFmpeg and try to encode and decode a raw PCM sound to Opus using a built-in FFmpeg "opus" codec. My input samples are raw PCM 8000 Hz 16 bit mono, in AV_SAMPLE_FMT_S16 format. Since Opus requires sample format AV_SAMPLE_FMT_FLTP and sample rate 48000 Hz only, so I resample my samples before encode them.

    &#xA;&#xA;

    I have two instances of ResamplerAudio class that does the work of resampling audio samples and has a member of SwrContext, I use the first instance of ResamplerAudio for resampling a raw PCM input audio before encoding and the second for resampling decoded audio to get it's format and sample rate the same as source values of input raw audio.

    &#xA;&#xA;

    ResamplerAudio class has a function that init it's SwrContext member like this :

    &#xA;&#xA;

    void ResamplerAudio::init(AVCodecContext *codecContext, int inSampleRate, int outSampleRate, AVSampleFormat inSampleFmt, AVSampleFormat outSampleFmt)&#xA;{&#xA;    swrContext = swr_alloc();&#xA;    if (!swrContext)&#xA;    {&#xA;        LOGE(TAG, "[init] Couldn&#x27;t allocate swr context");&#xA;        return;&#xA;    }&#xA;&#xA;    av_opt_set_int(swrContext, "in_channel_layout", (int64_t) codecContext->channel_layout, 0);&#xA;    av_opt_set_int(swrContext, "out_channel_layout", (int64_t) codecContext->channel_layout,  0);&#xA;&#xA;    av_opt_set_int(swrContext, "in_channel_count", codecContext->channels, 0);&#xA;    av_opt_set_int(swrContext, "out_channel_count", codecContext->channels, 0);&#xA;&#xA;    av_opt_set_int(swrContext, "in_sample_rate", inSampleRate, 0);&#xA;    av_opt_set_int(swrContext, "out_sample_rate", outSampleRate, 0);&#xA;&#xA;    av_opt_set_sample_fmt(swrContext, "in_sample_fmt", inSampleFmt, 0);&#xA;    av_opt_set_sample_fmt(swrContext, "out_sample_fmt", outSampleFmt,  0);&#xA;&#xA;    int ret = swr_init(swrContext);&#xA;    if (ret &lt; 0)&#xA;    {&#xA;        LOGE(TAG, "[init] swr_init error: %s", av_err2str(ret));&#xA;        return;&#xA;    }&#xA;&#xA;    LOGD(TAG, "[init] success codecContext->channel_layout: %d; inSampleRate: %d; outSampleRate: %d; inSampleFmt: %d; outSampleFmt: %d", (int) codecContext->channel_layout, inSampleRate, outSampleRate, inSampleFmt, outSampleFmt);&#xA;}&#xA;

    &#xA;&#xA;

    And I call ResamplerAudio::init function for the first instance of ResamplerAudio (this instance do resamping a raw PCM input audio before encoding and I called it resamplerEncoder) with the following args :

    &#xA;&#xA;

    resamplerEncoder->init(contextEncoder, 8000, 48000, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP);&#xA;

    &#xA;&#xA;

    The second instance of ResamplerAudio (this instance do resamping after decoding audio from Opus and I called it resamplerDecoder) I init with the following args :

    &#xA;&#xA;

    resamplerDecoder->init(contextDecoder, 48000, 8000, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16);&#xA;

    &#xA;&#xA;

    The function of ResamplerAudio that does resampling looks like this :

    &#xA;&#xA;

    std::vector ResamplerAudio::convert(uint8_t **inData, int inSamplesCount, int outChannels, int outFormat)&#xA;{&#xA;    std::vector result;&#xA;    uint8_t *dstData = NULL;&#xA;    const int dstNbSamples = swr_get_out_samples(swrContext, inSamplesCount);&#xA;    av_samples_alloc(&amp;dstData, NULL, outChannels, dstNbSamples, AVSampleFormat(outFormat), 1);&#xA;    int resampledSize = swr_convert(swrContext, &amp;dstData, dstNbSamples, (const uint8_t **)inData, inSamplesCount);&#xA;    int dstBufSize = av_samples_get_buffer_size(NULL, outChannels, resampledSize, AVSampleFormat(outFormat), 1);&#xA;&#xA;    if (dstBufSize &lt;= 0) return result;&#xA;&#xA;    std::copy(&amp;dstData[0], &amp;dstData[dstBufSize], std::back_inserter(result));&#xA;&#xA;    return result;&#xA;}&#xA;

    &#xA;&#xA;

    And I call ResamplerAudio::convert function before encoding with the following args :

    &#xA;&#xA;

    // data - an array of raw pcm audio&#xA;// dataLength - the length of data array&#xA;// getSamplesCount() - function that calculates samples count&#xA;// frameEncode - AVFrame that using for encode audio&#xA;std::vector resampledData = resamplerEncoder->convert(&amp;data, getSamplesCount(dataLength, frameEncode->channels, AV_SAMPLE_FMT_S16), frameEncode->channels, frameEncode->format);&#xA;

    &#xA;&#xA;

    getSamplesCount() function looks like this :

    &#xA;&#xA;

    getSamplesCount(int bytesCount, int channels, AVSampleFormat format)&#xA;{&#xA;    return bytesCount / av_get_bytes_per_sample(format) / channels;&#xA;}&#xA;

    &#xA;&#xA;

    After that I fill my frameEncode with resampled samples :

    &#xA;&#xA;

    memcpy(&amp;frame->data[0][0], &amp;resampledData[0], sizeof(uint8_t) * resampledDataLength);&#xA;

    &#xA;&#xA;

    And pass frameEncode to encoding like this encodeFrame(resampledDataLength) :

    &#xA;&#xA;

    void encodeFrame(int dataLength)&#xA;{&#xA;    /* send the frame for encoding */&#xA;    int ret = avcodec_send_frame(contextEncoder, frameEncode);&#xA;    if (ret &lt; 0)&#xA;    {&#xA;        LOGE(TAG, "[encodeFrame] avcodec_send_frame error: %s", av_err2str(ret));&#xA;        return;&#xA;    }&#xA;&#xA;    /* read all the available output packets (in general there may be any number of them */&#xA;    while (ret >= 0)&#xA;    {&#xA;        ret = avcodec_receive_packet(contextEncoder, packetEncode);&#xA;        if (ret &lt; 0 &amp;&amp; ret != AVERROR(EAGAIN)) LOGE(TAG, "[encodeFrame] error in avcodec_receive_packet: %s", av_err2str(ret));&#xA;        if (ret &lt; 0) break;&#xA;&#xA;        // encodedData - std::vector that stores encoded data&#xA;        std::copy(&amp;packetEncode->data[0], &amp;packetEncode->data[dataLength], std::back_inserter(encodedData));&#xA;        av_packet_unref(packetEncode);&#xA;    }&#xA;}&#xA;

    &#xA;&#xA;

    Then I decode my encoded samples and do resampling to get back them in source sample format and sample rate so I call ResamplerAudio::convert function for resamplerDecoder with the following args :

    &#xA;&#xA;

    // frameDecode - AVFrame that holds decoded audio&#xA;std::vector resampledData = resamplerDecoder->convert(frameDecode->data, frameDecode->nb_samples, frameDecode->channels, AV_SAMPLE_FMT_S16);&#xA;

    &#xA;&#xA;

    And result sound is choppy and I also noticed that the decoded array size is bigger than the source array size with raw pcm audio.

    &#xA;&#xA;

    Please any ideas what I'm doing wrong ?

    &#xA;&#xA;

    UPD 18.05.2020

    &#xA;&#xA;

    I tested my resampling logic, I did resampling of raw pcm sound without any encoding and decoding routines. First I tried to convert the sample rate of input sound from 8000 Hz to 48000 Hz than I took resampled samples from step above and convert it's sample rate from 48000 Hz to 8000 Hz and the result sound is perfect and clean, also I did the same steps but I converted not a sample rate but a sample format from AV_SAMPLE_FMT_S16 to AV_SAMPLE_FMT_FLTP and vice versa and again the result sound is perfect and clean, also I got the same result when I coverted both a sample rate and a sample format.&#xA;So I assume that the problem of distorted and choppy sound is in my encoding or decoding routine, I think most likely in decoding routine because after decoding I ALWAYS get AVFrame with 960 nb_samples despite what was the size of input sound.

    &#xA;&#xA;

    My decoding routine looks like this :

    &#xA;&#xA;

    std::vector decode(uint8_t *data, unsigned int dataLength)&#xA;{&#xA;    decodedData.clear();&#xA;&#xA;    int dataSize = dataLength;&#xA;&#xA;    while (dataSize > 0)&#xA;    {&#xA;        if (!frameDecode)&#xA;        {&#xA;            frameDecode = av_frame_alloc();&#xA;            if (!frameDecode)&#xA;            {&#xA;                LOGE(TAG, "[decode] Couldn&#x27;t allocate the frame");&#xA;                return EMPTY_DATA;&#xA;            }&#xA;        }&#xA;&#xA;        ret = av_parser_parse2(parser, contextDecoder, &amp;packetDecode->data, &amp;packetDecode->size, &amp;data[0], dataSize, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);&#xA;        if (ret &lt; 0) {&#xA;            LOGE(TAG, "[decode] av_parser_parse2 error: %s", av_err2str(ret));&#xA;            return EMPTY_DATA;&#xA;        }&#xA;&#xA;        data &#x2B;= ret;&#xA;        dataSize -= ret;&#xA;&#xA;        doDecode();&#xA;    }&#xA;    return decodedData;&#xA;}&#xA;&#xA;void doDecode()&#xA;{&#xA;    if (packetDecode->size) {&#xA;        /* send the packet with the compressed data to the decoder */&#xA;        int ret = avcodec_send_packet(contextDecoder, packetDecode);&#xA;        if (ret &lt; 0) LOGE(TAG, "[decode] avcodec_send_packet error: %s", av_err2str(ret));&#xA;&#xA;        /* read all the output frames (in general there may be any number of them */&#xA;        while (ret >= 0)&#xA;        {&#xA;            ret = avcodec_receive_frame(contextDecoder, frameDecode);&#xA;            if (ret &lt; 0 &amp;&amp; ret != AVERROR(EAGAIN) &amp;&amp; ret != AVERROR_EOF) LOGE(TAG, "[decode] avcodec_receive_frame error: %s", av_err2str(ret));&#xA;            if (ret &lt; 0) break;&#xA;&#xA;            std::vector resampledData = resamplerDecoder->convert(frameDecode->data, frameDecode->nb_samples, frameDecode->channels, AV_SAMPLE_FMT_S16);&#xA;            if (!resampledData.size()) continue;&#xA;            std::copy(&amp;resampledData.data()[0], &amp;resampledData.data()[resampledData.size()], std::back_inserter(decodedData));&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;&#xA;

    UPD 30.05.2020

    &#xA;&#xA;

    I decided to refuse to use FFmpeg in my project and use libopus 1.3.1 instead, so I made a wrapper around it and it works fine.

    &#xA;