Recherche avancée

Médias (1)

Mot : - Tags -/censure

Autres articles (57)

  • Monitoring de fermes de MediaSPIP (et de SPIP tant qu’à faire)

    31 mai 2013, par

    Lorsque l’on gère plusieurs (voir plusieurs dizaines) de MediaSPIP sur la même installation, il peut être très pratique d’obtenir d’un coup d’oeil certaines informations.
    Cet article a pour but de documenter les scripts de monitoring Munin développés avec l’aide d’Infini.
    Ces scripts sont installés automatiquement par le script d’installation automatique si une installation de munin est détectée.
    Description des scripts
    Trois scripts Munin ont été développés :
    1. mediaspip_medias
    Un script de (...)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Les notifications de la ferme

    1er décembre 2010, par

    Afin d’assurer une gestion correcte de la ferme, il est nécessaire de notifier plusieurs choses lors d’actions spécifiques à la fois à l’utilisateur mais également à l’ensemble des administrateurs de la ferme.
    Les notifications de changement de statut
    Lors d’un changement de statut d’une instance, l’ensemble des administrateurs de la ferme doivent être notifiés de cette modification ainsi que l’utilisateur administrateur de l’instance.
    À la demande d’un canal
    Passage au statut "publie"
    Passage au (...)

Sur d’autres sites (5065)

  • C++ ffmpeg lib version 7.0 - distortion in exported audio

    4 septembre 2024, par Chris P

    I want to make a C++ lib named cppdub which will mimic the python module pydub.

    


    One main function is to export the AudioSegment to a file with a specific format (example : mp3).

    


    The code is :

    


    &#xA;AudioSegment AudioSegment::from_file(const std::string&amp; file_path, const std::string&amp; format, const std::string&amp; codec,&#xA;    const std::map&amp; parameters, int start_second, int duration) {&#xA;&#xA;    avformat_network_init();&#xA;    av_log_set_level(AV_LOG_ERROR); // Adjust logging level as needed&#xA;&#xA;    AVFormatContext* format_ctx = nullptr;&#xA;    if (avformat_open_input(&amp;format_ctx, file_path.c_str(), nullptr, nullptr) != 0) {&#xA;        std::cerr &lt;&lt; "Error: Could not open audio file." &lt;&lt; std::endl;&#xA;        return AudioSegment();  // Return an empty AudioSegment on failure&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(format_ctx, nullptr) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error: Could not find stream information." &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    int audio_stream_index = -1;&#xA;    for (unsigned int i = 0; i &lt; format_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            audio_stream_index = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    if (audio_stream_index == -1) {&#xA;        std::cerr &lt;&lt; "Error: Could not find audio stream." &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    AVCodecParameters* codec_par = format_ctx->streams[audio_stream_index]->codecpar;&#xA;    const AVCodec* my_codec = avcodec_find_decoder(codec_par->codec_id);&#xA;    AVCodecContext* codec_ctx = avcodec_alloc_context3(my_codec);&#xA;&#xA;    if (!codec_ctx) {&#xA;        std::cerr &lt;&lt; "Error: Could not allocate codec context." &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    if (avcodec_parameters_to_context(codec_ctx, codec_par) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error: Could not initialize codec context." &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    if (avcodec_open2(codec_ctx, my_codec, nullptr) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error: Could not open codec." &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    SwrContext* swr_ctx = swr_alloc();&#xA;    if (!swr_ctx) {&#xA;        std::cerr &lt;&lt; "Error: Could not allocate SwrContext." &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    // Set up resampling context to convert to S16 format with 2 bytes per sample&#xA;    av_opt_set_chlayout(swr_ctx, "in_chlayout", &amp;codec_ctx->ch_layout, 0);&#xA;    av_opt_set_int(swr_ctx, "in_sample_rate", codec_ctx->sample_rate, 0);&#xA;    av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", codec_ctx->sample_fmt, 0);&#xA;&#xA;    AVChannelLayout dst_ch_layout;&#xA;    av_channel_layout_copy(&amp;dst_ch_layout, &amp;codec_ctx->ch_layout);&#xA;    av_channel_layout_uninit(&amp;dst_ch_layout);&#xA;    av_channel_layout_default(&amp;dst_ch_layout, 2);&#xA;&#xA;    av_opt_set_chlayout(swr_ctx, "out_chlayout", &amp;dst_ch_layout, 0);&#xA;    av_opt_set_int(swr_ctx, "out_sample_rate", codec_ctx->sample_rate, 0);  // Match input sample rate&#xA;    av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);  // Force S16 format&#xA;&#xA;    if (swr_init(swr_ctx) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error: Failed to initialize the resampling context" &lt;&lt; std::endl;&#xA;        swr_free(&amp;swr_ctx);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    AVPacket packet;&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        std::cerr &lt;&lt; "Error: Could not allocate frame." &lt;&lt; std::endl;&#xA;        swr_free(&amp;swr_ctx);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    std::vector<char> output;&#xA;    while (av_read_frame(format_ctx, &amp;packet) >= 0) {&#xA;        if (packet.stream_index == audio_stream_index) {&#xA;            if (avcodec_send_packet(codec_ctx, &amp;packet) == 0) {&#xA;                while (avcodec_receive_frame(codec_ctx, frame) == 0) {&#xA;                    if (frame->pts != AV_NOPTS_VALUE) {&#xA;                        frame->pts = av_rescale_q(frame->pts, codec_ctx->time_base, format_ctx->streams[audio_stream_index]->time_base);&#xA;                    }&#xA;&#xA;                    uint8_t* output_buffer;&#xA;                    int output_samples = av_rescale_rnd(&#xA;                        swr_get_delay(swr_ctx, codec_ctx->sample_rate) &#x2B; frame->nb_samples,&#xA;                        codec_ctx->sample_rate, codec_ctx->sample_rate, AV_ROUND_UP);&#xA;&#xA;                    int output_buffer_size = av_samples_get_buffer_size(&#xA;                        nullptr, 2, output_samples, AV_SAMPLE_FMT_S16, 1);&#xA;&#xA;                    output_buffer = (uint8_t*)av_malloc(output_buffer_size);&#xA;&#xA;                    if (output_buffer) {&#xA;                        memset(output_buffer, 0, output_buffer_size); // Zero padding to avoid random noise&#xA;                        int converted_samples = swr_convert(swr_ctx, &amp;output_buffer, output_samples,&#xA;                            (const uint8_t**)frame->extended_data, frame->nb_samples);&#xA;&#xA;                        if (converted_samples >= 0) {&#xA;                            output.insert(output.end(), output_buffer, output_buffer &#x2B; output_buffer_size);&#xA;                        }&#xA;                        else {&#xA;                            std::cerr &lt;&lt; "Error: Failed to convert audio samples." &lt;&lt; std::endl;&#xA;                        }&#xA;                        // Make sure output_buffer is valid before freeing&#xA;                        if (output_buffer != nullptr) {&#xA;                            av_free(output_buffer);&#xA;                            output_buffer = nullptr; // Prevent double-free&#xA;                        }&#xA;                    }&#xA;                    else {&#xA;                        std::cerr &lt;&lt; "Error: Could not allocate output buffer." &lt;&lt; std::endl;&#xA;                    }&#xA;                }&#xA;            }&#xA;            else {&#xA;                std::cerr &lt;&lt; "Error: Failed to send packet to codec context." &lt;&lt; std::endl;&#xA;            }&#xA;        }&#xA;        av_packet_unref(&amp;packet);&#xA;    }&#xA;&#xA;    int frame_width = av_get_bytes_per_sample(AV_SAMPLE_FMT_S16) * 2;  // Use 2 bytes per sample and 2 channels&#xA;&#xA;    std::map metadata = {&#xA;        {"sample_width", 2},  // S16 format has 2 bytes per sample&#xA;        {"frame_rate", codec_ctx->sample_rate},  // Use the input sample rate&#xA;        {"channels", 2},  // Assuming stereo output&#xA;        {"frame_width", frame_width}&#xA;    };&#xA;&#xA;    av_frame_free(&amp;frame);&#xA;    swr_free(&amp;swr_ctx);&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;    avformat_close_input(&amp;format_ctx);&#xA;&#xA;    return AudioSegment(static_cast<const>(output.data()), output.size(), metadata);&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;std::ofstream AudioSegment::export_segment(const std::string&amp; out_f,&#xA;    const std::string&amp; format,&#xA;    const std::string&amp; codec,&#xA;    const std::string&amp; bitrate,&#xA;    const std::vector&amp; parameters,&#xA;    const std::map&amp; tags,&#xA;    const std::string&amp; id3v2_version,&#xA;    const std::string&amp; cover) {&#xA;    av_log_set_level(AV_LOG_DEBUG);&#xA;    AVCodecContext* codec_ctx = nullptr;&#xA;    AVFormatContext* format_ctx = nullptr;&#xA;    AVStream* stream = nullptr;&#xA;    AVFrame* frame = nullptr;&#xA;    AVPacket* pkt = nullptr;&#xA;    SwrContext* swr_ctx = swr_alloc();&#xA;    int ret;&#xA;&#xA;    // Initialize format context&#xA;    if (avformat_alloc_output_context2(&amp;format_ctx, nullptr, format.c_str(), out_f.c_str()) &lt; 0) {&#xA;        throw std::runtime_error("Could not allocate format context.");&#xA;    }&#xA;&#xA;    // Find encoder&#xA;    const AVCodec* codec_ptr = avcodec_find_encoder_by_name(codec.c_str());&#xA;    if (!codec_ptr) {&#xA;        throw std::runtime_error("Codec not found.");&#xA;    }&#xA;&#xA;    // Add stream&#xA;    stream = avformat_new_stream(format_ctx, codec_ptr);&#xA;    if (!stream) {&#xA;        throw std::runtime_error("Failed to create new stream.");&#xA;    }&#xA;&#xA;    // Allocate codec context&#xA;    codec_ctx = avcodec_alloc_context3(codec_ptr);&#xA;    if (!codec_ctx) {&#xA;        throw std::runtime_error("Could not allocate audio codec context.");&#xA;    }&#xA;&#xA;    // Set codec parameters&#xA;    codec_ctx->bit_rate = std::stoi(bitrate);&#xA;    codec_ctx->sample_rate = this->get_frame_rate(); // Assuming get_frame_rate() returns the correct sample rate&#xA;&#xA;    // Set channel layout for stereo output&#xA;    av_channel_layout_default(&amp;codec_ctx->ch_layout, 2);&#xA;    codec_ctx->sample_fmt = AV_SAMPLE_FMT_S16P;&#xA;&#xA;    // Open codec&#xA;    if (avcodec_open2(codec_ctx, codec_ptr, nullptr) &lt; 0) {&#xA;        throw std::runtime_error("Could not open codec.");&#xA;    }&#xA;&#xA;    // Set codec parameters to the stream&#xA;    if (avcodec_parameters_from_context(stream->codecpar, codec_ctx) &lt; 0) {&#xA;        throw std::runtime_error("Could not initialize stream codec parameters.");&#xA;    }&#xA;&#xA;    // Open output file&#xA;    std::ofstream out_file(out_f, std::ios::binary);&#xA;    if (!out_file) {&#xA;        throw std::runtime_error("Failed to open output file.");&#xA;    }&#xA;&#xA;    if (!(format_ctx->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        if (avio_open(&amp;format_ctx->pb, out_f.c_str(), AVIO_FLAG_WRITE) &lt; 0) {&#xA;            throw std::runtime_error("Could not open output file.");&#xA;        }&#xA;    }&#xA;&#xA;    // Write file header&#xA;    if (avformat_write_header(format_ctx, nullptr) &lt; 0) {&#xA;        throw std::runtime_error("Error occurred when opening output file.");&#xA;    }&#xA;&#xA;    // Initialize packet&#xA;    pkt = av_packet_alloc();&#xA;    if (!pkt) {&#xA;        throw std::runtime_error("Could not allocate AVPacket.");&#xA;    }&#xA;&#xA;    // Initialize frame&#xA;    frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        throw std::runtime_error("Could not allocate AVFrame.");&#xA;    }&#xA;    frame->nb_samples = codec_ctx->frame_size;&#xA;    frame->format = codec_ctx->sample_fmt;&#xA;    frame->ch_layout = codec_ctx->ch_layout;&#xA;&#xA;    // Allocate data buffer&#xA;    if (av_frame_get_buffer(frame, 0) &lt; 0) {&#xA;        throw std::runtime_error("Could not allocate audio data buffers.");&#xA;    }&#xA;&#xA;    // Initialize SwrContext for resampling&#xA;    if (!swr_ctx) {&#xA;        throw std::runtime_error("Could not allocate SwrContext.");&#xA;    }&#xA;&#xA;    // Set input and output options&#xA;    av_opt_set_chlayout(swr_ctx, "in_chlayout", &amp;codec_ctx->ch_layout, 0);&#xA;    av_opt_set_chlayout(swr_ctx, "out_chlayout", &amp;codec_ctx->ch_layout, 0);&#xA;    av_opt_set_int(swr_ctx, "in_sample_rate", codec_ctx->sample_rate, 0);&#xA;    av_opt_set_int(swr_ctx, "out_sample_rate", codec_ctx->sample_rate, 0);&#xA;    av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", codec_ctx->sample_fmt, 0);&#xA;    av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", codec_ctx->sample_fmt, 0);&#xA;&#xA;    // Initialize the resampling context&#xA;    if (swr_init(swr_ctx) &lt; 0) {&#xA;        throw std::runtime_error("Failed to initialize SwrContext.");&#xA;    }&#xA;&#xA;    // Allocate buffer for resampled data&#xA;    int samples_read = 0;&#xA;    int total_samples = data_.size() / (av_get_bytes_per_sample(codec_ctx->sample_fmt) * codec_ctx->ch_layout.nb_channels);&#xA;&#xA;    int num_channels = codec_ctx->ch_layout.nb_channels;&#xA;    int bytes_per_sample = av_get_bytes_per_sample(codec_ctx->sample_fmt);&#xA;    int buffer_size = codec_ctx->frame_size * num_channels * bytes_per_sample;&#xA;    uint8_t* resampled_data = (uint8_t*)av_malloc(buffer_size);&#xA;    if (!resampled_data) {&#xA;        throw std::runtime_error("Could not allocate buffer for resampled data.");&#xA;    }&#xA;&#xA;    // Set up buffer pointers for swr_convert&#xA;    uint8_t* resampled_data_array[2] = { nullptr, nullptr };&#xA;    for (int i = 0; i &lt; num_channels; &#x2B;&#x2B;i) {&#xA;        resampled_data_array[i] = resampled_data &#x2B; i * codec_ctx->frame_size * bytes_per_sample;&#xA;    }&#xA;&#xA;    while (samples_read &lt; total_samples) {&#xA;        if (av_frame_make_writable(frame) &lt; 0) {&#xA;            throw std::runtime_error("Frame not writable.");&#xA;        }&#xA;&#xA;        int num_samples = std::min(codec_ctx->frame_size, total_samples - samples_read);&#xA;&#xA;        if (av_sample_fmt_is_planar(codec_ctx->sample_fmt)) {&#xA;            for (int ch = 0; ch &lt; num_channels; &#x2B;&#x2B;ch) {&#xA;                int channel_size = num_samples * bytes_per_sample;&#xA;                std::memcpy(frame->data[ch],&#xA;                    data_.data() &#x2B; (samples_read * bytes_per_sample * num_channels) &#x2B; (ch * channel_size),&#xA;                    channel_size);&#xA;            }&#xA;        }&#xA;        else {&#xA;            int buffer_size = num_samples * bytes_per_sample * num_channels;&#xA;            std::memcpy(frame->data[0],&#xA;                data_.data() &#x2B; samples_read * bytes_per_sample * num_channels,&#xA;                buffer_size);&#xA;        }&#xA;&#xA;        // Resample audio data&#xA;        int output_samples = av_rescale_rnd(swr_get_delay(swr_ctx, codec_ctx->sample_rate) &#x2B; frame->nb_samples,&#xA;            codec_ctx->sample_rate, codec_ctx->sample_rate, AV_ROUND_UP);&#xA;        int converted_samples = swr_convert(swr_ctx, resampled_data_array, output_samples,&#xA;            (const uint8_t**)frame->data, frame->nb_samples);&#xA;&#xA;        if (converted_samples &lt; 0) {&#xA;            av_free(resampled_data);&#xA;            throw std::runtime_error("Error converting audio samples.");&#xA;        }&#xA;&#xA;        // Send the frame for encoding&#xA;        if (avcodec_send_frame(codec_ctx, frame) &lt; 0) {&#xA;            av_free(resampled_data);&#xA;            throw std::runtime_error("Error sending frame for encoding.");&#xA;        }&#xA;&#xA;        // Receive and write packets&#xA;        while (avcodec_receive_packet(codec_ctx, pkt) >= 0) {&#xA;            out_file.write(reinterpret_cast(pkt->data), pkt->size);&#xA;            av_packet_unref(pkt);&#xA;        }&#xA;&#xA;        samples_read &#x2B;= num_samples;&#xA;&#xA;        // If the frame is partially filled, pad the remaining part with zeros&#xA;        if (num_samples &lt; codec_ctx->frame_size) {&#xA;            for (int ch = 0; ch &lt; num_channels; &#x2B;&#x2B;ch) {&#xA;                int padding_size = (codec_ctx->frame_size - num_samples) * bytes_per_sample;&#xA;                std::memset(frame->data[ch] &#x2B; num_samples * bytes_per_sample, 0, padding_size);&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    // Flush the encoder&#xA;    if (avcodec_send_frame(codec_ctx, nullptr) &lt; 0) {&#xA;        av_free(resampled_data);&#xA;        throw std::runtime_error("Error flushing the encoder.");&#xA;    }&#xA;&#xA;    while (avcodec_receive_packet(codec_ctx, pkt) >= 0) {&#xA;        out_file.write(reinterpret_cast(pkt->data), pkt->size);&#xA;        av_packet_unref(pkt);&#xA;    }&#xA;&#xA;    // Write file trailer&#xA;    av_write_trailer(format_ctx);&#xA;&#xA;    // Cleanup&#xA;    av_frame_free(&amp;frame);&#xA;    av_packet_free(&amp;pkt);&#xA;    av_free(resampled_data);&#xA;    swr_free(&amp;swr_ctx);&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;&#xA;    if (!(format_ctx->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        avio_closep(&amp;format_ctx->pb);&#xA;    }&#xA;    avformat_free_context(format_ctx);&#xA;&#xA;    out_file.close();&#xA;    return out_file;&#xA;}&#xA;&#xA;&#xA;</const></char>

    &#xA;

    I have no run time error but i see this message in console :

    &#xA;

    [file @ 0000025906626100] Setting default whitelist &#x27;file,crypto,data&#x27;&#xA;[SWR @ 0000025906632040] Using s16p internally between filters&#xA;[libmp3lame @ 0000025906609b00] Trying to remove 47 more samples than there are in the queue&#xA;[AVIOContext @ 0000025906608540] Statistics: 566 bytes written, 0 seeks, 1 writeouts&#xA;

    &#xA;

    I can play the exported mp3 file but there is sound distortion.

    &#xA;

  • C++ ffmpeg lib version 7.0 - noice in exported audio

    2 septembre 2024, par Chris P

    I want to make a C++ lib named cppdub which will mimic the python module pydub.

    &#xA;

    One main function is to export the AudioSegment to a file with a specific format (example : mp3).

    &#xA;

    The code is :

    &#xA;

    AudioSegment AudioSegment::from_file(const std::string&amp; file_path, const std::string&amp; format, const std::string&amp; codec,&#xA;    const std::map&amp; parameters, int start_second, int duration) {&#xA;&#xA;    avformat_network_init();&#xA;    av_log_set_level(AV_LOG_ERROR); // Adjust logging level as needed&#xA;&#xA;    AVFormatContext* format_ctx = nullptr;&#xA;    if (avformat_open_input(&amp;format_ctx, file_path.c_str(), nullptr, nullptr) != 0) {&#xA;        std::cerr &lt;&lt; "Error: Could not open audio file." &lt;&lt; std::endl;&#xA;        return AudioSegment();  // Return an empty AudioSegment on failure&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(format_ctx, nullptr) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error: Could not find stream information." &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    int audio_stream_index = -1;&#xA;    for (unsigned int i = 0; i &lt; format_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            audio_stream_index = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    if (audio_stream_index == -1) {&#xA;        std::cerr &lt;&lt; "Error: Could not find audio stream." &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    AVCodecParameters* codec_par = format_ctx->streams[audio_stream_index]->codecpar;&#xA;    const AVCodec* my_codec = avcodec_find_decoder(codec_par->codec_id);&#xA;    AVCodecContext* codec_ctx = avcodec_alloc_context3(my_codec);&#xA;&#xA;    if (avcodec_parameters_to_context(codec_ctx, codec_par) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error: Could not initialize codec context." &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    if (avcodec_open2(codec_ctx, my_codec, nullptr) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error: Could not open codec." &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    SwrContext* swr_ctx = swr_alloc();&#xA;    if (!swr_ctx) {&#xA;        std::cerr &lt;&lt; "Error: Could not allocate SwrContext." &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    av_opt_set_chlayout(swr_ctx, "in_chlayout", &amp;codec_ctx->ch_layout, 0);&#xA;    av_opt_set_int(swr_ctx, "in_sample_rate", codec_ctx->sample_rate, 0);&#xA;    av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", codec_ctx->sample_fmt, 0);&#xA;&#xA;    AVChannelLayout dst_ch_layout;&#xA;    av_channel_layout_copy(&amp;dst_ch_layout, &amp;codec_ctx->ch_layout);&#xA;    av_channel_layout_uninit(&amp;dst_ch_layout);&#xA;    av_channel_layout_default(&amp;dst_ch_layout, 2);&#xA;&#xA;    av_opt_set_chlayout(swr_ctx, "out_chlayout", &amp;dst_ch_layout, 0);&#xA;    av_opt_set_int(swr_ctx, "out_sample_rate", 48000, 0);&#xA;    av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);&#xA;&#xA;    if (swr_init(swr_ctx) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error: Failed to initialize the resampling context" &lt;&lt; std::endl;&#xA;        swr_free(&amp;swr_ctx);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    AVPacket packet;&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        std::cerr &lt;&lt; "Error: Could not allocate frame." &lt;&lt; std::endl;&#xA;        swr_free(&amp;swr_ctx);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_close_input(&amp;format_ctx);&#xA;        return AudioSegment();&#xA;    }&#xA;&#xA;    std::vector<char> output;&#xA;    while (av_read_frame(format_ctx, &amp;packet) >= 0) {&#xA;        if (packet.stream_index == audio_stream_index) {&#xA;            if (avcodec_send_packet(codec_ctx, &amp;packet) == 0) {&#xA;                while (avcodec_receive_frame(codec_ctx, frame) == 0) {&#xA;                    if (frame->pts != AV_NOPTS_VALUE) {&#xA;                        frame->pts = av_rescale_q(frame->pts, codec_ctx->time_base, format_ctx->streams[audio_stream_index]->time_base);&#xA;                    }&#xA;&#xA;                    uint8_t* output_buffer;&#xA;                    int output_samples = av_rescale_rnd(&#xA;                        swr_get_delay(swr_ctx, codec_ctx->sample_rate) &#x2B; frame->nb_samples,&#xA;                        48000, codec_ctx->sample_rate, AV_ROUND_UP);&#xA;&#xA;                    int output_buffer_size = av_samples_get_buffer_size(&#xA;                        nullptr, 2, output_samples, AV_SAMPLE_FMT_S16, 1);&#xA;&#xA;                    output_buffer = (uint8_t*)av_malloc(output_buffer_size);&#xA;&#xA;                    if (output_buffer) {&#xA;                        memset(output_buffer, 0, output_buffer_size); // Zero padding to avoid random noise&#xA;                        int converted_samples = swr_convert(swr_ctx, &amp;output_buffer, output_samples,&#xA;                            (const uint8_t**)frame->extended_data, frame->nb_samples);&#xA;&#xA;                        if (converted_samples >= 0) {&#xA;                            output.insert(output.end(), output_buffer, output_buffer &#x2B; output_buffer_size);&#xA;                        }&#xA;                        else {&#xA;                            std::cerr &lt;&lt; "Error: Failed to convert audio samples." &lt;&lt; std::endl;&#xA;                        }&#xA;&#xA;                        av_free(output_buffer);&#xA;                    }&#xA;                    else {&#xA;                        std::cerr &lt;&lt; "Error: Could not allocate output buffer." &lt;&lt; std::endl;&#xA;                    }&#xA;                }&#xA;            }&#xA;            else {&#xA;                std::cerr &lt;&lt; "Error: Failed to send packet to codec context." &lt;&lt; std::endl;&#xA;            }&#xA;        }&#xA;        av_packet_unref(&amp;packet);&#xA;    }&#xA;&#xA;    av_frame_free(&amp;frame);&#xA;    swr_free(&amp;swr_ctx);&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;    avformat_close_input(&amp;format_ctx);&#xA;&#xA;    std::map metadata = {&#xA;        {"sample_width", 2},&#xA;        {"frame_rate", 48000},&#xA;        {"channels", 2},&#xA;        {"frame_width", 4}&#xA;    };&#xA;&#xA;    return AudioSegment(static_cast<const>(output.data()), output.size(), metadata);&#xA;}&#xA;&#xA;&#xA;std::ofstream AudioSegment::export_segment(std::string&amp; out_f,&#xA;    const std::string&amp; format,&#xA;    const std::string&amp; codec,&#xA;    const std::string&amp; bitrate,&#xA;    const std::vector&amp; parameters,&#xA;    const std::map&amp; tags,&#xA;    const std::string&amp; id3v2_version,&#xA;    const std::string&amp; cover) {&#xA;    av_log_set_level(AV_LOG_DEBUG);&#xA;    AVCodecContext* codec_ctx = nullptr;&#xA;    AVFormatContext* format_ctx = nullptr;&#xA;    AVStream* stream = nullptr;&#xA;    AVFrame* frame = nullptr;&#xA;    AVPacket* pkt = nullptr;&#xA;    int ret;&#xA;&#xA;    // Open output file&#xA;    std::ofstream out_file(out_f, std::ios::binary);&#xA;    if (!out_file) {&#xA;        throw std::runtime_error("Failed to open output file.");&#xA;    }&#xA;&#xA;    // Initialize format context&#xA;    avformat_alloc_output_context2(&amp;format_ctx, nullptr, format.c_str(), out_f.c_str());&#xA;    if (!format_ctx) {&#xA;        throw std::runtime_error("Could not allocate format context.");&#xA;    }&#xA;&#xA;    // Find encoder&#xA;    const AVCodec* codec_ptr = avcodec_find_encoder_by_name(codec.c_str());&#xA;    if (!codec_ptr) {&#xA;        throw std::runtime_error("Codec not found.");&#xA;    }&#xA;&#xA;    // Add stream&#xA;    stream = avformat_new_stream(format_ctx, codec_ptr);&#xA;    if (!stream) {&#xA;        throw std::runtime_error("Failed to create new stream.");&#xA;    }&#xA;&#xA;    // Allocate codec context&#xA;    codec_ctx = avcodec_alloc_context3(codec_ptr);&#xA;    if (!codec_ctx) {&#xA;        throw std::runtime_error("Could not allocate audio codec context.");&#xA;    }&#xA;&#xA;    // Set codec parameters&#xA;    codec_ctx->bit_rate = std::stoi(bitrate);&#xA;    codec_ctx->sample_fmt = codec_ptr->sample_fmts ? codec_ptr->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;&#xA;    codec_ctx->sample_rate = frame_rate_;&#xA;    codec_ctx->ch_layout.nb_channels = this->get_channels();&#xA;    AVChannelLayout ch_layout_1;&#xA;    av_channel_layout_uninit(&amp;ch_layout_1);&#xA;    av_channel_layout_default(&amp;ch_layout_1, this->get_channels());&#xA;    codec_ctx->ch_layout = ch_layout_1;&#xA;&#xA;    // Open codec&#xA;    ret = avcodec_open2(codec_ctx, codec_ptr, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        throw std::runtime_error("Could not open codec.");&#xA;    }&#xA;&#xA;    // Initialize packet&#xA;    pkt = av_packet_alloc();&#xA;    if (!pkt) {&#xA;        throw std::runtime_error("Could not allocate AVPacket.");&#xA;    }&#xA;&#xA;    // Initialize frame&#xA;    frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        throw std::runtime_error("Could not allocate AVFrame.");&#xA;    }&#xA;&#xA;    frame->nb_samples = codec_ctx->frame_size;&#xA;    frame->format = codec_ctx->sample_fmt;&#xA;    frame->ch_layout = codec_ctx->ch_layout;&#xA;    frame->sample_rate = codec_ctx->sample_rate;&#xA;&#xA;    // Allocate data buffer&#xA;    ret = av_frame_get_buffer(frame, 0);&#xA;    if (ret &lt; 0) {&#xA;        throw std::runtime_error("Could not allocate audio data buffers.");&#xA;    }&#xA;&#xA;    // Encode frames&#xA;    int samples_read = 0;&#xA;    while (samples_read &lt; data_.size()) {&#xA;        ret = av_frame_make_writable(frame);&#xA;        if (ret &lt; 0) {&#xA;            throw std::runtime_error("Frame not writable.");&#xA;        }&#xA;&#xA;        // Determine the number of samples to copy into the frame&#xA;        int frame_size = std::min<int>(codec_ctx->frame_size, (data_.size() - samples_read) / frame_width_);&#xA;        int buffer_size = frame_size * frame_width_;&#xA;&#xA;        // Clear the frame data to avoid artifacts from previous data&#xA;        std::memset(frame->data[0], 0, codec_ctx->frame_size * frame_width_);&#xA;&#xA;        // Copy the actual audio data into the frame&#xA;        std::memcpy(frame->data[0], data_.data() &#x2B; samples_read, buffer_size);&#xA;        samples_read &#x2B;= buffer_size;&#xA;&#xA;        // If the frame is partially filled, pad the remaining part with zeros&#xA;        if (frame_size &lt; codec_ctx->frame_size) {&#xA;            std::memset(frame->data[0] &#x2B; buffer_size, 0, (codec_ctx->frame_size - frame_size) * frame_width_);&#xA;        }&#xA;&#xA;        // Send the frame for encoding&#xA;        ret = avcodec_send_frame(codec_ctx, frame);&#xA;        if (ret &lt; 0) {&#xA;            throw std::runtime_error("Error sending frame for encoding.");&#xA;        }&#xA;&#xA;        // Receive and write packets&#xA;        while (ret >= 0) {&#xA;            ret = avcodec_receive_packet(codec_ctx, pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;                break;&#xA;            }&#xA;            else if (ret &lt; 0) {&#xA;                throw std::runtime_error("Error encoding frame.");&#xA;            }&#xA;&#xA;            out_file.write(reinterpret_cast(pkt->data), pkt->size);&#xA;            av_packet_unref(pkt);&#xA;        }&#xA;    }&#xA;&#xA;    // **Explicitly flush the encoder**&#xA;    ret = avcodec_send_frame(codec_ctx, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        throw std::runtime_error("Error flushing the encoder.");&#xA;    }&#xA;&#xA;    // Receive and write remaining packets after flushing&#xA;    while (ret >= 0) {&#xA;        ret = avcodec_receive_packet(codec_ctx, pkt);&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;            break;&#xA;        }&#xA;        else if (ret &lt; 0) {&#xA;            throw std::runtime_error("Error encoding frame during flush.");&#xA;        }&#xA;&#xA;        out_file.write(reinterpret_cast(pkt->data), pkt->size);&#xA;        av_packet_unref(pkt);&#xA;    }&#xA;&#xA;    // Cleanup&#xA;    av_frame_free(&amp;frame);&#xA;    av_packet_free(&amp;pkt);&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;    avformat_free_context(format_ctx);&#xA;&#xA;    return out_file;&#xA;}&#xA;</int></const></char>

    &#xA;

    I have no run time error but i see this message in console :

    &#xA;

    [libmp3lame @ 000002d26b239ac0] Trying to remove 47 more samples than there are in the queue&#xA;

    &#xA;

    I can play the exported mp3 file but there is background noise.

    &#xA;

  • C++ ffmpeg lib version 7.0 - runtime error

    1er septembre 2024, par Chris P

    I want to make a C++ lib named cppdub which will mimic the python module pydub.

    &#xA;

    One main function is to export the AudioSegment to a file with a specific format (example : mp3).

    &#xA;

    The code is :

    &#xA;

    void check_av_error(int error_code, const std::string&amp; msg) {&#xA;    if (error_code &lt; 0) {&#xA;        char errbuf[AV_ERROR_MAX_STRING_SIZE];&#xA;        av_strerror(error_code, errbuf, sizeof(errbuf));&#xA;        throw std::runtime_error(msg &#x2B; ": " &#x2B; errbuf);&#xA;    }&#xA;}&#xA;&#xA;std::string av_err2str_(int errnum) {&#xA;    char buf[AV_ERROR_MAX_STRING_SIZE];&#xA;    av_strerror(errnum, buf, sizeof(buf));&#xA;    return std::string(buf);&#xA;}&#xA;&#xA;void log_error(const std::string&amp; msg) {&#xA;    std::cerr &lt;&lt; "Error: " &lt;&lt; msg &lt;&lt; std::endl;&#xA;}&#xA;&#xA;std::ofstream cppdub::AudioSegment::export_segment(&#xA;    std::string&amp; out_f,&#xA;    const std::string&amp; format,&#xA;    const std::string&amp; codec,&#xA;    const std::string&amp; bitrate,&#xA;    const std::vector&amp; parameters,&#xA;    const std::map&amp; tags,&#xA;    const std::string&amp; id3v2_version,&#xA;    const std::string&amp; cover) {&#xA;&#xA;    av_log_set_level(AV_LOG_DEBUG);&#xA;    avformat_network_init();&#xA;&#xA;    AVFormatContext* format_ctx = nullptr;&#xA;    int ret = avformat_alloc_output_context2(&amp;format_ctx, nullptr, format.c_str(), out_f.c_str());&#xA;    check_av_error(ret, "Could not allocate format context");&#xA;&#xA;    if (!(format_ctx->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        ret = avio_open(&amp;format_ctx->pb, out_f.c_str(), AVIO_FLAG_WRITE);&#xA;        check_av_error(ret, "Could not open output file");&#xA;    }&#xA;&#xA;    AVStream* stream = avformat_new_stream(format_ctx, nullptr);&#xA;    if (!stream) {&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Could not allocate stream");&#xA;    }&#xA;&#xA;    const AVCodec* codec_obj = avcodec_find_encoder_by_name(codec.c_str());&#xA;    if (!codec_obj) {&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Codec not found");&#xA;    }&#xA;&#xA;    AVCodecContext* codec_ctx = avcodec_alloc_context3(codec_obj);&#xA;    if (!codec_ctx) {&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Could not allocate codec context");&#xA;    }&#xA;&#xA;    codec_ctx->sample_rate = this->get_frame_rate();&#xA;    AVChannelLayout ch_layout_1;&#xA;    av_channel_layout_uninit(&amp;ch_layout_1);&#xA;    av_channel_layout_default(&amp;ch_layout_1, 2);&#xA;    codec_ctx->ch_layout = ch_layout_1; // Adjust based on your needs&#xA;    codec_ctx->bit_rate = std::stoi(bitrate);&#xA;    codec_ctx->sample_fmt = codec_obj->sample_fmts[0];&#xA;&#xA;    if (format_ctx->oformat->flags &amp; AVFMT_GLOBALHEADER) {&#xA;        codec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    }&#xA;&#xA;    ret = avcodec_open2(codec_ctx, codec_obj, nullptr);&#xA;    check_av_error(ret, "Could not open codec");&#xA;&#xA;    stream->time_base = { 1, codec_ctx->sample_rate };&#xA;    ret = avcodec_parameters_from_context(stream->codecpar, codec_ctx);&#xA;    check_av_error(ret, "Could not set codec parameters");&#xA;&#xA;    ret = avformat_write_header(format_ctx, nullptr);&#xA;    check_av_error(ret, "Error occurred when writing header");&#xA;&#xA;    AVPacket pkt;&#xA;    av_init_packet(&amp;pkt);&#xA;    pkt.data = nullptr;&#xA;    pkt.size = 0;&#xA;&#xA;    int frame_size = av_samples_get_buffer_size(nullptr, codec_ctx->ch_layout.nb_channels,&#xA;        codec_ctx->frame_size, codec_ctx->sample_fmt, 0);&#xA;    check_av_error(frame_size, "Could not calculate frame size");&#xA;&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Error allocating frame");&#xA;    }&#xA;&#xA;    frame->format = codec_ctx->sample_fmt;&#xA;    frame->ch_layout = codec_ctx->ch_layout;&#xA;    frame->sample_rate = codec_ctx->sample_rate;&#xA;    frame->nb_samples = codec_ctx->frame_size;&#xA;&#xA;    ret = av_frame_get_buffer(frame, 0);&#xA;    if (ret &lt; 0) {&#xA;        av_frame_free(&amp;frame);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Error allocating frame buffer: " &#x2B; av_err2str_(ret));&#xA;    }&#xA;&#xA;    size_t data_offset = 0;&#xA;&#xA;    while (data_offset &lt; this->raw_data().size()) {&#xA;        int samples_to_process = std::min(frame_size, static_cast<int>(this->raw_data().size()) - static_cast<int>(data_offset));&#xA;&#xA;        // Fill the frame with audio data&#xA;        ret = avcodec_fill_audio_frame(frame, codec_ctx->ch_layout.nb_channels, codec_ctx->sample_fmt,&#xA;            reinterpret_cast<const>(this->raw_data().data()) &#x2B; data_offset,&#xA;            samples_to_process, 0);&#xA;        if (ret &lt; 0) {&#xA;            log_error("Error filling audio frame: " &#x2B; av_err2str_(ret));&#xA;            av_frame_free(&amp;frame);&#xA;            avcodec_free_context(&amp;codec_ctx);&#xA;            avformat_free_context(format_ctx);&#xA;            throw std::runtime_error("Error filling audio frame: " &#x2B; av_err2str_(ret));&#xA;        }&#xA;&#xA;        data_offset &#x2B;= samples_to_process;&#xA;&#xA;        ret = avcodec_send_frame(codec_ctx, frame);&#xA;        if (ret &lt; 0) {&#xA;            log_error("Error sending frame for encoding: " &#x2B; av_err2str_(ret));&#xA;            av_frame_free(&amp;frame);&#xA;            avcodec_free_context(&amp;codec_ctx);&#xA;            avformat_free_context(format_ctx);&#xA;            throw std::runtime_error("Error sending frame for encoding: " &#x2B; av_err2str_(ret));&#xA;        }&#xA;&#xA;        while (ret >= 0) {&#xA;            ret = avcodec_receive_packet(codec_ctx, &amp;pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;                break;&#xA;            }&#xA;            check_av_error(ret, "Error receiving packet");&#xA;&#xA;            pkt.stream_index = stream->index;&#xA;&#xA;            ret = av_interleaved_write_frame(format_ctx, &amp;pkt);&#xA;            check_av_error(ret, "Error writing encoded frame to output file");&#xA;&#xA;            av_packet_unref(&amp;pkt);&#xA;        }&#xA;    }&#xA;&#xA;    // Flush the encoder&#xA;    avcodec_send_frame(codec_ctx, nullptr);&#xA;    while (avcodec_receive_packet(codec_ctx, &amp;pkt) == 0) {&#xA;        pkt.stream_index = stream->index;&#xA;        av_interleaved_write_frame(format_ctx, &amp;pkt);&#xA;        av_packet_unref(&amp;pkt);&#xA;    }&#xA;&#xA;    av_write_trailer(format_ctx);&#xA;&#xA;    av_frame_free(&amp;frame);&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;    avformat_free_context(format_ctx);&#xA;&#xA;    return std::ofstream(out_f, std::ios::binary);&#xA;}&#xA;</const></int></int>

    &#xA;

    The runtime error is :

    &#xA;

    Exception thrown at 0x00007FF945137C9B (avcodec-61.dll) in cppdub_test.exe : 0xC0000005 : Access violation reading location 0x0000024CBCD25080.

    &#xA;

    for line :

    &#xA;

        ret = avcodec_send_frame(codec_ctx, frame);&#xA;

    &#xA;

    Call stack :

    &#xA;

        avcodec-61.dll!00007ff945137c9b()   Unknown&#xA;    avcodec-61.dll!00007ff9451381bb()   Unknown&#xA;    avcodec-61.dll!00007ff945139679()   Unknown&#xA;    avcodec-61.dll!00007ff94371521d()   Unknown&#xA;    avcodec-61.dll!00007ff9434a80c2()   Unknown&#xA;    avcodec-61.dll!00007ff9434a84a6()   Unknown&#xA;    avcodec-61.dll!00007ff9434a8749()   Unknown&#xA;>   cppdub_test.exe!cppdub::AudioSegment::export_segment(std::string &amp; out_f, const std::string &amp; format, const std::string &amp; codec, const std::string &amp; bitrate, const std::vector> &amp; parameters, const std::map,std::allocator>> &amp; tags, const std::string &amp; id3v2_version, const std::string &amp; cover) Line 572  C&#x2B;&#x2B;&#xA;    cppdub_test.exe!main() Line 33  C&#x2B;&#x2B;&#xA;    [External Code] &#xA;&#xA;

    &#xA;

    Autos :

    &#xA;

    &#x2B;       this    0x000000d3a08ff690 {data_="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0... ...} cppdub::AudioSegment *&#xA;&#x2B;       bitrate "128000"    const std::string &amp;&#xA;&#x2B;       ch_layout_1 {order=AV_CHANNEL_ORDER_NATIVE (1) nb_channels=2 u={mask=3 map=0x0000000000000003 {id=??? name=... opaque=...} } ...}   AVChannelLayout&#xA;&#x2B;       codec   "libmp3lame"    const std::string &amp;&#xA;&#x2B;       codec_ctx   0x0000024cbc78c240 {av_class=avcodec-61.dll!0x00007ff94789c760 {class_name=0x00007ff94789c740 "AVCodecContext" ...} ...}    AVCodecContext *&#xA;&#x2B;       codec_obj   avcodec-61.dll!0x00007ff9477fa4c0 (load symbols for additional information) {name=0x00007ff9477fa47c "libmp3lame" ...}  const AVCodec *&#xA;&#x2B;       cover   ""  const std::string &amp;&#xA;        data_offset 9216    unsigned __int64&#xA;&#x2B;       format  "mp3"   const std::string &amp;&#xA;&#x2B;       format_ctx  0x0000024cbc788a40 {av_class=avformat-61.dll!0x00007ff99eb09fe0 {class_name=0x00007ff99eb09fc0 "AVFormatContext" ...} ...}  AVFormatContext *&#xA;&#x2B;       frame   0x0000024cbc787380 {data=0x0000024cbc787380 {0x0000024cbcd25080 <error reading="reading" characters="characters" of="of">, ...} ...}    AVFrame *&#xA;        frame_size  9216    int&#xA;&#x2B;       id3v2_version   "4" const std::string &amp;&#xA;&#x2B;       out_f   "ha-ha-ha.mp3"  std::string &amp;&#xA;&#x2B;       parameters  { size=0 }  const std::vector> &amp;&#xA;&#x2B;       pkt {buf=0x0000000000000000 <null> pts=-9223372036854775808 dts=-9223372036854775808 ...}   AVPacket&#xA;        ret 9216    int&#xA;        samples_to_process  9216    int&#xA;&#x2B;       stream  0x0000024cbc789bc0 {av_class=avformat-61.dll!0x00007ff99eb09840 {class_name=0x00007ff99eb09820 "AVStream" ...} ...} AVStream *&#xA;&#x2B;       tags    { size=0 }  const std::map,std::allocator>> &amp;&#xA;</null></error>

    &#xA;