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

杭州网站备案要多久山东东营市区号

杭州网站备案要多久,山东东营市区号,网站dns解析失败,原则网站设计版式一#xff1a;前言 FFmpeg 是一个非常强大的多媒体框架#xff0c;它可以用来处理视频和音频数据。它包括了命令行工具 ffmpeg、ffplay、ffprobe 等#xff0c;以及一套可以用来开发多媒体应用的库#xff08;libavcodec、libavformat、libavutil、libswscale 等#xff0…一前言 FFmpeg 是一个非常强大的多媒体框架它可以用来处理视频和音频数据。它包括了命令行工具 ffmpeg、ffplay、ffprobe 等以及一套可以用来开发多媒体应用的库libavcodec、libavformat、libavutil、libswscale 等。FFmpeg 支持多种音视频格式的转换、编码、解码、流处理等操作。 RTSPReal Time Streaming Protocol是一种网络控制协议用于建立和控制媒体流的会话。它常用于流媒体应用比如视频监控系统。RTSP 允许客户端控制媒体流如播放、暂停、快进等并且可以支持多种流媒体传输协议如 RTPReal-time Transport Protocol。 二功能分析 功能要求支持多路流媒体信号同时进行解码和保存也就是录播功能。 功能分析要想实现多路流媒体信号同时进行解码功能的实现首先会想到一个问题那就是同步性对于多路并非运行而言其多路从事的其实是一个工作那就是通过avformat_open_input()打开对应的流文件然后再对这个流文件进行处理。 功能实现更具功能分析可以得到一个实现方案那就是使用线程并发性的特点利用多线程互不干扰同时进行的特点来实现多路的流媒体并发解码。下面的示例为两路流并发运行的例子多路流同样的道理有多少路采用多少线程。思路清晰条理清晰直接上具体实现功能。 三功能实现 单路拉流解码流程 1打开输入流文件 使用ffmpeg的接口函数 avformat_alloc_context() 创建一个存储多媒体容器格式信息的结构体。然后用avformat_open_input()打开流文件。 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options); 其中的第一个参数就是上面函数的返回值第二个参数就是流地址的RUL第三个参数为NULL,第四个参数的作用为设置一些解复用器特定的选项rtsp的默认传输是UDP可以通过这个参数加上av_dict_set()函数来修改为 TCP协议。 2寻找媒体信息 int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); 第一个参数为上面的创建结构体的函数返回值第二个为NULL。 然后访问里面的流媒体信息。 fctx-nb_streams;//有几个流媒体 fctx-streams[0];//一般为视频流媒体 fctx-streams[1];//音频 3创建上下文 avcodec_alloc_context3(NULL) int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *params); 拷贝流媒体中的数据。 fctx-streams[video_index]-codecpar 4寻找解码器 AVCodec *avcodec_find_decoder(enum AVCodecID id); 通过ID来寻找对应的解码器。 5绑定上下文 打开编码器;avcodec_open2 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); 6:编码并保存 接口函数 int av_read_frame(AVFormatContext *s, AVPacket *pkt); int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *pkt); int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); 分别的功能为 向输入流中读取一个数据包 向解码器发送一个压缩数据包 从解码器中接收解码后的帧。 基本解码功能就结束了要注意资源的回收和释放 av_frame_unref() 释放 AVFrame 结构体中的所有引用的资源 av_packet_unref 用于释放 AVPacket 结构体中的所有资源。 两路拉流功能实现 两路是用俩线程分别实现俩路解码的过程解码流程大体不变不一样的点就是加入两个线程。具体代码如下 #include stdio.h #include stdlib.h #include string.h #include unistd.h #include libavcodec/avcodec.h #include libavformat/avformat.h #include libavutil/avutil.h #include libavdevice/avdevice.h #include pthread.h// 定义视频流索引 int video_index1 -1; int video_index2 -1; AVFormatContext *fctx1 NULL; AVFormatContext *fctx2 NULL; // 线程处理函数 void *decode_stream(void *arg) {AVFormatContext *format_ctx (AVFormatContext *)arg;AVCodecContext *codec_ctx NULL;AVCodec *codec NULL;AVPacket packet;AVFrame *frame av_frame_alloc();int ret;FILE *file NULL;// 寻找视频流int video_stream_index video_index1;if (format_ctx fctx2) {video_stream_index video_index2;file fopen(2.yuv, w);} else {file fopen(1.yuv, w);}if (!file) {printf(创建YUV文件失败\n);return NULL;}// 获取解码器上下文codec_ctx avcodec_alloc_context3(NULL);avcodec_parameters_to_context(codec_ctx, format_ctx-streams[video_stream_index]-codecpar);// 寻找解码器codec avcodec_find_decoder(codec_ctx-codec_id);if (codec NULL) {printf(未找到解码器\n);fclose(file);return NULL;}// 打开解码器if (avcodec_open2(codec_ctx, codec, NULL) 0) {printf(无法打开解码器\n);fclose(file);return NULL;}// 读取数据并解码av_init_packet(packet);packet.data NULL;packet.size 0;while (av_read_frame(format_ctx, packet) 0) {if (packet.stream_index video_stream_index) {ret avcodec_send_packet(codec_ctx, packet);if (ret 0) {printf(发送数据到解码器失败\n);break;}while (ret 0) {ret avcodec_receive_frame(codec_ctx, frame);if (ret AVERROR(EAGAIN) || ret AVERROR_EOF) {break;} else if (ret 0){printf(解码失败\n);break;}// 写入YUV数据fwrite(frame-data[0], 1, frame-linesize[0] * frame-height, file);fwrite(frame-data[1], 1, frame-linesize[1] * frame-height / 2, file);fwrite(frame-data[2], 1, frame-linesize[2] * frame-height / 2, file);av_frame_unref(frame);}av_packet_unref(packet);}}// 释放资源if (frame) {av_frame_free(frame);}if (codec_ctx) {avcodec_free_context(codec_ctx);}if (file) {fclose(file);}return NULL; }int main() {avformat_network_init();AVDictionary *options1 NULL;AVDictionary *options2 NULL;//定义两路流媒体URLchar filepath1[] rtsp://192.168.xx.xx/xx/xx;//根据自己的URL设置char filepath2[] rtsp://xxx.xxx.xx.xx.;av_dict_set(options1, buffer_size, 1080000, 0);av_dict_set(options1, rtsp_transport, tcp, 0);av_dict_set(options1, stimeout, 5000000, 0);av_dict_set(options1, max_delay, 500000, 0);av_dict_set(options2, buffer_size, 720000, 0);av_dict_set(options2, rtsp_transport, tcp, 0);av_dict_set(options2, stimeout, 5000000, 0);av_dict_set(options2, max_delay, 500000, 0);//1:打开输入流文件fctx1 avformat_alloc_context();fctx2 avformat_alloc_context();if (avformat_open_input(fctx1, filepath1, NULL, options1) 0) {printf(第一路流文件打开失败\n);return -1;}if (avformat_open_input(fctx2, filepath2, NULL, options2) 0) {printf(第二路流文件打开失败\n);avformat_close_input(fctx1);avformat_free_context(fctx1);return -1;}if (avformat_find_stream_info(fctx1, NULL) 0) {printf(第一路流文件非流媒体文件\n);avformat_close_input(fctx1);avformat_close_input(fctx2);avformat_free_context(fctx1);avformat_free_context(fctx2);return -1;}if (avformat_find_stream_info(fctx2, NULL) 0) {printf(第二路流文件非流媒体文件\n);avformat_close_input(fctx1);avformat_close_input(fctx2);avformat_free_context(fctx1);avformat_free_context(fctx2);return -1;}//寻找对应的视频流索引for (int i 0; i fctx1-nb_streams; i) {if (fctx1-streams[i]-codecpar-codec_type AVMEDIA_TYPE_VIDEO) {video_index1 i;break;}}for (int i 0; i fctx2-nb_streams; i) {if (fctx2-streams[i]-codecpar-codec_type AVMEDIA_TYPE_VIDEO) {video_index2 i;break;}}//创建线程pthread_t tid1, tid2;pthread_create(tid1, NULL, decode_stream, fctx1);pthread_create(tid2, NULL, decode_stream, fctx2);pthread_join(tid1, NULL);pthread_join(tid2, NULL);avformat_close_input(fctx1);avformat_close_input(fctx2);avformat_free_context(fctx1);avformat_free_context(fctx2);return 0; }
http://www.pierceye.com/news/409372/

