ffmpeg 帧类型enum

AV_PICTURE_TYPE_NONE
Undefined.

AV_PICTURE_TYPE_I
Intra.

AV_PICTURE_TYPE_P
Predicted.

AV_PICTURE_TYPE_B
Bi-dir predicted.

AV_PICTURE_TYPE_S
S(GMC)-VOP MPEG4.

AV_PICTURE_TYPE_SI
Switching Intra.

AV_PICTURE_TYPE_SP
Switching Predicted.

AV_PICTURE_TYPE_BI
BI type.

https://ffmpeg.org/doxygen/1.1/group__lavu__picture.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
滤镜是FFmpeg中的一个重要概念,它可以对音视频进行各种处理,例如裁剪、旋转、缩放、调整亮度、对比度等等。FFmpeg提供了丰富的滤镜库,可以通过API在代码中使用滤镜。下面是一个简单的使用FFmpeg API添加滤镜的例子: ```c #include <libavfilter/avfilter.h> #include <libavfilter/buffersink.h> #include <libavfilter/buffersrc.h> AVFilterContext *buffersink_ctx; AVFilterContext *buffersrc_ctx; AVFilterGraph *filter_graph; int video_stream_index = -1; // 初始化滤镜 int init_filters(const char *filters_descr) { char args[512]; int ret = 0; AVFilter *buffersrc = avfilter_get_by_name("buffer"); AVFilter *buffersink = avfilter_get_by_name("buffersink"); AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }; filter_graph = avfilter_graph_alloc(); if (!outputs || !inputs || !filter_graph) { ret = AVERROR(ENOMEM); goto end; } // 设置输入参数 snprintf(args, sizeof(args), "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d", buffersrc_ctx->inputs[0]->width, buffersrc_ctx->inputs[0]->height, buffersrc_ctx->inputs[0]->format, buffersrc_ctx->inputs[0]->time_base.num, buffersrc_ctx->inputs[0]->time_base.den, buffersrc_ctx->inputs[0]->sample_aspect_ratio.num, buffersrc_ctx->inputs[0]->sample_aspect_ratio.den); // 添加输入滤镜 ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in", args, NULL, filter_graph); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot create buffer source\n"); goto end; } // 添加输出滤镜 ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out", NULL, NULL, filter_graph); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot create buffer sink\n"); goto end; } // 设置输出参数 ret = av_opt_set_int_list(buffersink_ctx, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot set output pixel format\n"); goto end; } // 添加滤镜 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; if ((ret = avfilter_graph_parse_ptr(filter_graph, filters_descr, &inputs, &outputs, NULL)) < 0) goto end; if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0) goto end; end: avfilter_inout_free(&inputs); avfilter_inout_free(&outputs); return ret; } // 处理滤镜 int filter_encode_write_frame(AVFrame *frame, AVCodecContext *enc_ctx, AVFormatContext *fmt_ctx) { int ret; AVFrame *filt_frame = av_frame_alloc(); if (!filt_frame) { ret = AVERROR(ENOMEM); goto end; } // 添加滤镜 if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) < 0) { av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n"); goto end; } // 获取输出 while (1) { ret = av_buffersink_get_frame(buffersink_ctx, filt_frame); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) break; if (ret < 0) goto end; // 编码并写入文件 filt_frame->pict_type = AV_PICTURE_TYPE_NONE; ret = encode_write_frame(filt_frame, enc_ctx, fmt_ctx); av_frame_unref(filt_frame); if (ret < 0) goto end; } end: av_frame_free(&filt_frame); return ret; } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值