Recherche avancée

Médias (91)

Autres articles (101)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • L’agrémenter visuellement

    10 avril 2011

    MediaSPIP est basé sur un système de thèmes et de squelettes. Les squelettes définissent le placement des informations dans la page, définissant un usage spécifique de la plateforme, et les thèmes l’habillage graphique général.
    Chacun peut proposer un nouveau thème graphique ou un squelette et le mettre à disposition de la communauté.

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (8110)

  • Segmentation fault on debian 9 when decoding audio with ffmpeg and libopus

    27 août 2021, par Ramil Dautov

    I wrote the program that takes as an input some .opus file, decodes it using libavcodec and libopus and then plays it using SDL2. Program works on Windows 10 and Ubuntu 18.04, however it crashes with the segmentation fault on Debian 9.

    


    I've tried to update libavcodec and libopus libraries, tried to compile using clang and gcc - nothing helped.

    


    Address sanitizer shows that stack overflow happens :

    


    ASAN:DEADLYSIGNAL
=================================================================
==12167==ERROR: AddressSanitizer: stack-overflow on address 0x2b3e74c81ff8 (pc 0x2b3e7a098803 bp 0x2b3e74c82690 sp 0x2b3e74c81eb0 T2)
    #0 0x2b3e7a098802 in quant_all_bands celt/bands.c:1403
    #1 0x2b3e7a0a2a37 in celt_decode_with_ec celt/celt_decoder.c:1083
    #2 0x2b3e7a0c8afb in opus_decode_frame src/opus_decoder.c:518
    #3 0x2b3e7a0c9e40 in opus_decode_native src/opus_decoder.c:721
    #4 0x2b3e7a0d33f3 in opus_multistream_decode_native src/opus_multistream_decoder.c:253
    #5 0x2b3e7a0d37a8 in opus_multistream_decode src/opus_multistream_decoder.c:398
    #6 0x2b3e760ad83c  (/usr/lib/x86_64-linux-gnu/libavcodec.so.57+0x43583c)
    #7 0x2b3e75e4ca27  (/usr/lib/x86_64-linux-gnu/libavcodec.so.57+0x1d4a27)
    #8 0x2b3e75e4f62a in avcodec_send_packet (/usr/lib/x86_64-linux-gnu/libavcodec.so.57+0x1d762a)
    #9 0x2b3e75e4f9e6  (/usr/lib/x86_64-linux-gnu/libavcodec.so.57+0x1d79e6)
    #10 0x55ef09511882 in decode(AVCodecContext*, AVPacket*, unsigned char*, int) /home/ram/my/player3/speaker.cpp:296
    #11 0x55ef09511626 in fillBuffer(AVCodecContext*, unsigned char*, int) /home/ram/my/player3/speaker.cpp:251
    #12 0x55ef09511294 in process(AVCodecContext*, unsigned char*, int) /home/ram/my/player3/speaker.cpp:194
    #13 0x55ef095105b9 in audio_callback(void*, unsigned char*, int) /home/ram/my/player3/speaker.cpp:69
    #14 0x2b3e7815cc31  (/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x1fc31)
    #15 0x2b3e781bcf8b  (/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x7ff8b)
    #16 0x2b3e7820c6c8  (/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf6c8)
    #17 0x2b3e77be74a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3)
    #18 0x2b3e7940ed0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e)

