当前位置: 首页 > news >正文

网站代运营多少钱一个月福州网站设计知名乐云seo

网站代运营多少钱一个月,福州网站设计知名乐云seo,优化最狠的手机优化软件,2015年手机网站需要主机 空间功能介绍 FFmpeg的过滤器是用于对音视频流进行处理和转换的模块。它可以对输入流进行各种操作#xff0c;如调整大小、调节亮度、对比度、裁剪、旋转等。 操作步骤 实现对某个视频的放大操作的详细步骤如下#xff1a; 配置和初始化FFmpeg#xff1a;在开始编写代码之前…功能介绍 FFmpeg的过滤器是用于对音视频流进行处理和转换的模块。它可以对输入流进行各种操作如调整大小、调节亮度、对比度、裁剪、旋转等。 操作步骤 实现对某个视频的放大操作的详细步骤如下 配置和初始化FFmpeg在开始编写代码之前需要配置和初始化FFmpeg库。这包括引入头文件、注册相关的编解码器和过滤器等。打开输入文件使用avformat_open_input函数打开要处理的视频文件并获取音视频流信息。配置输入流上下文和输出流上下文使用avcodec_parameters_to_context函数从输入流中获取编解码器参数并将其配置给相应的解码器上下文。创建输出流上下文指定输出文件格式及其编码参数。配置过滤器图使用avfilter_graph_alloc函数创建过滤器图。添加输入过滤器使用avfilter_graph_create_filter函数为过滤器图添加输入过滤器。输入过滤器的参数是输入流上下文中的解码器上下文。添加输出过滤器使用avfilter_graph_create_filter函数为过滤器图添加输出过滤器。输出过滤器的参数是输出流上下文中的编码器上下文。创建过滤器链使用avfilter_graph_parse2函数将过滤器图中的过滤器链接起来形成过滤器链。配置过滤器链使用avfilter_graph_config函数对过滤器链进行配置包括设置过滤器参数和连接输入输出。创建帧对象使用av_frame_alloc函数创建待处理的帧对象。 从输入文件中读取帧使用av_read_frame函数从输入文件中循环读取帧数据直到所有帧读取完毕。处理帧数据在帧数据处理循环中将读取到的帧数据传入过滤器链进行处理。将处理后的帧数据写入输出文件使用av_frame_get_best_effort_timestamp函数获取帧的时间戳然后使用av_interleaved_write_frame函数向输出文件写入帧数据。释放资源循环结束后释放所有资源包括释放帧对象、关闭输入文件、关闭输出文件等。 源码实现 下面是使用FFmpeg过滤器功能实现将input.mp4文件中的视频宽度扩大两倍并水平翻转的代码流程 #include stdio.h #include stdlib.h #include string.h #include libavfilter/avfilter.h #include libavfilter/buffersink.h #include libavfilter/buffersrc.h #include libavutil/opt.hint main(int argc, char *argv[]) {const char *filters scalew2*iw:hih, hflip;const char *video_file input.mp4;// 注册所有的过滤器avfilter_register_all();// 用于存储视频文件的格式上下文AVFormatContext *format_ctx NULL;// 打开视频文件并获取格式上下文if (avformat_open_input(format_ctx, video_file, NULL, NULL) ! 0) {fprintf(stderr, Unable to open video file.);return -1;}// 检索流信息if (avformat_find_stream_info(format_ctx, NULL) 0) {fprintf(stderr, Unable to retrieve stream information.);avformat_close_input(format_ctx);return -1;}// 查找视频流索引int video_stream_index av_find_best_stream(format_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);if (video_stream_index AVERROR_STREAM_NOT_FOUND) {fprintf(stderr, Unable to find video stream.);avformat_close_input(format_ctx);return -1;}// 获取视频流解码器上下文AVCodecContext *codec_ctx format_ctx-streams[video_stream_index]-codec;// 查找视频流解码器AVCodec *codec avcodec_find_decoder(codec_ctx-codec_id);if (codec NULL) {fprintf(stderr, Unable to find decoder.);avformat_close_input(format_ctx);return -1;}// 打开视频流解码器if (avcodec_open2(codec_ctx, codec, NULL) ! 0) {fprintf(stderr, Unable to open decoder.);avformat_close_input(format_ctx);return -1;}// 创建过滤器图AVFilterGraph *filter_graph avfilter_graph_alloc();if (!filter_graph) {fprintf(stderr, Unable to create filter graph.\n);avcodec_close(codec_ctx);avformat_close_input(format_ctx);return -1;}// 创建输入过滤器AVFilter *buffer_src avfilter_get_by_name(buffer);AVFilterContext *buffer_src_ctx;if (avfilter_graph_create_filter(buffer_src_ctx, buffer_src, in, NULL, NULL, filter_graph) 0) {fprintf(stderr, Unable to create buffer source filter.\n);avfilter_graph_free(filter_graph);avcodec_close(codec_ctx);avformat_close_input(format_ctx);return -1;}// 设置输入过滤器参数if (av_opt_set_bin(buffer_src_ctx, video_size, (uint8_t*)codec_ctx-width, sizeof(codec_ctx-width), AV_OPT_SEARCH_CHILDREN) 0) {fprintf(stderr, Unable to set video size.\n);avfilter_graph_free(filter_graph);avcodec_close(codec_ctx);avformat_close_input(format_ctx);return -1;}// 创建输出过滤器AVFilterInOut *outputs avfilter_inout_alloc();AVFilterInOut *inputs avfilter_inout_alloc();AVFilter *buffer_sink avfilter_get_by_name(buffersink);AVFilterContext *buffer_sink_ctx;if (avfilter_graph_create_filter(buffer_sink_ctx, buffer_sink, out, NULL, NULL, filter_graph) 0) {fprintf(stderr, Unable to create buffer sink filter.\n);avfilter_graph_free(filter_graph);avfilter_inout_free(outputs);avfilter_inout_free(inputs);avcodec_close(codec_ctx);avformat_close_input(format_ctx);return -1;}// 创建输入过滤器参数enum AVPixelFormat pix_fmts[] { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE };outputs-name av_strdup(in);outputs-filter_ctx buffer_src_ctx;outputs-pad_idx 0;outputs-next NULL;inputs-name av_strdup(out);inputs-filter_ctx buffer_sink_ctx;inputs-pad_idx 0;inputs-next NULL;// 连接输入输出过滤器if (avfilter_graph_parse_ptr(filter_graph, filters, inputs, outputs, NULL) 0) {fprintf(stderr, Unable to parse filter graph.\n);avfilter_graph_free(filter_graph);avfilter_inout_free(outputs);avfilter_inout_free(inputs);avcodec_close(codec_ctx);avformat_close_input(format_ctx);return -1;}// 配置过滤器图if (avfilter_graph_config(filter_graph, NULL) 0) {fprintf(stderr, Unable to configure filter graph.\n);avfilter_graph_free(filter_graph);avfilter_inout_free(outputs);avfilter_inout_free(inputs);avcodec_close(codec_ctx);avformat_close_input(format_ctx);return -1;}// 创建输入帧和输出帧AVFrame *frame av_frame_alloc();AVFrame *out_frame av_frame_alloc();if (!frame) {fprintf(stderr, Unable to allocate frame.\n);avfilter_graph_free(filter_graph);avfilter_inout_free(outputs);avfilter_inout_free(inputs);avcodec_close(codec_ctx);avformat_close_input(format_ctx);return -1;}// 打开输出文件FILE *video_dst_file fopen(output.mp4, wb);if (!video_dst_file) {fprintf(stderr, Unable to open output file.\n);avfilter_graph_free(filter_graph);avfilter_inout_free(outputs);avfilter_inout_free(inputs);av_frame_free(frame);avcodec_close(codec_ctx);avformat_close_input(format_ctx);return -1;}// 初始化空的AVPacket结构体用于存储解码之后的数据AVPacket packet { 0 };// 读取每个视频包while (av_read_frame(format_ctx, packet) 0) {// 检查是否是视频流if (packet.stream_index video_stream_index) {// 将视频包发送到解码器进行解码if (avcodec_send_packet(codec_ctx, packet) ! 0) {fprintf(stderr, Error sending packet to decoder.\n);break;}// 解码每个解码帧while (avcodec_receive_frame(codec_ctx, frame) 0) {// 将解码帧发送到过滤器图进行处理if (av_buffersrc_add_frame_flags(buffer_src_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) ! 0) {fprintf(stderr, Error adding frame to filter graph.\n);break;}// 获取过滤后的帧while (av_buffersink_get_frame(buffer_sink_ctx, out_frame) 0) {// 直接将帧数据写入输出文件fwrite(out_frame-data[0], 1, out_frame-linesize[0] * out_frame-height, video_dst_file);fwrite(out_frame-data[1], 1, out_frame-linesize[1] * out_frame-height / 2, video_dst_file);fwrite(out_frame-data[2], 1, out_frame-linesize[2] * out_frame-height / 2, video_dst_file);// 释放帧对象av_frame_unref(out_frame);}}// 释放帧对象av_frame_unref(frame);}// 释放数据包对象av_packet_unref(packet);}// 关闭输出文件fclose(video_dst_file);// 释放资源avfilter_graph_free(filter_graph);avfilter_inout_free(outputs);avfilter_inout_free(inputs);av_frame_free(frame);avcodec_free_context(codec_ctx);avformat_close_input(format_ctx);return 0; } 如果有多个过滤器可以通过遍历过滤器源码数组来创建和连接多个过滤器。每次循环迭代我们创建一个新的过滤器并与前一个过滤器进行连接。最后一个过滤器将连接到输出过滤器。请注意在每次迭代中我们使用前一个过滤器的输出过滤器上下文作为当前过滤器的输入。 const char *filters[] {scalew2*iw:hih,hflip,rotate30*PI/180 };// ...// 创建输入输出过滤器链表 AVFilterInOut *outputs avfilter_inout_alloc(); AVFilterInOut *inputs avfilter_inout_alloc();// 创建输入过滤器 AVFilterContext *buffer_src_ctx NULL; if (avfilter_graph_create_filter(buffer_src_ctx, buffer_src, in, NULL, NULL, filter_graph) 0) {// 错误处理 }// 设置输入过滤器参数 if (av_opt_set_bin(buffer_src_ctx, video_size, (uint8_t*)codec_ctx-width, sizeof(codec_ctx-width), AV_OPT_SEARCH_CHILDREN) 0) {// 错误处理 }// 循环遍历过滤器源码数组并创建过滤器 for (int i 0; i num_filters; i) {// 创建输出过滤器AVFilterContext *filter_ctx NULL;if (avfilter_graph_create_filter(filter_ctx, filter, filter_name, NULL, NULL, filter_graph) 0) {// 错误处理}// 连接过滤器if (avfilter_link(buffer_src_ctx, 0, filter_ctx, 0) 0) {// 错误处理}buffer_src_ctx filter_ctx; // 更新buffer_src_ctx为当前过滤器的输出过滤器上下文 }// 创建输出过滤器 AVFilterContext *buffer_sink_ctx NULL; if (avfilter_graph_create_filter(buffer_sink_ctx, buffer_sink, out, NULL, NULL, filter_graph) 0) {// 错误处理 }// 连接输出过滤器 if (avfilter_link(buffer_src_ctx, 0, buffer_sink_ctx, 0) 0) {// 错误处理 }// 配置过滤器图 if (avfilter_graph_config(filter_graph, NULL) 0) {// 错误处理 }// ...// 在解码和过滤循环中处理帧// ...// 释放资源 avfilter_graph_free(filter_graph); avfilter_inout_free(outputs); avfilter_inout_free(inputs);// ...
http://www.yutouwan.com/news/252825/

