Recherche avancée

Médias (17)

Mot : - Tags -/wired

Autres articles (13)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • MediaSPIP Init et Diogène : types de publications de MediaSPIP

    11 novembre 2010, par

    À l’installation d’un site MediaSPIP, le plugin MediaSPIP Init réalise certaines opérations dont la principale consiste à créer quatre rubriques principales dans le site et de créer cinq templates de formulaire pour Diogène.
    Ces quatre rubriques principales (aussi appelées secteurs) sont : Medias ; Sites ; Editos ; Actualités ;
    Pour chacune de ces rubriques est créé un template de formulaire spécifique éponyme. Pour la rubrique "Medias" un second template "catégorie" est créé permettant d’ajouter (...)

  • Initialisation de MediaSPIP (préconfiguration)

    20 février 2010, par

    Lors de l’installation de MediaSPIP, celui-ci est préconfiguré pour les usages les plus fréquents.
    Cette préconfiguration est réalisée par un plugin activé par défaut et non désactivable appelé MediaSPIP Init.
    Ce plugin sert à préconfigurer de manière correcte chaque instance de MediaSPIP. Il doit donc être placé dans le dossier plugins-dist/ du site ou de la ferme pour être installé par défaut avant de pouvoir utiliser le site.
    Dans un premier temps il active ou désactive des options de SPIP qui ne le (...)