相关文章:

  • 做网站 业务流程图如何选择丹阳网站建设
  • 金属东莞网站建设技术支持开放平台产品经理
  • 全网营销型的网站苏州网站设计多少钱
  • 河南教育平台网站建设北京市工程建设信息交易网站
  • 正规品牌网站设计推荐如何上传自己的做的网站
  • 企业网站优化甲薇g71679做同等效果下拉词制作手机网站哪家好
  • 物流运输做网站的素材多用户商城系统价格
  • 营销型网站建设流程电脑怎么建网站
  • 郑州市汉狮做网站360免费建站
  • 安阳哪里有学做网站的学校做个公众号需要多少钱
  • 建站seo是什么成都做营销型网站
  • 网站建设哪个wordpress分类title
  • 建手机网站多少钱挂机软件定制
  • 网站建设 提案 框架河南一般建一个网站需要多少钱
  • 福建省建设人才市场网站深圳营销型网站建设优化
  • 晋城购物网站开发设计宣传网站有哪些
  • 在哪人网站要以接it项目做企业为什么要分析环境
  • 达令的网站建设wordpress上传视频
  • 织梦免费网站模块下载地址南充楼盘网
  • 深圳极速网站建设服务器做网站 然后百度推广
  • 西充县住房和城乡建设局网站深圳建设局网站打不开
  • 深圳常平网站建设制作公司网站开发qq群
  • 校园网站建设的感受论文专业微信网站建设公司首选
  • 国外免费logo设计网站免费网课平台
  • 高端网站设计定制公司页面跳转自动更新
  • 项目建设资金来源网站网站开发技术可以做什么工作
  • 可做易企秀的网站网页建站网站
  • 南京网站建设价格大型网站开发协调
  • 园林景观设计公司点评的网站和论坛大型网站搜索怎么做的
  • 河南省建设教育培训中心网站广告机器设备的价格表