Revision f7ead94c ffmpeg.c

View differences:

ffmpeg.c
339 339
#endif
340 340

  
341 341
#if CONFIG_AVFILTER
342
typedef struct {
343
    int pix_fmt;
344
} FilterOutPriv;
345

  
346

  
347
static int output_init(AVFilterContext *ctx, const char *args, void *opaque)
348
{
349
    FilterOutPriv *priv = ctx->priv;
350

  
351
    if(!opaque) return -1;
352

  
353
    priv->pix_fmt = *((int *)opaque);
354

  
355
    return 0;
356
}
357

  
358
static void output_end_frame(AVFilterLink *link)
359
{
360
}
361

  
362
static int output_query_formats(AVFilterContext *ctx)
363
{
364
    FilterOutPriv *priv = ctx->priv;
365
    enum PixelFormat pix_fmts[] = { priv->pix_fmt, PIX_FMT_NONE };
366

  
367
    avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
368
    return 0;
369
}
370 342

  
371 343
static int get_filtered_video_pic(AVFilterContext *ctx,
372 344
                                  AVFilterBufferRef **picref, AVFrame *pic2,
......
391 363
    return 1;
392 364
}
393 365

  
394
static AVFilter output_filter =
395
{
396
    .name      = "ffmpeg_output",
397

  
398
    .priv_size = sizeof(FilterOutPriv),
399
    .init      = output_init,
400

  
401
    .query_formats = output_query_formats,
402

  
403
    .inputs    = (AVFilterPad[]) {{ .name          = "default",
404
                                    .type          = AVMEDIA_TYPE_VIDEO,
405
                                    .end_frame     = output_end_frame,
406
                                    .min_perms     = AV_PERM_READ, },
407
                                  { .name = NULL }},
408
    .outputs   = (AVFilterPad[]) {{ .name = NULL }},
409
};
410

  
411 366
static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
412 367
{
413 368
    AVFilterContext *last_filter, *filter;
414 369
    /** filter graph containing all filters including input & output */
415 370
    AVCodecContext *codec = ost->st->codec;
416 371
    AVCodecContext *icodec = ist->st->codec;
372
    FFSinkContext ffsink_ctx = { .pix_fmt = codec->pix_fmt };
417 373
    char args[255];
418 374
    int ret;
419 375

  
......
421 377

  
422 378
    if ((ret = avfilter_open(&ist->input_video_filter, avfilter_get_by_name("buffer"), "src")) < 0)
423 379
        return ret;
424
    if ((ret = avfilter_open(&ist->output_video_filter, &output_filter, "out")) < 0)
380
    if ((ret = avfilter_open(&ist->output_video_filter, &ffsink, "out")) < 0)
425 381
        return ret;
426 382

  
427 383
    snprintf(args, 255, "%d:%d:%d:%d:%d", ist->st->codec->width,
......
429 385
             ist->st->time_base.num, ist->st->time_base.den);
430 386
    if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0)
431 387
        return ret;
432
    if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &codec->pix_fmt)) < 0)
388
    if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &ffsink_ctx)) < 0)
433 389
        return ret;
434 390

  
435 391
    /* add input and output filters to the overall graph */

Also available in: Unified diff