Sur d’autres sites (4630)

  • Implementing a chained overlay filter with the Libavfilter library in Android NDK

    14 mars 2014, par gookman

    I am trying to use the overlay filter with multiple input sources, for an Android app. Basically, I want to overlay multiple video sources on top of a static image.
    I have looked at the sample that comes with ffmpeg and implemented my code based on that, but things don't seem to be working as expected.

    In the ffmpeg filtering sample there seems to be a single video input. I have to handle multiple video inputs and I am not sure that my solution is the correct one. I have tried to find other examples, but looks like this is the only one.

    Here is my code :

    AVFilterContext **inputContexts;
    AVFilterContext *outputContext;
    AVFilterGraph *graph;

    int initFilters(AVFrame *bgFrame, int inputCount, AVCodecContext **codecContexts, char *filters)
    {
       int i;
       int returnCode;
       char args[512];
       char name[9];
       AVFilterInOut **graphInputs = NULL;
       AVFilterInOut *graphOutput = NULL;

       AVFilter *bufferSrc  = avfilter_get_by_name("buffer");
       AVFilter *bufferSink = avfilter_get_by_name("buffersink");

       graph = avfilter_graph_alloc();
       if(graph == NULL)
           return -1;

       //allocate inputs
       graphInputs = av_calloc(inputCount + 1, sizeof(AVFilterInOut *));
       for(i = 0; i <= inputCount; i++)
       {
           graphInputs[i] = avfilter_inout_alloc();
           if(graphInputs[i] == NULL)
               return -1;
       }

       //allocate input contexts
       inputContexts = av_calloc(inputCount + 1, sizeof(AVFilterContext *));
       //first is the background
       snprintf(args, sizeof(args), "video_size=%dx%d:pix_fmt=%d:time_base=1/1:pixel_aspect=0", bgFrame->width, bgFrame->height, bgFrame->format);
       returnCode = avfilter_graph_create_filter(&inputContexts[0], bufferSrc, "background", args, NULL, graph);
       if(returnCode < 0)
           return returnCode;
       graphInputs[0]->filter_ctx = inputContexts[0];
       graphInputs[0]->name = av_strdup("background");
       graphInputs[0]->next = graphInputs[1];

       //allocate the rest
       for(i = 1; i <= inputCount; i++)
       {
           AVCodecContext *codecCtx = codecContexts[i - 1];
           snprintf(args, sizeof(args), "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
                       codecCtx->width, codecCtx->height, codecCtx->pix_fmt,
                       codecCtx->time_base.num, codecCtx->time_base.den,
                       codecCtx->sample_aspect_ratio.num, codecCtx->sample_aspect_ratio.den);
           snprintf(name, sizeof(name), "video_%d", i);

           returnCode = avfilter_graph_create_filter(&inputContexts[i], bufferSrc, name, args, NULL, graph);
           if(returnCode < 0)
               return returnCode;

           graphInputs[i]->filter_ctx = inputContexts[i];
           graphInputs[i]->name = av_strdup(name);
           graphInputs[i]->pad_idx = 0;
           if(i < inputCount)
           {
               graphInputs[i]->next = graphInputs[i + 1];
           }
           else
           {
               graphInputs[i]->next = NULL;
           }
       }

       //allocate outputs
       graphOutput = avfilter_inout_alloc();  
       returnCode = avfilter_graph_create_filter(&outputContext, bufferSink, "out", NULL, NULL, graph);
       if(returnCode < 0)
           return returnCode;
       graphOutput->filter_ctx = outputContext;
       graphOutput->name = av_strdup("out");
       graphOutput->next = NULL;
       graphOutput->pad_idx = 0;

       returnCode = avfilter_graph_parse_ptr(graph, filters, graphInputs, &graphOutput, NULL);
       if(returnCode < 0)
           return returnCode;

       returnCode = avfilter_graph_config(graph, NULL);
           return returnCode;

       return 0;
    }

    The filters argument of the function is passed on to avfilter_graph_parse_ptr and it can looks like this : [background] scale=512x512 [base]; [video_1] scale=256x256 [tmp_1]; [base][tmp_1] overlay=0:0 [out]

    The call breaks after the call to avfilter_graph_config with the warning :
    Output pad "default" with type video of the filter instance "background" of buffer not connected to any destination and the error Invalid argument.

    What is it that I am not doing correctly ?

  • Filtering audio with Libavfilter results in noise

    6 mai 2014, par gookman

    I am trying to apply some simple filters to an audio stream using libavfilter. The problem I am having is that the output result is only noise. I can’t figure out if the issue is with the filtering or with the way I am encoding the audio data.

    I am not decoding the original audio data myself. This is done through an amovie filter which is part of the filter graph. The code for the graph setup is similar to this :

    void setupGraph()
    {
       AVFilterInOut *gis = NULL;
       AVFilterInOut *gos = NULL;

       graph = avfilter_graph_alloc();

       avfilter_graph_parse2(graph, "amovie=file.mp4 [in_1]; [in_1] abuffersink", &gis, &gos);

       avfilter_graph_config(graph, NULL);

       //get AVFilterContext here for the abuffersink
    }

    This is how I initialise the audio encoder :

    void setupAudioEncoder()
    {  
       AVOutputFormat *outFormat = av_guess_format("mpeg4", filePath, NULL);

       formatCtx = avformat_alloc_context();

       formatCtx->oformat = outFormat;
       memcpy(formatCtx->filename, filePath, std::min(strlen(filePath), sizeof(formatCtx->filename)));

       AVCodecContext *codecCtx = NULL;

       AVCodec *codec = avcodec_find_encoder(formatCtx->oformat->audio_codec);

       audioStream = avformat_new_stream(formatCtx, codec);

       AVCodecContext *codecCtx = audioStream->codec;
       codecCtx->codec_id = formatCtx->oformat->audio_codec;
       codecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
       // Set format
       codecCtx->bit_rate    = 128000;
       codecCtx->sample_rate = 48000;
       codecCtx->channels    = 1;
       codecCtx->sample_fmt  = AV_SAMPLE_FMT_S16;

       if(formatCtx->oformat->flags & AVFMT_GLOBALHEADER)
       {
           codecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
       }

       // Open the codec.
       avcodec_open2(codecCtx, codec, NULL);
    }

    And this is how the processing loop looks like :

    void process()
    {  
       int returnCode = 0;
       int gotPacket = 0;
       AVPacket pkt;
       AVCodecContext *codecCtx = audioStream->codec;

       avformat_write_header(formatCtx, NULL);

       AVFrame *frame = av_frame_alloc();

       while(1)
       {
           returnCode = av_buffersink_get_frame(filterContext, frame);
           if(returnCode == AVERROR(EAGAIN) || returnCode == AVERROR_EOF)
           {
               break;
           }

           frame->pts = av_frame_get_best_effort_timestamp(frame);

           av_init_packet(&pkt);
           pkt.data = NULL;
           pkt.size = 0;

           // Encode
           avcodec_encode_audio2(codecCtx, &pkt, frame, &gotPacket);  

           if(gotPacket != 0)
           {
               pkt.stream_index = output->audioStream->index;

               // Write frame
               av_interleaved_write_frame(output->formatCtx, &pkt);    
           }

           av_free_packet(&pkt);

           av_frame_unref(frame);
       }

       av_write_trailer(formatCtx);
    }

    I have skipped a lot of error checking in the code in order for it to be more readable.

  • FFmpeg scale pad with watermark error parsing filterchain

    21 février 2024, par nicover

    I'm trying to scale a landscape video to full screen ratio with black pad around and add a watermark above, running this command :

    


    -i videoInput.MP4 
-i  watermark-.jpg 
-filter_complex 
[0:v]scale=720.0:720.0*0.59,pad=720.0:720.0*1.77:(ow-iw)/2:(oh-ih)/2:black[main][1:v]scale=iw*0.56:-1[v1];[main][v1]overlay=0:0 
-c:v libx264 -c:a copy -preset ultrafast -y output.mp4


    


    And then I'm getting this error :

    


    [AVFilterGraph @ 0x2825f38a0] Trailing garbage after a filter: scale=iw*0.56:-1[v1];[main][v1]overlay=0:0

[AVFilterGraph @ 0x2825f38a0] Error parsing filterchain '[0:v]scale=720.0:720.0*0.59,pad=720.0:720.0*1.77:(ow-iw)/2:(oh-ih)/2:black[main][1:v]scale=iw*0.56:-1[v1];[main][v1]overlay=0:0' 

around: scale=iw*0.56:-1[v1];[main][v1]overlay=0:0

Error initializing complex filters.
Invalid argument


    


    I'm not able to found the error around the filter graph.

    


    Is the filter graph incorrect ? How to fix it ?