Recherche avancée

Médias (1)

Mot : - Tags -/musée

Autres articles (73)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

Sur d’autres sites (7771)

  • Stuttering rendering using ffmpeg and sdl2

    22 décembre 2020, par Wiesen_Walle

    With the following Code I get a stuttering rendering of the movie file. Interesstingly, when dumping information with ffmpeg it says it has 25 fps and a duration of 00:01:32.90 ; however when counting the frames and time it runs by myself it gives a time of about 252 seconds, I guess the code receiving the frames and sending the package (int cap(vid v)) draws the same frame multiple of times. But I cannot see what's wrong ?

    


    //PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/usr/lib64/pkgconfig/   --> add path to PKF_Config search path&#xA;//export PKG_CONFIG_PATH --> export PKG_Config search path to become visible for gcc&#xA;//gcc ffmpeg_capture_fl.c -Wall -pedantic -fPIC `pkg-config --cflags --libs libavdevice libavformat libavcodec libavutil libavdevice libavfilter libswscale libswresample sdl2`&#xA;&#xA;&#xA;#include <libavdevice></libavdevice>avdevice.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include &#xA;#include &#xA;#include <libavutil></libavutil>rational.h>&#xA;#include <sys></sys>time.h>&#xA;#include &#xA;&#xA;&#xA;typedef struct vid{&#xA;AVFormatContext *inc;&#xA;AVInputFormat *iformat;&#xA;AVCodecContext  *pCodecCtx;&#xA;AVCodec         *pCodec;&#xA;AVFrame         *pFrame;&#xA;int videoStream;} vid;&#xA;&#xA;typedef struct sws{&#xA;struct SwsContext *ctx;&#xA;uint8_t **buffer;&#xA;int *linesize;&#xA;} sws;&#xA;&#xA;&#xA;vid cap_init_fl(char *fl);&#xA;int cap(vid v);&#xA;void cap_close(vid v);&#xA;&#xA;sws init_swsctx(int width, int height, enum AVPixelFormat pix_fmt, int new_width, int new_height, enum AVPixelFormat new_pxf);&#xA;void conv_pxlformat(sws scale, uint8_t **src_data, int *src_linesize, int height);&#xA;void free_sws(sws inp);&#xA;&#xA;#include <sdl2></sdl2>SDL.h>&#xA;&#xA;typedef struct sdl_window{&#xA;    SDL_Window *window;&#xA;    SDL_Renderer *renderer;&#xA;    SDL_Texture *texture;&#xA;    SDL_Event *event;&#xA;    int width;&#xA;    int height;&#xA;    int pitch;&#xA;    uint32_t sdl_pxl_frmt;&#xA;    }sdl_window;&#xA;&#xA;sdl_window init_windowBGR24_ffmpg(int width, int height);&#xA;int render_on_texture_update(sdl_window wow, uint8_t *data);&#xA;void close_window(sdl_window wow);&#xA;&#xA;&#xA;vid cap_init_fl(char *fl){&#xA;    vid v = {NULL, NULL, NULL, NULL, NULL, -1};&#xA;    int i;&#xA;    &#xA;    av_register_all();&#xA;    avdevice_register_all();&#xA;&#xA;    if( 0 > avformat_open_input( &amp;(v.inc), fl , v.iformat, NULL)) {&#xA;        printf("Input device could not been opened\n");&#xA;        cap_close(v);&#xA;        exit(1);&#xA;        }&#xA;&#xA;    if(avformat_find_stream_info(v.inc, NULL)&lt;0){&#xA;        printf("Stream information could not been found.\n");&#xA;        cap_close(v);&#xA;        exit(2);&#xA;    }&#xA;&#xA;    // Dump information about file onto standard error&#xA;    av_dump_format(v.inc, 0, fl, 0);&#xA;&#xA;    // Find the first video stream&#xA;    v.videoStream=-1;&#xA;    for(i=0; inb_streams; i&#x2B;&#x2B;){&#xA;      if(v.inc->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_VIDEO) {&#xA;        v.videoStream=i;&#xA;        break;&#xA;      }}&#xA;&#xA;    if(v.videoStream==-1){&#xA;        printf("Could not find video stream.\n");&#xA;        cap_close(v);&#xA;        exit(3);&#xA;        }&#xA;&#xA;    // Find the decoder for the video stream&#xA;    v.pCodec=avcodec_find_decoder(v.inc->streams[v.videoStream]->codecpar->codec_id);&#xA;        if(v.pCodec==NULL) {&#xA;          printf("Unsupported codec!\n");&#xA;        cap_close(v);&#xA;        exit(4);&#xA;           // Codec not found&#xA;        }&#xA;&#xA;    &#xA;&#xA;    // Get a pointer to the codec context for the video stream&#xA;    &#xA;    if((v.pCodecCtx=avcodec_alloc_context3(NULL)) == NULL){&#xA;        printf("Could not allocate codec context\n");&#xA;        cap_close(v);&#xA;        exit(10);}&#xA;&#xA;    avcodec_parameters_to_context (v.pCodecCtx, v.inc->streams[v.videoStream]->codecpar);       &#xA;    &#xA;    // Open codec&#xA;    if(avcodec_open2(v.pCodecCtx, v.pCodec, NULL)&lt;0){&#xA;        printf("Could not open codec");&#xA;        cap_close(v);&#xA;        exit(5);&#xA;        }&#xA;        &#xA;    &#xA;    // Allocate video frame&#xA;    v.pFrame=av_frame_alloc();&#xA;    if(v.pFrame==NULL){&#xA;        printf("Could not allocate AVframe");&#xA;        cap_close(v);&#xA;        exit(6);}&#xA;&#xA;    &#xA;    return v;&#xA;}&#xA;&#xA;&#xA;&#xA;int cap(vid v){&#xA;    int errorCodeRF, errorCodeSP, errorCodeRecFR;&#xA;    AVPacket pkt;&#xA;        &#xA;    if((errorCodeRF = av_read_frame(v.inc, &amp;pkt))  >= 0){&#xA;        &#xA;        if (pkt.stream_index == v.videoStream) {&#xA;            &#xA;            errorCodeSP = avcodec_send_packet(v.pCodecCtx, &amp;pkt);&#xA;            &#xA;            if (errorCodeSP >= 0 || errorCodeSP == AVERROR(EAGAIN)){&#xA;                &#xA;                errorCodeRecFR = avcodec_receive_frame(v.pCodecCtx, v.pFrame);&#xA;                &#xA;                if (errorCodeRecFR &lt; 0){ &#xA;                    av_packet_unref(&amp;pkt);&#xA;                    return errorCodeRecFR;&#xA;                    }&#xA;                else{&#xA;                    av_packet_unref(&amp;pkt);&#xA;                    return 0;&#xA;                    }&#xA;                &#xA;                }&#xA;            else{&#xA;                 av_packet_unref(&amp;pkt);&#xA;                 return errorCodeSP;}&#xA;                &#xA;        }}&#xA;                &#xA;    else{&#xA;        return errorCodeRF;}&#xA;        return 1;&#xA;        }&#xA;    &#xA;    &#xA;&#xA;void cap_close(vid v){&#xA;    if(v.pFrame != NULL) av_free(v.pFrame);&#xA;    avcodec_close(v.pCodecCtx);&#xA;    avformat_close_input(&amp;(v.inc));&#xA;    if(v.inc != NULL) avformat_free_context(v.inc);&#xA;    &#xA;    v.inc = NULL;&#xA;    v.iformat = NULL;&#xA;    v.pCodecCtx = NULL;&#xA;    v.pCodec = NULL;&#xA;    v.pFrame = NULL;&#xA;    v.videoStream=-1;}&#xA;&#xA;&#xA;&#xA;sws init_swsctx(int width, int height, enum AVPixelFormat pix_fmt, int new_width, int new_height, enum AVPixelFormat new_pxf){&#xA;&#xA;int nwidth, nheight;&#xA;sws scale;&#xA;&#xA;scale.buffer = (uint8_t **) malloc(4 * sizeof(uint8_t *));&#xA;scale.linesize = (int *) malloc(4 * sizeof(int));&#xA;&#xA;&#xA;nwidth = (new_width &lt;= 0) ?  width : new_width;&#xA;nheight = (new_height &lt;= 0) ?  height : new_height;&#xA;&#xA;av_image_alloc(scale.buffer, scale.linesize, nwidth, nheight, new_pxf, 1);&#xA;scale.ctx = sws_getContext(width, height, pix_fmt, nwidth, nheight, new_pxf, SWS_BILINEAR, NULL, NULL, NULL);&#xA;&#xA;if(scale.ctx==NULL){&#xA;    printf("Could not allocate SWS-Context\n");&#xA;    av_freep(&amp;(scale.buffer)[0]);&#xA;    free(scale.buffer);&#xA;    free(scale.linesize);&#xA;    exit(12);&#xA;    }&#xA;            &#xA;return scale;}&#xA;&#xA;&#xA;void conv_pxlformat(sws scale, uint8_t **src_data, int *src_linesize, int height){  &#xA;    sws_scale(scale.ctx, (const uint8_t **) src_data, src_linesize, 0, height, scale.buffer, scale.linesize);&#xA;    }&#xA;&#xA;&#xA;void free_sws(sws inp){&#xA;    av_freep(&amp;(inp.buffer)[0]);&#xA;    free(inp.buffer);&#xA;    free(inp.linesize); &#xA;}&#xA;&#xA;&#xA;sdl_window init_windowBGR24_ffmpg(int width, int height){&#xA;&#xA; sdl_window wow;&#xA;    &#xA; if (SDL_Init(SDL_INIT_VIDEO) &lt; 0) {&#xA;    printf("Couldn&#x27;t initialize SDL in function: create_sdl_window(...)\n");&#xA;    exit(7);}&#xA;    &#xA; wow.window = SDL_CreateWindow("SDL_CreateTexture",&#xA;                        SDL_WINDOWPOS_UNDEFINED,&#xA;                        SDL_WINDOWPOS_UNDEFINED,&#xA;                        width, height,&#xA;                        SDL_WINDOW_RESIZABLE);&#xA;&#xA; wow.renderer = SDL_CreateRenderer(wow.window, -1, SDL_RENDERER_ACCELERATED);&#xA; wow.texture = SDL_CreateTexture(wow.renderer, SDL_PIXELFORMAT_BGR24, SDL_TEXTUREACCESS_STREAMING, width, height);&#xA; wow.width = width;&#xA; wow.height = height;&#xA; wow.pitch = width * 3;  //only true for 3 byte / 24bit packed formats like bgr24&#xA; wow.sdl_pxl_frmt = SDL_PIXELFORMAT_BGR24;&#xA; SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); &#xA; SDL_SetHint(SDL_HINT_RENDER_VSYNC, "enable"); &#xA; SDL_RenderSetLogicalSize(wow.renderer, wow.width, wow.height);&#xA; return wow;&#xA;}&#xA;&#xA;&#xA;int render_on_texture_update(sdl_window wow, uint8_t *data){&#xA;    &#xA;    if (SDL_UpdateTexture(wow.texture, NULL, data, wow.pitch)&lt; 0){&#xA;        printf("SDL_render_on_texture_update_failed: %s\n", SDL_GetError());&#xA;        return -1;&#xA;        }&#xA;    SDL_RenderClear(wow.renderer);&#xA;    SDL_RenderCopy(wow.renderer, wow.texture, NULL, NULL);&#xA;    SDL_RenderPresent(wow.renderer);&#xA;&#xA;    return 0; &#xA;}&#xA;&#xA;&#xA;void close_window(sdl_window wow){&#xA;    SDL_DestroyRenderer(wow.renderer);&#xA;    SDL_Quit();&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;int main(){&#xA;    int n, vid_error;&#xA;    long int time_per_frame_usec, duration_usec;&#xA;    vid v;&#xA;    sdl_window wow;&#xA;    struct timeval tval_start, tval_start1, tval_end, tval_duration;&#xA;    sws scale;&#xA;    SDL_Event event;&#xA;   &#xA;    vid_error = AVERROR(EAGAIN);&#xA;    v = cap_init_fl("mw_maze_test.mp4"); &#xA;    &#xA;    while(vid_error == AVERROR(EAGAIN)){&#xA;        vid_error =cap(v);}&#xA;        &#xA;    if(vid_error &lt; 0){&#xA;        printf("Could not read from Capture\n");&#xA;        cap_close(v);&#xA;        return 0;&#xA;        }&#xA;&#xA;    wow = init_windowBGR24_ffmpg((v.pCodecCtx)->width, (v.pCodecCtx)->height);&#xA;    scale = init_swsctx((v.pCodecCtx)->width, (v.pCodecCtx)->height, (v.pCodecCtx)->pix_fmt, 0, 0, AV_PIX_FMT_BGR24);&#xA;        &#xA;    time_per_frame_usec =  ((long int)((v.inc)->streams[v.videoStream]->avg_frame_rate.den) *  1000000 / (long int) ((v.inc)->streams[v.videoStream]->avg_frame_rate.num));&#xA;    &#xA;    printf("Time per frame: %ld\n", time_per_frame_usec);&#xA;    n = 0;&#xA;    &#xA;    gettimeofday(&amp;tval_start, NULL);&#xA;    gettimeofday(&amp;tval_start1, NULL);&#xA;    &#xA;    while ((vid_error =cap(v)) >= 0) {&#xA;                &#xA;                if (SDL_PollEvent(&amp;event) != 0) {&#xA;                        if (event.type == SDL_QUIT)&#xA;                        break;}&#xA;                    &#xA;                conv_pxlformat(scale, (v.pFrame)->data, (v.pFrame)->linesize, (v.pCodecCtx)->height);&#xA;                gettimeofday(&amp;tval_end, NULL);&#xA;                timersub(&amp;tval_end, &amp;tval_start, &amp;tval_duration);&#xA;                duration_usec = (long int)tval_duration.tv_sec * 1000000 &#x2B; (long int)tval_duration.tv_usec;&#xA;                &#xA;                while(duration_usec &lt; time_per_frame_usec) {&#xA;                gettimeofday(&amp;tval_end, NULL);&#xA;                timersub(&amp;tval_end, &amp;tval_start, &amp;tval_duration);&#xA;                duration_usec = (long int)tval_duration.tv_sec * 1000000 &#x2B; (long int)tval_duration.tv_usec;&#xA;                    }&#xA;                &#xA;                gettimeofday(&amp;tval_start, NULL);&#xA;                render_on_texture_update(wow, *(scale.buffer)); &#xA;                n&#x2B;&#x2B;;&#xA;        }&#xA;  &#xA;    gettimeofday(&amp;tval_end, NULL);&#xA;    timersub(&amp;tval_end, &amp;tval_start1, &amp;tval_duration);&#xA;    duration_usec = (long int)tval_duration.tv_sec * 1000000 &#x2B; (long int)tval_duration.tv_usec;&#xA;    &#xA;    printf("Total time and frames; %ld %i\n", duration_usec, n);&#xA;    &#xA;    if(vid_error == AVERROR(EAGAIN)){&#xA;                    printf("AVERROR(EAGAIN) occured\n)");&#xA;                    }   &#xA;                &#xA;    &#xA;    sws_freeContext(scale.ctx);&#xA;    free_sws(scale);&#xA;    close_window(wow);&#xA;    cap_close(v); &#xA;    return 0;   &#xA;}&#xA;&#xA;

    &#xA;

    the output is:&#xA;&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;mw_maze_test.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: isommp42&#xA;    creation_time   : 2014-02-14T21:09:52.000000Z&#xA;  Duration: 00:01:32.90, start: 0.000000, bitrate: 347 kb/s&#xA;    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 384x288 [SAR 1:1 DAR 4:3], 249 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)&#xA;    Metadata:&#xA;      handler_name    : VideoHandler&#xA;    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2014-02-14T21:09:53.000000Z&#xA;      handler_name    : IsoMedia File Produced by Google, 5-11-2011&#xA;Time per frame: 40000&#xA;Total time and frames; 252881576 6322&#xA;&#xA;&#xA;

    &#xA;

  • add username as random position watermark to video using PHP [duplicate]

    12 novembre 2020, par mohamed.nabil

    Iam working on video learning courses website

    &#xA;

    I want to put a dynamic watermark appears in random positions on top of video with username or email of the logedin user.

    &#xA;

    is it possible to do this example by using ffmpeg or require Ai ?, website is php wordpress site.

    &#xA;

    This link provide an example of What I mean from vdocipher website&#xA;https://www.vdocipher.com/blog/2014/12/add-text-to-videos-with-watermark/

    &#xA;

  • Resampling audio using libswresample, leaves small amount of noise after resampling

    20 juillet 2020, par Milo

    I'm trying to resample audio from 44Khz to 48Khz and I'm getting s small light noise after resampling. As if someone is gently ticking the mic. This happens both ways. From 48Khz to 44Khz and vice versa.

    &#xA;

    I've read that this can happen because swrContext still has some data left and that I shoudl flush the context before resampling next frame. And although this helps a little (less noticeable noise), it's still present.

    &#xA;

    I've tried using FFmpeg resample filter instead, but the output is just loud incoherent noise. I'm pretty sure that libswresample should not output any noise on resampling which means that I just don't know how to use it well and I'm missing some options.

    &#xA;

    This is the code for resampler.

    &#xA;

    int ResampleFrame(VideoState * videoState, AVFrame *decoded_audio_frame,     enum AVSampleFormat out_sample_fmt, uint8_t * out_buf)&#xA;{&#xA; int in_sample_rate = videoState->audio->ptrAudioCodecCtx_->sample_rate;&#xA; int out_sample_rate = SAMPLE_RATE;&#xA;&#xA;// get an instance of the AudioResamplingState struct, create if NULL&#xA;AudioResamplingState* arState = getAudioResampling(videoState->audio->ptrAudioCodecCtx_->channel_layout);&#xA;&#xA;if (!arState->swr_ctx)&#xA;{&#xA;    printf("swr_alloc error.\n");&#xA;    return -1;&#xA;}&#xA;&#xA;// get input audio channels&#xA;arState->in_channel_layout = (videoState->audio->ptrAudioCodecCtx_->channels ==&#xA;            av_get_channel_layout_nb_channels(videoState->audio->ptrAudioCodecCtx_->channel_layout)) ?&#xA;            videoState->audio->ptrAudioCodecCtx_->channel_layout :&#xA;            av_get_default_channel_layout(videoState->audio->ptrAudioCodecCtx_->channels);&#xA;&#xA;&#xA;// check input audio channels correctly retrieved&#xA;if (arState->in_channel_layout &lt;= 0)&#xA;{&#xA;    printf("in_channel_layout error.\n");&#xA;    return -1;&#xA;}&#xA;&#xA;&#xA;arState->out_channel_layout = AV_CH_LAYOUT_STEREO;&#xA;&#xA;// retrieve number of audio samples (per channel)&#xA;arState->in_nb_samples = decoded_audio_frame->nb_samples;&#xA;if (arState->in_nb_samples &lt;= 0)&#xA;{&#xA;    printf("in_nb_samples error.\n");&#xA;    return -1;&#xA;}&#xA;&#xA;// Set SwrContext parameters for resampling&#xA;av_opt_set_int(arState->swr_ctx, "in_channel_layout", arState->in_channel_layout, 0);&#xA;av_opt_set_int(arState->swr_ctx, "in_sample_rate", in_sample_rate, 0);&#xA;av_opt_set_sample_fmt(arState->swr_ctx, "in_sample_fmt", videoState->audio->ptrAudioCodecCtx_->sample_fmt, 0);&#xA;&#xA;&#xA;// Set SwrContext parameters for resampling&#xA;av_opt_set_int(arState->swr_ctx, "out_channel_layout", arState->out_channel_layout, 0);&#xA;av_opt_set_int(arState->swr_ctx, "out_sample_rate", out_sample_rate, 0);&#xA;av_opt_set_sample_fmt(arState->swr_ctx, "out_sample_fmt", out_sample_fmt, 0);&#xA;&#xA;&#xA;// initialize SWR context after user parameters have been set&#xA;int ret = swr_init(arState->swr_ctx);&#xA;if (ret &lt; 0)&#xA;   {&#xA;    printf("Failed to initialize the resampling context.\n");&#xA;    return -1;&#xA;   }&#xA;&#xA;&#xA; // retrieve output samples number taking into account the progressive delay&#xA;int64_t delay = swr_get_delay(arState->swr_ctx, videoState->audio->ptrAudioCodecCtx_->sample_rate) &#x2B; arState->in_nb_samples;&#xA;arState->out_nb_samples = av_rescale_rnd(delay, out_sample_rate, in_sample_rate, AV_ROUND_UP );&#xA;&#xA;// check output samples number was correctly rescaled&#xA;if (arState->out_nb_samples &lt;= 0)&#xA;{&#xA;    printf("av_rescale_rnd error\n");&#xA;    return -1;&#xA;}&#xA;&#xA;// get number of output audio channels&#xA;arState->out_nb_channels = av_get_channel_layout_nb_channels(arState->out_channel_layout);&#xA;&#xA;// allocate data pointers array for arState->resampled_data and fill data&#xA;// pointers and linesize accordingly&#xA;// check memory allocation for the resampled data was successful&#xA;ret = av_samples_alloc_array_and_samples(&amp;arState->resampled_data, &amp;arState->out_linesize, arState->out_nb_channels, arState->out_nb_samples, out_sample_fmt, 0);&#xA;if (ret &lt; 0)&#xA;   {&#xA;    printf("av_samples_alloc_array_and_samples() error: Could not allocate destination samples.\n");&#xA;    return -1;&#xA;   }&#xA;&#xA;&#xA;if (arState->swr_ctx)&#xA;   {&#xA;    // do the actual audio data resampling&#xA;    // check audio conversion was successful&#xA;    int ret_num_samples = swr_convert(arState->swr_ctx,arState->resampled_data,arState->out_nb_samples,(const uint8_t**)decoded_audio_frame->data, decoded_audio_frame->nb_samples);&#xA;    //int ret_num_samples = swr_convert_frame(arState->swr_ctx,arState->resampled_data,arState->out_nb_samples,(const uint8_t**)decoded_audio_frame->data, decoded_audio_frame->nb_samples);&#xA;&#xA;    if (ret_num_samples &lt; 0)&#xA;       {&#xA;        printf("swr_convert_error.\n");&#xA;        return -1;&#xA;       }&#xA;&#xA;&#xA;    // get the required buffer size for the given audio parameters&#xA;    // check audio buffer size&#xA;    arState->resampled_data_size = av_samples_get_buffer_size(&amp;arState->out_linesize,   arState->out_nb_channels,ret_num_samples,out_sample_fmt,1);&#xA;&#xA;    if (arState->resampled_data_size &lt; 0)&#xA;       {&#xA;        printf("av_samples_get_buffer_size error.\n");&#xA;        return -1;&#xA;       }&#xA;   } else {&#xA;           printf("swr_ctx null error.\n");&#xA;           return -1;&#xA;          }&#xA;&#xA;&#xA;&#xA;// copy the resampled data to the output buffer&#xA;memcpy(out_buf, arState->resampled_data[0], arState->resampled_data_size);&#xA;&#xA;&#xA;// flush the swr context&#xA;int delayed = swr_convert(arState->swr_ctx,arState->resampled_data,arState->out_nb_samples,NULL,0);&#xA;&#xA;&#xA;&#xA;if (arState->resampled_data)&#xA;   {&#xA;    av_freep(&amp;arState->resampled_data[0]);&#xA;   }&#xA;&#xA;av_freep(&amp;arState->resampled_data);&#xA;arState->resampled_data = NULL;&#xA;&#xA;int ret_data_size = arState->resampled_data_size;&#xA;&#xA;&#xA;&#xA;return ret_data_size;&#xA;}&#xA;

    &#xA;

    I also tries using the filter as shown here but my output is just noise.

    &#xA;

    This is my filter code

    &#xA;

    int  ResampleFrame(AVFrame *frame, uint8_t *out_buf)&#xA;{&#xA;   /* Push the decoded frame into the filtergraph */&#xA;    qint32 ret;&#xA;    ret = av_buffersrc_add_frame_flags(buffersrc_ctx1, frame, AV_BUFFERSRC_FLAG_KEEP_REF);&#xA;    if (ret &lt; 0) &#xA;       {&#xA;        printf("ResampleFrame: Error adding frame to buffer\n");&#xA;        // Delete input frame and return null&#xA;        av_frame_unref(frame);&#xA;        return 0;&#xA;    }&#xA;&#xA;&#xA;    //printf("resampling\n");&#xA;    AVFrame *resampled_frame = av_frame_alloc();&#xA;&#xA;&#xA;    /* Pull filtered frames from the filtergraph */&#xA;    ret = av_buffersink_get_frame(buffersink_ctx1, resampled_frame);&#xA;&#xA;    /* Set the timestamp on the resampled frame */&#xA;    resampled_frame->best_effort_timestamp = resampled_frame->pts;&#xA;&#xA;    if (ret &lt; 0) &#xA;       {&#xA;        av_frame_unref(frame);&#xA;        av_frame_unref(resampled_frame);&#xA;        return 0;&#xA;       }&#xA;&#xA;&#xA;    int buffer_size = av_samples_get_buffer_size(NULL,   2,resampled_frame->nb_samples,AV_SAMPLE_FMT_S16,1);&#xA;&#xA;    memcpy(out_buf,resampled_frame->data,buffer_size);&#xA;&#xA;    //av_frame_unref(frame);&#xA;    av_frame_unref(resampled_frame);&#xA;    return buffer_size;&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;QString filter_description1 = "aresample=48000,aformat=sample_fmts=s16:channel_layouts=stereo,asetnsamples=n=1024:p=0";&#xA;&#xA;int InitAudioFilter(AVStream *inputStream) &#xA;{&#xA;&#xA;    char args[512];&#xA;    int ret;&#xA;    const AVFilter *buffersrc = avfilter_get_by_name("abuffer");&#xA;    const AVFilter *buffersink = avfilter_get_by_name("abuffersink");&#xA;    AVFilterInOut *outputs = avfilter_inout_alloc();&#xA;    AVFilterInOut *inputs = avfilter_inout_alloc();&#xA;    filter_graph = avfilter_graph_alloc();&#xA;&#xA;&#xA;    const enum AVSampleFormat out_sample_fmts[] = {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE};&#xA;    const int64_t out_channel_layouts[] = {AV_CH_LAYOUT_STEREO, -1};&#xA;    const int out_sample_rates[] = {48000, -1};&#xA;&#xA;    snprintf(args, sizeof(args), "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%" PRIx64,&#xA;                         inputStream->codec->time_base.num, inputStream->codec->time_base.den,&#xA;                         inputStream->codec->sample_rate,&#xA;                         av_get_sample_fmt_name(inputStream->codec->sample_fmt),&#xA;                         inputStream->codec->channel_layout);&#xA;&#xA;&#xA;    ret = avfilter_graph_create_filter(&amp;buffersrc_ctx1, buffersrc, "in", args, NULL, filter_graph);&#xA;&#xA;    if (ret &lt; 0) &#xA;       {&#xA;        printf("InitAudioFilter: Unable to create buffersrc\n");&#xA;        return -1;&#xA;       }&#xA;&#xA;    ret = avfilter_graph_create_filter(&amp;buffersink_ctx1, buffersink, "out", NULL, NULL, filter_graph);&#xA;&#xA;    if (ret &lt; 0) &#xA;       {&#xA;        printf("InitAudioFilter: Unable to create buffersink\n");&#xA;        return ret;&#xA;       }&#xA;&#xA;    // set opt SAMPLE FORMATS&#xA;    ret = av_opt_set_int_list(buffersink_ctx1, "sample_fmts", out_sample_fmts, -1, AV_OPT_SEARCH_CHILDREN);&#xA;&#xA;    if (ret &lt; 0) &#xA;       {&#xA;        printf("InitAudioFilter: Cannot set output sample format\n");&#xA;        return ret;&#xA;       }&#xA;&#xA;    // set opt CHANNEL LAYOUTS&#xA;    ret = av_opt_set_int_list(buffersink_ctx1, "channel_layouts", out_channel_layouts, -1, AV_OPT_SEARCH_CHILDREN);&#xA;&#xA;    if (ret &lt; 0) {&#xA;        printf("InitAudioFilter: Cannot set output channel layout\n");&#xA;        return ret;&#xA;    }&#xA;&#xA;    // set opt OUT SAMPLE RATES&#xA;    ret = av_opt_set_int_list(buffersink_ctx1, "sample_rates", out_sample_rates, -1, AV_OPT_SEARCH_CHILDREN);&#xA;&#xA;    if (ret &lt; 0) &#xA;       {&#xA;        printf("InitAudioFilter: Cannot set output sample rate\n");&#xA;        return ret;&#xA;       }&#xA;&#xA;    /* Endpoints for the filter graph. */&#xA;    outputs -> name = av_strdup("in");&#xA;    outputs -> filter_ctx = buffersrc_ctx1;&#xA;    outputs -> pad_idx = 0;&#xA;    outputs -> next = NULL;&#xA;&#xA;    /* Endpoints for the filter graph. */&#xA;    inputs -> name = av_strdup("out");&#xA;    inputs -> filter_ctx = buffersink_ctx1;&#xA;    inputs -> pad_idx = 0;&#xA;    inputs -> next = NULL;&#xA;&#xA;&#xA;    if ((ret = avfilter_graph_parse_ptr(filter_graph, filter_description1.toStdString().c_str(), &amp;inputs, &amp;outputs, NULL)) &lt; 0) &#xA;       {&#xA;        printf("InitAudioFilter: Could not add the filter to graph\n");&#xA;       }&#xA;&#xA;&#xA;    if ((ret = avfilter_graph_config(filter_graph, NULL)) &lt; 0) &#xA;       {&#xA;        printf("InitAudioFilter: Could not configure the graph\n");&#xA;       }&#xA;&#xA;    /* Print summary of the sink buffer&#xA;     * Note: args buffer is reused to store channel layout string */&#xA;    AVFilterLink *outlink = buffersink_ctx1->inputs[0];&#xA;    av_get_channel_layout_string(args, sizeof(args), -1, outlink->channel_layout);&#xA;&#xA;    QString str = args;&#xA;    printf("Output: srate:%dHz fmt:%s chlayout: %s\n", (int) outlink->sample_rate, &#xA;                                                      av_get_sample_fmt_name((AVSampleFormat) outlink->format),&#xA;                                                      str.toStdString().c_str());&#xA;&#xA;&#xA;    filterGraphInitialized_ = true; &#xA;}&#xA;

    &#xA;

    And since I don't have much experience with filters or audio for that matter, I'm also probably missing something here. But Can't figure out what.

    &#xA;

    Thanks

    &#xA;