SUMMARY: AddressSanitizer: stack-overflow celt/bands.c:1403 in quant_all_bands
Thread T2 (SDLAudioDev2) created by T0 here:
    #0 0x2b3e74d0df59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59)
    #1 0x2b3e7820c732  (/usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0xcf732)



    


    I also tried to increase stack size using ulimit -s unlimited and tried to increase stack size for the thread that starts decoding, didn't work.

    


    In main.cpp file I have this :

    


    #include <iostream>&#xA;#include <memory>&#xA;#include <mutex>&#xA;#include "speaker.h"&#xA;#include "SDL2/SDL.h"&#xA;&#xA;extern "C"{&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libswresample></libswresample>swresample.h>&#xA;}&#xA;&#xA;static int decode_audio_file(const char* path) {&#xA;    &#xA;    av_register_all();&#xA;&#xA;    // get format from audio file&#xA;    AVFormatContext* format = avformat_alloc_context();&#xA;    if (avformat_open_input(&amp;format, path, NULL, NULL) != 0) {&#xA;        std::cout &lt;&lt; "Could not open file" &lt;&lt; std::endl;&#xA;        return -1;&#xA;    }&#xA;    if (avformat_find_stream_info(format, NULL) &lt; 0) {&#xA;        std::cout &lt;&lt; "Could not retrieve stream info from file" &lt;&lt; std::endl;&#xA;        return -1;&#xA;    }&#xA;&#xA;    // Find the index of the first audio stream&#xA;    int stream_index =- 1;&#xA;    for (int i=0; i&lt; format->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (format->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            stream_index = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;    if (stream_index == -1) {&#xA;        std::cout &lt;&lt; "Could not retrieve audio stream from file" &lt;&lt; std::endl;&#xA;        return -1;&#xA;    }&#xA;    AVStream* stream = format->streams[stream_index];&#xA;&#xA;    // Initialize speaker&#xA;    init_Speaker("OPUS",&#xA;                  48000,&#xA;                  2,&#xA;                  15,&#xA;                  3,&#xA;                  av_get_channel_layout("stereo"),&#xA;                  av_get_sample_fmt("s16"));&#xA;&#xA;    // prepare to read data&#xA;    AVPacket* packet;&#xA;    packet = av_packet_alloc();&#xA;    av_init_packet(packet);&#xA;&#xA;    // iterate through frames&#xA;    while (av_read_frame(format, packet) >= 0) {&#xA;        play(packet->data, packet->size, std::chrono::microseconds{packet->pts},&#xA;                std::chrono::microseconds{packet->dts});&#xA;        av_packet_unref(packet);&#xA;    }&#xA;&#xA;    // clean up&#xA;    avformat_free_context(format);&#xA;    close_Speaker();&#xA;&#xA;    // success&#xA;    return 0;&#xA;}&#xA;&#xA;int main(int argc, char const *argv[]) {&#xA;    // check parameters&#xA;    if (argc &lt; 2) {&#xA;        std::cout &lt;&lt; "Please provide the path to an audio file as first command-line argument.\n";&#xA;        return -1;&#xA;    }&#xA;&#xA;    // Init Audio&#xA;    SDL_Init(SDL_INIT_AUDIO);&#xA;&#xA;    // decode data&#xA;    if (decode_audio_file(argv[1]) != 0) {&#xA;        return -1;&#xA;    }&#xA;&#xA;    std::cout &lt;&lt; "Finish" &lt;&lt; std::endl;&#xA;    return 0;&#xA;}&#xA;&#xA;</mutex></memory></iostream>

    &#xA;

    In speaker.cpp :

    &#xA;

    #include "speaker.h"&#xA;#include "pthread.h"&#xA;#include "avcodec.h"&#xA;#include "common.h"&#xA;#include <iostream>&#xA;&#xA;extern "C"&#xA;{&#xA;#include <libswresample></libswresample>swresample.h>&#xA;#include <libavutil></libavutil>hwcontext.h>&#xA;}&#xA;&#xA;using std::chrono::microseconds;&#xA;&#xA;SDL_AudioDeviceID m_id;&#xA;&#xA;AVCodecParserContext *parser = nullptr;&#xA;&#xA;//&#xA;constexpr static auto buffer_size{1024}; // 2048&#xA;constexpr static auto buffer_max_size{AVCODEC_MAX_AUDIO_FRAME_SIZE * 4};&#xA;uint32_t m_samplerate;&#xA;uint32_t m_queue_limit;&#xA;uint32_t m_queue_dropfactor;&#xA;int64_t m_channel_layout;&#xA;AVSampleFormat m_device_format;&#xA;AVCodecID audio_codec_id{AV_CODEC_ID_NONE};&#xA;AVCodecContext* adecoder;&#xA;&#xA;player::PacketQueue queue(0, true); &#xA;&#xA;&#xA;static uint8_t* buf = nullptr;&#xA;uint32_t absize{};&#xA;uint32_t abpos{};&#xA;int32_t max_decoder_size{};&#xA;// need a converter?&#xA;uint8_t* convbuf{};&#xA;SwrContext* swrctx{};&#xA;int32_t sframes{};&#xA;AVCodec* codec{};&#xA;&#xA;uint8_t * audio_buffer_init() {&#xA;    if(buf == nullptr) {&#xA;        buf = (uint8_t*) malloc(buffer_max_size);&#xA;        if(buf == nullptr) {&#xA;            return nullptr;&#xA;        }&#xA;    }&#xA;    return buf;&#xA;}&#xA;&#xA;void audio_callback(void* userdata, uint8_t* stream, int len) {&#xA;    AVCodecContext* decoder = (AVCodecContext*)userdata;&#xA;    process(decoder, stream, len);&#xA;};&#xA;&#xA;void init_Speaker(const std::string&amp; codecName,&#xA;                 int32_t samplerate,&#xA;                 uint8_t channels,&#xA;                 uint32_t queue_limit,&#xA;                 uint32_t queue_dropfactor,&#xA;                 int64_t channel_layout,&#xA;                 AVSampleFormat format)&#xA;{&#xA;    m_samplerate = samplerate;&#xA;    m_queue_limit = queue_limit;&#xA;    m_queue_dropfactor = queue_dropfactor;&#xA;    m_device_format = format;&#xA;    m_channel_layout = channel_layout;&#xA;&#xA;&#xA;    SDL_SetHint(SDL_HINT_THREAD_STACK_SIZE, "8388608");&#xA;&#xA;    if(codecName.empty())&#xA;        throw std::runtime_error("audio decoder: no codec specified.");&#xA;&#xA;    auto names = player::lookup_ffmpeg_decoders(codecName);&#xA;    if(names == nullptr)&#xA;        throw std::runtime_error("audio decoder: cannot find decoder names for {}"&#x2B;codecName);&#xA;&#xA;    audio_codec_id = player::lookup_codec_id(codecName);&#xA;    codec      = player::avcodec_find_decoder(names, AV_CODEC_ID_NONE);&#xA;    if(codec == nullptr)&#xA;        throw std::runtime_error("audio decoder: cannot find the decoder for {}"&#x2B;codecName);&#xA;&#xA;    adecoder = avcodec_alloc_context3(codec);&#xA;    if(adecoder == nullptr)&#xA;        throw std::runtime_error("audio decoder: cannot allocate context");&#xA;&#xA;    adecoder->channels   = channels;&#xA;    adecoder->sample_rate = samplerate;&#xA;    if(adecoder->channels == 1)&#xA;    {&#xA;        adecoder->channel_layout = AV_CH_LAYOUT_MONO;&#xA;    }&#xA;    else if(adecoder->channels == 2)&#xA;    {&#xA;        adecoder->channel_layout = AV_CH_LAYOUT_STEREO;&#xA;    }&#xA;    else&#xA;        throw std::runtime_error("audio decoder: unsupported number of channels ({})"&#x2B; adecoder->channels);&#xA;    &#xA;&#xA;    if(avcodec_open2(adecoder, codec, nullptr) != 0)&#xA;        throw std::runtime_error("audio decoder: cannot open decoder");&#xA;&#xA;    parser = av_parser_init(codec->id);&#xA;&#xA;    SDL_AudioSpec wanted, spec;&#xA;    wanted.freq     = samplerate;&#xA;    wanted.format   = AUDIO_S16SYS;&#xA;    wanted.channels = channels;&#xA;    wanted.silence  = 0;&#xA;    wanted.samples  = buffer_size;&#xA;    wanted.userdata = adecoder;&#xA;    wanted.callback = audio_callback;&#xA;    &#xA;&#xA;    m_id = SDL_OpenAudioDevice(nullptr, 0, &amp;wanted, &amp;spec, 0);&#xA;    if(m_id == 0)&#xA;        throw std::runtime_error(SDL_GetError());&#xA;&#xA;    SDL_PauseAudioDevice(m_id, 0);&#xA;}&#xA;&#xA;void close_Speaker()&#xA;{&#xA;    SDL_CloseAudioDevice(m_id);&#xA;    &#xA;    if(adecoder != nullptr)&#xA;        player::avcodec_close(adecoder);&#xA;&#xA;}&#xA;&#xA;void play(uint8_t* buffer, size_t bufsize, microseconds pts, microseconds dts)&#xA;{&#xA;    if(!buffer || !bufsize) {&#xA;        return;&#xA;    }&#xA;    &#xA;    AVPacket* avpkt;&#xA;    avpkt = av_packet_alloc();&#xA;    av_init_packet(avpkt);&#xA;    uint8_t bf[bufsize &#x2B; 64];&#xA;    memcpy(bf, buffer, bufsize);&#xA;&#xA;    av_parser_parse2(parser, adecoder, &amp;avpkt->data, &amp;avpkt->size,&#xA;                           bf, bufsize,&#xA;                           pts.count(), dts.count(), 0);&#xA;&#xA;    queue.put(av_packet_clone(avpkt));&#xA;    queue.drop(m_queue_limit, m_queue_dropfactor); &#xA;&#xA;}&#xA;&#xA;//&#xA;&#xA;void process(AVCodecContext* decoder, uint8_t* stream, int ssize)&#xA;{&#xA;    auto filled = fillBuffer(decoder, stream, ssize);&#xA;&#xA;    auto unfilled{(ssize - filled) / 4};&#xA;    auto dummy{sframes};&#xA;&#xA;    sframes = unfilled == 0 ? 0 : sframes &#x2B; unfilled;&#xA;    memset(stream &#x2B; filled, 0, unfilled * 4);&#xA;    &#xA;    if(sframes != dummy)&#xA;        queue.add_silence((int64_t)sframes * 1000000 / m_samplerate);&#xA;}&#xA;&#xA;int fillBuffer(AVCodecContext* decoder, uint8_t* stream, int ssize)&#xA;{&#xA;    int filled{};&#xA;    AVPacket avpkt;&#xA;    audio_buffer_init();&#xA;    while(filled &lt; ssize)&#xA;    {&#xA;        int dsize{}, delta{};&#xA;&#xA;        // buffer has enough data&#xA;        if(absize - abpos >= static_cast<unsigned int="int">(ssize - filled))&#xA;        {&#xA;            delta = ssize - filled;&#xA;            std::copy(buf &#x2B; abpos, buf &#x2B; abpos &#x2B; delta, stream);&#xA;            abpos &#x2B;= delta;&#xA;            filled &#x2B;= delta;&#xA;            return ssize;&#xA;        }&#xA;        else if(absize - abpos > 0)&#xA;        {&#xA;            delta = absize - abpos;&#xA;            std::copy(buf &#x2B; abpos, buf &#x2B; abpos &#x2B; delta, stream);&#xA;            stream &#x2B;= delta;&#xA;            filled &#x2B;= delta;&#xA;            abpos = absize = 0;&#xA;        }&#xA;        // move data to head, leave more ab buffers&#xA;        if(abpos != 0)&#xA;        {&#xA;            std::copy(buf &#x2B; abpos, buf &#x2B; abpos &#x2B; absize - abpos, buf);&#xA;            absize -= abpos;&#xA;            abpos = 0;&#xA;        }&#xA;        // decode more packets&#xA;        if(!queue.get(&amp;avpkt, false))&#xA;            break;&#xA;        if((dsize = decode(decoder, &amp;avpkt, buf &#x2B; absize, buffer_max_size - absize)) &lt; 0)&#xA;            break;&#xA;        absize &#x2B;= dsize;&#xA;    }&#xA;&#xA;    return filled;&#xA;}&#xA;&#xA;int decode(AVCodecContext* decoder, AVPacket* pkt, uint8_t* dstbuf, int dstlen)&#xA;{&#xA;    const uint8_t* srcplanes[SWR_CH_MAX];&#xA;    uint8_t* dstplanes[SWR_CH_MAX];&#xA;    int filled{};&#xA;&#xA;    AVFrame* aframe = av_frame_alloc();&#xA;&#xA;    auto saveptr = pkt->data;&#xA;&#xA;    while(pkt->size > 0)&#xA;    {&#xA;        int len{}, got_frame{};&#xA;        unsigned char* srcbuf{};&#xA;        int datalen{};&#xA;&#xA;        if((len = avcodec_decode_audio4(decoder, aframe, &amp;got_frame, pkt)) &lt; 0)&#xA;        {&#xA;            return -1;&#xA;        }&#xA;        if(got_frame == 0)&#xA;        {&#xA;            pkt->size -= len;&#xA;            pkt->data &#x2B;= len;&#xA;            continue;&#xA;        }&#xA;&#xA;        if(aframe->format == m_device_format)&#xA;        {&#xA;            datalen = av_samples_get_buffer_size(nullptr,&#xA;                                                 aframe->channels /*rtspconf->audio_channels*/,&#xA;                                                 aframe->nb_samples,&#xA;                                                 (AVSampleFormat)aframe->format,&#xA;                                                 1 /*no-alignment*/);&#xA;            srcbuf  = aframe->data[0];&#xA;        }&#xA;        else&#xA;        {&#xA;            // need conversion!&#xA;            if(swrctx == nullptr)&#xA;            {&#xA;                if((swrctx = swr_alloc_set_opts(nullptr,&#xA;                                                m_channel_layout,&#xA;                                                m_device_format,&#xA;                                                m_samplerate,&#xA;                                                aframe->channel_layout,&#xA;                                                (AVSampleFormat)aframe->format,&#xA;                                                aframe->sample_rate,&#xA;                                                0,&#xA;                                                nullptr)) == nullptr)&#xA;                {&#xA;                    return -1;&#xA;                }&#xA;                auto err = swr_init(swrctx);&#xA;                if(err &lt; 0)&#xA;                {&#xA;                    char msg[1024];&#xA;                    av_strerror(err, msg, 1024);&#xA;                    return -1;&#xA;                }&#xA;                max_decoder_size = av_samples_get_buffer_size(nullptr,&#xA;                                                              2, &#xA;                                                              m_samplerate,&#xA;                                                              m_device_format,&#xA;                                                              1 /*no-alignment*/);&#xA;                if((convbuf = (unsigned char*)::malloc(max_decoder_size)) == nullptr)&#xA;                {&#xA;                    return -1;&#xA;                }&#xA;            }&#xA;            datalen = av_samples_get_buffer_size(nullptr,&#xA;                                                 2,&#xA;                                                 aframe->nb_samples,&#xA;                                                 m_device_format,&#xA;                                                 1 /*no-alignment*/);&#xA;            if(datalen > max_decoder_size)&#xA;            {&#xA;                return -1;&#xA;            }&#xA;            srcplanes[0] = aframe->data[0];&#xA;            if(av_sample_fmt_is_planar((AVSampleFormat)aframe->format) != 0)&#xA;            {&#xA;                // planar&#xA;                int i;&#xA;                for(i = 1; i &lt; aframe->channels; i&#x2B;&#x2B;)&#xA;                {&#xA;                    srcplanes[i] = aframe->data[i];&#xA;                }&#xA;                srcplanes[i] = nullptr;&#xA;            }&#xA;            else&#xA;            {&#xA;                srcplanes[1] = nullptr;&#xA;            }&#xA;            dstplanes[0] = convbuf;&#xA;            dstplanes[1] = nullptr;&#xA;&#xA;            swr_convert(swrctx, dstplanes, aframe->nb_samples, srcplanes, aframe->nb_samples);&#xA;            srcbuf = convbuf;&#xA;        }&#xA;        if(datalen > dstlen)&#xA;        {&#xA;            datalen = dstlen;&#xA;        }&#xA;&#xA;        std::copy(srcbuf, srcbuf &#x2B; datalen, dstbuf);&#xA;        dstbuf &#x2B;= datalen;&#xA;        dstlen -= datalen;&#xA;        filled &#x2B;= datalen;&#xA;&#xA;        pkt->size -= len;&#xA;        pkt->data &#x2B;= len;&#xA;        av_frame_unref(aframe);&#xA;    }&#xA;    pkt->data = saveptr;&#xA;    if(pkt->data)&#xA;        av_packet_unref(pkt);&#xA;    if(aframe != nullptr)&#xA;        av_frame_free(&amp;aframe);&#xA;    &#xA;    return filled;&#xA;}&#xA;</unsigned></iostream>

    &#xA;

    In packet_queue.cpp :

    &#xA;

    #include "packet_queue.h"&#xA;&#xA;using player::PacketQueue;&#xA;using lock_guard  = std::lock_guard;&#xA;using unique_lock = std::unique_lock;&#xA;using std::chrono::milliseconds;&#xA;&#xA;PacketQueue::PacketQueue(uint32_t playback_queue_silence, bool playback_queue_debug) :&#xA;        m_playback_queue_debug(playback_queue_debug), m_playback_queue_silence(playback_queue_silence)&#xA;{&#xA;}&#xA;&#xA;void PacketQueue::clear()&#xA;{&#xA;    lock_guard lk{m_mtx};&#xA;    for(auto&amp; pkt : queue)&#xA;        av_packet_unref(pkt);&#xA;&#xA;    m_size = 0;&#xA;    queue.clear();&#xA;}&#xA;&#xA;void PacketQueue::add_silence(int64_t silence_pts)&#xA;{&#xA;    if(m_playback_queue_silence == 0)&#xA;    {&#xA;        return;&#xA;    }&#xA;&#xA;    lock_guard lk{m_mtx};&#xA;    silence_pts = filtered_packets > 0 ? silence_pts : last_pts &#x2B; silence_pts;&#xA;&#xA;    auto tv  = std::chrono::microseconds{last_pts};&#xA;    auto tv2 = std::chrono::microseconds{silence_pts};&#xA;}&#xA;&#xA;bool PacketQueue::put(AVPacket* pkt)&#xA;{&#xA;    if(pkt == nullptr)&#xA;    {&#xA;        return false;&#xA;    }&#xA;&#xA;    lock_guard lk{m_mtx};&#xA;    if((silence_pts - pkt->pts) > (m_playback_queue_silence * 1000))&#xA;    {&#xA;        auto tv = std::chrono::microseconds{pkt->pts};&#xA;        filtered_packets&#x2B;&#x2B;;&#xA;        if(m_playback_queue_debug)&#xA;        return true;&#xA;    }&#xA;&#xA;    queue.push_back(pkt);&#xA;    filtered_packets = 0;&#xA;    return true;&#xA;}&#xA;&#xA;bool PacketQueue::get(AVPacket* pkt, bool block, milliseconds timeout)&#xA;{&#xA;    unique_lock lk{m_mtx};&#xA;&#xA;    for(;;)&#xA;    {&#xA;        if(queue.size() > 0)&#xA;        {&#xA;            auto ptr = queue.front();&#xA;            queue.pop_front();&#xA;            m_size -= ptr->size;&#xA;            last_pts = ptr->pts;&#xA;            av_packet_move_ref(pkt, ptr);&#xA;            return true;&#xA;        }&#xA;        else if(!block)&#xA;        {&#xA;            return false;&#xA;        }&#xA;        else if(!m_cv.wait_for(lk, timeout, [&amp;] { return !queue.empty(); }))&#xA;        {&#xA;            return false;&#xA;        }&#xA;&#xA;    }&#xA;    return false;&#xA;}&#xA;&#xA;bool PacketQueue::drop(size_t limit, size_t dropfactor)&#xA;{&#xA;    int dropped, count = 0;&#xA;&#xA;    lock_guard lk{m_mtx};&#xA;&#xA;    // queue size exceeded?&#xA;    if(queue.size() &lt;= limit)&#xA;    {&#xA;        return false;&#xA;    }&#xA;&#xA;    // start dropping&#xA;    dropped = queue.size() / dropfactor;&#xA;    // keep at least one&#xA;    if(dropped == queue.size())&#xA;        dropped--;&#xA;&#xA;    AVPacket* pkt;&#xA;    while(dropped-- > 0 &amp;&amp; !queue.empty())&#xA;    {&#xA;        pkt = queue.front();&#xA;&#xA;        if(pkt->flags != AV_PKT_FLAG_KEY)&#xA;        {&#xA;            queue.pop_front();&#xA;            m_size -= pkt->size;&#xA;            av_packet_unref(pkt);&#xA;            &#x2B;&#x2B;count;&#xA;        }&#xA;    }&#xA;&#xA;    return true; // count;&#xA;}&#xA;&#xA;int PacketQueue::drop2(size_t limit, bool error)&#xA;{&#xA;    int count = 0;&#xA;&#xA;    // dropping enabled?&#xA;    if(limit &lt;= 0 &amp;&amp; !error)&#xA;        return 0;&#xA;&#xA;    lock_guard lk{m_mtx};&#xA;    // queue size exceeded?&#xA;    if(queue.size() &lt;= limit &amp;&amp; !error)&#xA;        return false;&#xA;&#xA;    for(auto i = queue.begin(); i != queue.end();)&#xA;    {&#xA;        AVPacket* pkt = *i;&#xA;        if(pkt->flags != AV_PKT_FLAG_KEY)&#xA;        {&#xA;            m_size -= pkt->size;&#xA;            av_packet_unref(pkt);&#xA;            i = queue.erase(i);&#xA;            count&#x2B;&#x2B;;&#xA;        }&#xA;        else&#xA;            &#x2B;&#x2B;i;&#xA;    }&#xA;&#xA;    return count;&#xA;}&#xA;

    &#xA;

    1403 line of celt/bands.c :&#xA;screenshot

    &#xA;

    Versions of libraries that I tried on Debian 9 :&#xA;libavcodec.so.57.64.101 and libopus.so.0.5.3

    &#xA;

    also I built manually libavcodec.so.57.107.100 and libopus.so.0.8.0 and tried to use them - the same error appears.

    &#xA;

    As I already mentioned, everything works fine on Windows 10 and Ubuntu 18.04. So I have no clue what could be the reason of the issue. Any help is appreciated.

    &#xA;

  • How to make a Seek command in discord py with ytdl and ffmpeg

    15 septembre 2021, par Utsarg

    I am making a discord py bot that plays music with ytdl and ffmpeg, is there a way to seek to a specific part in the song ?

    &#xA;

  • Use data to develop impactful video content

    28 septembre 2021, par Ben Erskine — Analytics Tips, Plugins

    Creating impactful video content is at the heart of what you do. How you really engage with your audience, change behaviours and influence customers to complete your digital goals. But how do you create truly impactful marketing content ? By testing, trialling, analysing and ultimately tweaking and reacting to data-informed insights that gear your content to your audience (rather than simply producing great content and shooting arrows in the dark).

    Whether you want to know how many plays your video has, finish rates, how your video is consumed over time, how video was consumed on specific days or even which locations users are viewing your video content. Media Analytics will gather all of your video data in one place and provide answers to all of these questions (and much more).

    What is impactful video content ?

    Impactful video content grabs your audience’s attention, keeps their attention and promotes them to take measurable action. Be that time spent on your website, goal completion or brand engagement (including following, commenting or sharing on social). Maybe you’ve developed video content, had some really great results, but not consistently, nor every time and it can be difficult to identify what exactly it is that engages and entices each and every time. And we all want to find where that lovely sweet spot is for your audience.

    Embedded video on your website can be a marketing piece that talks about the benefits of your product. Or can be educational or informative that support the brand and overall impression of the brand. And at the very best entertaining at the same time. 

    84% of people say that they’ve been convinced to buy a product or service by watching a brand’s video. Building trust, knowledge and engagement are simply quicker with video. Viewers interact more, and are engaged longer with video, they are more likely to take in the message and trust what they are seeing through educational, informative or even entertaining video marketing content than solely through reading content on a website. And even better they take action, complete goals on your website and engage with your brand (potentially long term).

    It is not only necessary to have embedded video content on your website, it needs to deliver all the elements of a well functioning website, creating the very best user experience is essential to keeping your viewers engaged. This includes ensuring the video is quick to load, on-brand, expected (in format and tone) and easy to use and/or find. Ensuring that your video content is all of these things can mean that your website users will stick around longer on your website, spend more time exploring (and reading) your website and ultimately complete more of your goals. With a great user experience, your users, in turn, are more likely to come back again to your website and trust your brand. 

    All great reasons to create impactful video content that supports your website and brand ! And to analyse data around this behaviour to repeat (or better) the video content that really hits the mark.

    Let’s talk stats

    In terms of video marketing, there are stats to support that viewers retain 95% of a message when they view it in a video format. The psychology behind this should be fairly obvious. It is easier (and quicker) for humans to consume video and watch someone explain something than it is to read and take action. Simply look at the rise of YouTube for explanatory and instructional video content !

    And how about the 87% of marketers that report a positive ROI on using video in their marketing ? This number has steadily increased since 2015 and matches the increase in video views over the years. This should be enough to demonstrate that video marketing is the way forward, however it needs to be the right type of video to create impact and engagement.

    Do you need more reasons to consider honing and refining your video content for your audience ? And riding this wave of impactful video marketing success ?

    But, how do we do that ?

    So, how do you make content that consistently converts your audience to engaged customers ? The answer is in the numbers. The data. Collecting data on each and every piece of media that is produced and put out into the world. Measuring everything, from where it is viewed, how it is viewed, how much of it is viewed and what is your viewer’s action after the fact.

    While Vimeo and YouTube have their own video analytics they are each to their own, meaning a lot more work for you to combine and analyse your data before forming insights that are useful. 

    Your data is collected by external parties, and is owned and used by these platforms, for their own means. Using Web Analytics from Matomo to collect and collate media data can mean your robust data insights are all in one place. And you own the data, keeping your data private, clean and easy to digest. 

    Once your data is across a single platform, your time can be spent on analysing the data (rather than collating) and discovering those super valuable insights. Additionally, these insights can be collated and reported, in one place, and used to inform future digital and video marketing planning. Working with the data and alongside creative teams to produce video that talks to your audience in an impactful way.

    The more data that is collected the deeper the insights. Saving time and money across a single platform and with data-backed insights to inform decisions that can influence the time (and money) spent producing video content that truly hits the mark with your audience. No more wasted investment and firing into the dark without knowledge. 

    Interrogating the ideal length of your video media means it is more likely to be viewed to the end. Or understanding the play rate on your website of any video. How often is the video played ? And which is played more often ? Constant tweaking and updating of your video content planning can be informed by data-driven human-centric insights. By consistently tracking your media, analysing and forming insights you can build upon past work, and create a fuller picture of who your audience is and how they will engage with future video content. Understanding your media over time can lead to informed decisions that can impact the video content and the level of investment to deliver ROI that means something.

    Wrap Up

    Media Analytics puts you at the heart of video engagement. No more guessing at what your audience wants to see, how long or when. Make every piece of video content have the impact you want (and need) to drive engagement, goal completion and customer conversion. Create a user experience that keeps your users on your website for longer. Delivering on all of those delicious digital marketing goals and speaking the language of key stakeholders throughout the business. Back your digital marketing, with truly impactful content, and above all else deliver to your audience content that keeps them engaged and coming back for more.

    Don’t just take our word for it ! Take a look at what Matomo can offer you with streamlined and insightful Media Analytics, all in one place. And go forth and create impactful content, that matters.

    Next steps :

    Check out our detailed user guide to Media Analytics

    Or, if you have questions, see our helpful Video & Audio Analytics FAQ’s