Recherche avancée

Médias (91)

Autres articles (29)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

  • MediaSPIP Core : La Configuration

    9 novembre 2010, par

    MediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
    Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)

Sur d’autres sites (4594)

  • How to adjust audio volume with AVFilter API from FFmpeg in Linux ?

    20 décembre 2024, par wangt13

    I am working on an embedded Linux system (kernel-5.10.24), and developing an audio player by using FFmpeg and ALSA libraries.

    


    Now the basic functions are done, and I can play MP3 file by using AVCodec and SWresample interfaces of FFmpeg.

    


    int decode_play(void)
{
    .....
    while (1) {
        if (av_read_frame(pfmtctx, packet) < 0) {
            avcodec_flush_buffers(pcodectx);
            printf("Got end of media, breaking\n");
            break;
        }
        if (packet->stream_index != stream) {
            continue;
        }
        int res = avcodec_send_packet(pcodectx, packet);
        if (res < 0) {
            printf("Error in decoding audio frame.\n");
            break;
        }

        while (res >= 0) {
            res = avcodec_receive_frame(pcodectx, pframe);
            if (res == AVERROR(EAGAIN)) {
                break;
            } else if (res == AVERROR_EOF) {
                break;
            } else if (res >= 0) {
                int outsamples = swr_convert(swrctx, &buf, pcodectx->frame_size, (const uint8_t **)pframe->data, pframe->nb_samples);
                snd_pcm_write(pcm_handle, buf, outsamples);
            }
        }
    }
}


    


    Now, I want to add volume changing to this audio player.
    
I found that there is AVfilter functions in FFmpeg, which can be used to adjust audio's volume. How can I use it in current design ?
I am not sure what filters should I use, and where should I plugin the filters ?
Should I put the filters before swr_convert or after the swr_convert ?

    


    With Erdal's help, I changed the player as follows,

    


    int decode_play(void)
{
    /* Init filter graph as filter_audio.c does */
    init_filter_graph(&graph, &src, &sink);

    while (1) {
        if (av_read_frame(pfmtctx, packet) < 0) {
            avcodec_flush_buffers(pcodectx);
            printf("Got end of media, breaking\n");
            break;
        }
        if (packet->stream_index != stream) {
            continue;
        }
        int res = avcodec_send_packet(pcodectx, packet);
        if (res < 0) {
            printf("Error in decoding audio frame.\n");
            break;
        }

        while (res >= 0) {
            res = avcodec_receive_frame(pcodectx, pframe);
            if (res == AVERROR(EAGAIN)) {
                break;
            } else if (res == AVERROR_EOF) {
                break;
            } else if (res >= 0) {
                int ret = av_buffersrc_add_frame(src, pframe);
                if (ret < 0) {
                    continue;
                }
                while ((ret = av_buffersink_get_frame(sink, filt_frame)) >= 0) {
                    int nb_samples = av_rescale_rnd(filt_frame->nb_samples, RESAMPLE_SAMPLE_RATE, filt_frame->sample_rate, AV_ROUND_UP);
                    printf("nb_samples: %d, f.nb_sample: %d, f.sr: %d\n", nb_samples, filt_frame->nb_samples, filt_frame->sample_rate);

                    int outs = snd_pcm_writei(playback_handle, filt_frame->extended_data[0], nb_samples);
                    if (outs < 0) {
                        snd_pcm_prepare(playback_handle);
                    }
                }
            }
        }
    }
}


    


    The original audio in format of 44100 Hz, stereo, fltp. And I chose to use aformat to do resampling instead of swresample as follows.

    


        snprintf(options_str, sizeof(options_str),
            "sample_fmts=%s:sample_rates=%d:channel_layouts=stereo",
            av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 32000);
    if (avfilter_init_str(aformat_ctx, options_str) < 0) {
        printf("error init aformat filter");
        return -1;
    }


    


    I succeeded playing the resampled audio with Avfilter.

    


  • avcodec/svq1dec : Add assert to ensure "stages >= 0"

    3 février 2015, par Michael Niedermayer
    avcodec/svq1dec : Add assert to ensure "stages >= 0"
    

    This is currently always true, the assert protects against
    future changes to the code breaking this assumtation

    Signed-off-by : Michael Niedermayer <michaelni@gmx.at>

    • [DH] libavcodec/svq1dec.c
  • lavfi : Move new field to the end of AVFilterLink

    29 juin 2016, par Timo Rothenpieler
    lavfi : Move new field to the end of AVFilterLink
    

    Even though this is not part of the public API, some external
    applications access fields after it, thus breaking after updating from
    ffmpeg 3.0 or earlier.
    Since it is not public, it can be freely moved to the end to avoid
    that problem in the future.

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

    • [DH] libavfilter/avfilter.h