Recherche avancée

Médias (0)

Mot : - Tags -/formulaire

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

Autres articles (28)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • MediaSPIP Player : les contrôles

    26 mai 2010, par

    Les contrôles à la souris du lecteur
    En plus des actions au click sur les boutons visibles de l’interface du lecteur, il est également possible d’effectuer d’autres actions grâce à la souris : Click : en cliquant sur la vidéo ou sur le logo du son, celui ci se mettra en lecture ou en pause en fonction de son état actuel ; Molette (roulement) : en plaçant la souris sur l’espace utilisé par le média (hover), la molette de la souris n’exerce plus l’effet habituel de scroll de la page, mais diminue ou (...)

  • L’utiliser, en parler, le critiquer

    10 avril 2011

    La première attitude à adopter est d’en parler, soit directement avec les personnes impliquées dans son développement, soit autour de vous pour convaincre de nouvelles personnes à l’utiliser.
    Plus la communauté sera nombreuse et plus les évolutions seront rapides ...
    Une liste de discussion est disponible pour tout échange entre utilisateurs.

Sur d’autres sites (4315)

  • 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;

  • Encoder (codec none) not found for output stream #0:1 [on hold]

    16 novembre 2013, par Gururak

    Hi i built ffmpeg executable on Redhat5. I want to mix two Audio using the command multiple
    "ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT.mp3".

    I enabled libflamemp3 library without any error.

    [root@localhost ~]# ffmpeg -i /root/media/Katlalli.mp3 -i /root/media/Katlalli.mp3 -filter_complex amix=inputs=2:duration=first:dropout_transition=2 /root/media/OUTPutnew123.mp3
    ffmpeg version 2.1 Copyright (c) 2000-2013 the FFmpeg developers
     built on Nov 14 2013 03:17:10 with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-46)
     configuration: --enable-libmp3lame
     libavutil      52. 48.100 / 52. 48.100
     libavcodec     55. 39.100 / 55. 39.100
     libavformat    55. 19.104 / 55. 19.104
     libavdevice    55.  5.100 / 55.  5.100
     libavfilter     3. 90.100 /  3. 90.100
     libswscale      2.  5.101 /  2.  5.101
     libswresample   0. 17.104 /  0. 17.104
    [mp3 @ 0x193ef240] Estimating duration from bitrate, this may be inaccurate
    Input #0, mp3, from &#39;/root/media/Katlalli.mp3&#39;:
     Metadata:
       artist          : Yograj Bhat
       title           : Katlalli Karadige
       track           : 3
       album           : Paramathma
       album_artist    : Puneet Rajkumar
       genre           : Kannada
       composer        : V.Harikrishna
       date            : 2011
     Duration: 00:04:41.46, start: 0.000000, bitrate: 191 kb/s
       Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
       Stream #0:1: Video: mjpeg, yuvj420p(pc), 200x200 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
       Metadata:
         title           : thumbnail
         comment         : Cover (front)
    [mp3 @ 0x194090a0] Estimating duration from bitrate, this may be inaccurate
    Input #1, mp3, from &#39;/root/media/Katlalli.mp3&#39;:
     Metadata:
       artist          : Yograj Bhat
       title           : Katlalli Karadige
       track           : 3
       album           : Paramathma
       album_artist    : Puneet Rajkumar
       genre           : Kannada
       composer        : V.Harikrishna
       date            : 2011
     Duration: 00:04:41.46, start: 0.000000, bitrate: 191 kb/s
       Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
       Stream #1:1: Video: mjpeg, yuvj420p(pc), 200x200 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
       Metadata:
         title           : thumbnail
         comment         : Cover (front)
    File &#39;/root/media/OUTPutnew123.mp3&#39; already exists. Overwrite ? [y/N] y
    Output #0, mp3, to &#39;/root/media/OUTPutnew123.mp3&#39;:
     Metadata:
       artist          : Yograj Bhat
       title           : Katlalli Karadige
       track           : 3
       album           : Paramathma
       album_artist    : Puneet Rajkumar
       genre           : Kannada
       composer        : V.Harikrishna
       date            : 2011
       Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp (default)
       Stream #0:1: Video: none, q=2-31, 128 kb/s, 90k tbn
       Metadata:
         title           : thumbnail
         comment         : Cover (front)
    Stream mapping:
     Stream #0:0 (mp3) -> amix:input0
     Stream #1:0 (mp3) -> amix:input1
     amix -> Stream #0:0 (libmp3lame)
     Stream #0:1 -> #0:1 (mjpeg -> ?)
    Encoder (codec none) not found for output stream #0:1

    But when i try to combine two mp3 audio,
    "ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT.mp3".

    I am getting error like

    "Encoder (codec none) not found for output stream #0:1"

    so please help me how to link or install "libmp3flame" on Redhat5.

  • Screen Transfer [on hold]

    9 décembre 2013, par sanalism

    I need to develop a program that transfers a users screen and sound to another user over internet. The scenario can be visualized like this :

    There is a teacher in front of his computer and writes some code on his computer (ex:visual studio). He has a microphone. There is two students watching teacher's screen and listening his voice from their own computers.

    There are a few alternatives to get screen capture of a user and transfer it like ffmpeg, aforge or self coded screen capture program by c# (over udp). Tried all alternatives.

    However, the problem is all of them are so slow, or creates bad resolution of video. There should be an alternative way, because some programs reaches a high quality. For example teamviewer, windows remote desktop, logmein can send the screen with a high quality. More over, teamviewer can send sound also.

    Where should I begin to overcome this mission ? Which platform, language, protocol is useful ?