相关文章:

  • 无锡建设工程项目代码申请网站wordpress怎么增加语言
  • 做简历网站商城网站建设制作设计
  • 深圳市光明区住房和建设局网站株洲网站平台搭建
  • 北京东方华美建设集团有限公司网站大型电商网站开发
  • 邢台做网站推广服务xly000.WordPress.cok
  • 嘉兴做微网站wordpress div layer
  • 官方网站面膜做微商微号网站开发
  • 酒楼网站模板wordpress 自动上传插件
  • 免费网站空间怎么网站建设公司名称
  • 枣庄做网站制作济南建设银行
  • 外贸网站 备案中民保险网
  • 可以做反链的网站济南电子商务网站开发
  • wordpress托管和建站网页制作和网页制作技术
  • 物流公司网站怎么做拓者设计官网网页版
  • 做画册去什么网站找素材深圳seo博客
  • 网站页面设计流程海外域名服务商
  • 最新域名2021东莞市seo网络推广企业
  • 如何自己制作一个网站中国互联网服务平台
  • 账号注册网站佛山建站怎么做
  • 个旧建设局信息公开门户网站网站建设教学方法探究
  • 建设局网站安全自查情况报告多个链接的网站怎么做的
  • php模板建站wordpress怎么添加文件验证
  • 动漫网站设计方案广州免费核酸检测点
  • 空间刷赞网站推广lnmp 502 wordpress
  • 做框架表格网站wordpress部署
  • 自做网站多少钱官网传奇
  • 合肥做网站 卫来网络wordpress快应用
  • 中山站群网站建设wordpress秒开优化
  • 做电影网站为什么要数据库中小企业网站开发
  • 共创福州网站建设网站建设头部代码