Recherche avancée

Médias (1)

Mot : - Tags -/publicité

Autres articles (77)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • 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 (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (10344)

  • BGR0 -> VAAPI fmt -> VAAPI h264 encode - with BGR0 file input gives junk encoded data

    4 avril 2019, par rgag

    I am writing a small c application using ffmpeg libraries to take a raw BGR0 file input and use VA apis to convert BGR0 to VAAPI pix_fmt which is directly fed to H264 encoder in GPU. The entire pipeline is working but the encoded frames are junk. Please go through the code and suggest if any changes needs to be done to the code. I suspect something related to setting of input and output frame, but I am not able to figure it out.

    Summary of the code is

    Create filters buffersrc and buffersink. Create vf_scale_vaapi filter
    and connect all filters as buffersrc->vf_scale_vaapi->buffersink.
    Input to buffersrc is BGR0 frame and output of buffersink is VAAPI
    frame. This VAAPI frame is fed to h264 encoder in gpu for encoding.

       const char *filter_descr = "hwupload,scale_vaapi=format=nv12";

       avfilter_register_all();
       av_log_set_level(48);
       char args[512];
       AVFilter *buffersrc  = avfilter_get_by_name("buffer");
       AVFilter *buffersink = avfilter_get_by_name("buffersink");
       if ( buffersink == NULL )
               printf("getting nul as sfilter name\n");
       AVFilterInOut *outputs = avfilter_inout_alloc();
       AVFilterInOut *inputs  = avfilter_inout_alloc();
       enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE };
       AVBufferSinkParams *buffersink_params;


       filter_graph = avfilter_graph_alloc();

       /* buffer video source: the decoded frames from the decoder will be inserted here. */
       snprintf(args, sizeof(args),
            "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d",
               in_width,in_height,AV_PIX_FMT_BGR0,
               1, 25,1,1);

       ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in",
               args, NULL, filter_graph);
       if (ret < 0) {
               printf("Cannot create buffer source\n");
               return ret;
       }

       /* buffer video sink: to terminate the filter chain. */
       buffersink_params = av_buffersink_params_alloc();
       buffersink_params->pixel_fmts = pix_fmts;
       ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out",
               NULL, buffersink_params, filter_graph);
       av_free(buffersink_params);
       if (ret < 0) {
               printf("Cannot create buffer sink\n");
               return ret;
       }

       /* Endpoints for the filter graph. */
       outputs->name       = av_strdup("in");
       outputs->filter_ctx = buffersrc_ctx;
       outputs->pad_idx    = 0;
       outputs->next       = NULL;

       inputs->name       = av_strdup("out");
       inputs->filter_ctx = buffersink_ctx;
       inputs->pad_idx    = 0;
       inputs->next       = NULL;


       type = av_hwdevice_find_type_by_name("vaapi");
           printf("did not find the hw device type\n");
           ret = -1;
       }

       ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_VAAPI, "/dev/dri/renderD128", NULL, 0);
       if ( ret < 0 )
               printf("could not create tghe hw devicew nctx\n");


       if (!(codec = avcodec_find_encoder_by_name(enc_name))) {
           fprintf(stderr, "Could not find encoder.\n");
           err = -1;
           goto fail;
       }

       if (!(avctx = avcodec_alloc_context3(codec))) {
           err = AVERROR(ENOMEM);
           goto fail;
       }

       avctx->width     = width;
       avctx->height    = height;
       avctx->time_base = (AVRational){1, 25};
       avctx->framerate = (AVRational){25, 1};
       avctx->sample_aspect_ratio = (AVRational){1, 1};
       avctx->pix_fmt   = AV_PIX_FMT_VAAPI;
       avctx->profile   = FF_PROFILE_H264_HIGH;


       hw_device_ctx = av_buffer_ref(device_ref);
       if (!hw_device_ctx){
           printf("could not ref hw device buf\n");
           ret= AVERROR(ENOMEM);
       }

       AVBufferRef *device = hw_device_ctx;
       for (i = 0; i < filter_graph->nb_filters; i++) {
           filter_graph->filters[i]->hw_device_ctx = av_buffer_ref(device);
           if (!filter_graph->filters[i]->hw_device_ctx) {
               ret = AVERROR(ENOMEM);
               goto fail;
           }
       }

       //========== BLOCK of CODE which I feel needs help===================
       if ((ret = avfilter_graph_parse_ptr(filter_graph, filter_descr, &inputs, &outputs, NULL)) < 0)
               return ret;
       for (i = 0; i < filter_graph->nb_filters; i++) {
           filter_graph->filters[i]->hw_device_ctx = av_buffer_ref(device);
           if (!filter_graph->filters[i]->hw_device_ctx) {
               ret = AVERROR(ENOMEM);
               goto fail;
           }
       }
       frame_out=av_frame_alloc();
       frame_buffer_out=(unsigned char *)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_VAAPI, in_width,in_height,1));
       av_image_fill_arrays(frame_out->data, frame_out->linesize,frame_buffer_out,
               AV_PIX_FMT_VAAPI,in_width, in_height,1);
       frame_in->width=in_width;
       frame_in->height=in_height;
       frame_in->format=AV_PIX_FMT_BGR0;

       avctx->hw_frames_ctx = av_buffer_ref(av_buffersink_get_hw_frames_ctx(buffersink_ctx));
       if ( !avctx->hw_frames_ctx){
           fprintf(stderr, "Failed to set hwframe context.\n");
           goto fail;
       }

       if ((err = avcodec_open2(avctx, codec, NULL)) < 0) {
           fprintf(stderr, "Cannot open video encoder codec. Error code: %s\n", av_err2str(err));
           goto fail;
       }
       //=====================================================================
       i = 0;



       while (1) {
               if(fread(frame_buffer_in, 1, in_width*in_height*4, fp_in)!= in_width*in_height*4){ //bgr0 read
                       break;
               }
               //input BGR 0
               frame_in->data[0]=frame_buffer_in;
               frame_in->pts = (1.0 / 30) * 90 * i;
               i++;
               if (av_buffersrc_add_frame(buffersrc_ctx, frame_in) < 0) {
                   printf( "Error while add frame.\n");
                   break;
               }


               /* pull filtered pictures from the filtergraph */
               ret = av_buffersink_get_frame(buffersink_ctx, frame_out);
               if (ret < 0){
                   printf("unable to get frma e from buffer sink\n");
                   break;
               }

              // Make sure Closed Captions will not be duplicated
              av_frame_remove_side_data(frame_out, AV_FRAME_DATA_A53_CC);
              int ret = 0;
              AVPacket enc_pkt;

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

              if ((ret = avcodec_send_frame(avctx, frame_out)) < 0) {
                  fprintf(stderr, "Error code: %s\n", av_err2str(ret));
                  goto fail;
              }

             // Make sure Closed Captions will not be duplicated
             av_frame_remove_side_data(frame, AV_FRAME_DATA_A53_CC);
             while (1) {
                    ret = avcodec_receive_packet(avctx, &enc_pkt);
                    if (ret ) //< 0 && ret != AVERROR(EAGAIN))
                        break;

                     enc_pkt.stream_index = 0;
                     ret = fwrite(enc_pkt.data, enc_pkt.size, 1, fp_out);
              }

             av_packet_unref(&enc_pkt);
      }
  • avcodec/lzwenc : Add 1 additional bit of padding for gif

    14 août 2013, par Michael Niedermayer
    avcodec/lzwenc : Add 1 additional bit of padding for gif
    

    This fixes issues with gimp reading animated gifs

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

    • [DH] libavcodec/lzwenc.c
    • [DH] tests/ref/fate/gifenc-bgr4_byte
    • [DH] tests/ref/fate/gifenc-bgr8
    • [DH] tests/ref/fate/gifenc-gray
    • [DH] tests/ref/fate/gifenc-pal8
    • [DH] tests/ref/fate/gifenc-rgb4_byte
    • [DH] tests/ref/fate/gifenc-rgb8
  • Trolls in trouble

    6 juin 2013, par Mans — Law and liberty

    Life as a patent troll is hopefully set to get more difficult. In a memo describing patent trolls as a “drain on the American economy,” the White House this week outlined a number of steps it is taking to stem this evil tide. Chiming in, the Chief Judge of the Court of Appeals for the Federal Circuit (where patent cases are heard) in a New York Times op-ed laments the toll patent trolling is taking on the industry, and urges judges to use powers already at their disposal to make the practice less attractive. However, while certainly a step in the right direction, these measures all fail to address the more fundamental properties of the patent system allowing trolls to exist in the first place.

    System and method for patent trolling

    Most patent trolling operations comprise the same basic elements :

    1. One or more patents with broad claims.
    2. The patents of (1) acquired by an otherwise non-practising entity (troll).
    3. The entity of (2) filing numerous lawsuits alleging infringement of the patents of (1).
    4. The lawsuits of (3) targeting end users or retailers.
    5. The lawsuits of (3) listing as plaintiffs difficult to trace shell companies.

    The recent legislative actions all take aim at the latter entries in this list. In so doing, they will no doubt cripple the trolls, but the trolls will remain alive, ready to resume their wicked ways once a new loophole is found in the system.

    To kill a patent troll

    As Judge Rader and his co-authors point out in the New York Times, “the problem stems largely from the fact that, [...] trolls have an important strategic advantage over their adversaries : they don’t make anything.” This is the heart of the troll, and this is where the blow should be struck. Our weapon shall be the mightiest judicial sword of all, the Constitution.

    The United States Constitution contains (in Article I, Section 8) the foundation for the patent system (emphasis mine) :

    The Congress shall have Power [...] To promote the Progress of Science and useful Arts, by securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries.

    Patent trolls are typically not inventors. They are merely hoarders of other people’s discarded inventions, and that allowing others to reap the benefits of an inventor’s work would somehow promote progress should be a tough argument. Indeed, it is the dissociation between investment and reward which has allowed the patent trolls to rise and prosper.

    In light of the above, the solution to the troll menace is actually strikingly simple : make patents non-transferable.

    Having the inventor retain the rights to his or her inventions (works for hire still being recognised), would render the establishment of non-practising entities, which most trolls are, virtually impossible. The original purpose of patents, to protect the investment of inventors, would remain unaffected, if not strengthened, by such a change.

    Links