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

济南企业做网站斗蟋蟀网站建设

济南企业做网站,斗蟋蟀网站建设,制作文件的软件,云南特色流程 根据硬件名称#xff0c;查询是否是支持的类型 const char *device_name qsv; //cuda enum AVHWDeviceType type av_hwdevice_find_type_by_name(device_name); if(type AV_HWDEVICE_TYPE_NONE) {//如果一个硬件类型是不支持的#xff0c;打印所有支持…流程 根据硬件名称查询是否是支持的类型 const char *device_name qsv; //cuda enum AVHWDeviceType type av_hwdevice_find_type_by_name(device_name); if(type AV_HWDEVICE_TYPE_NONE) {//如果一个硬件类型是不支持的打印所有支持的硬件名称printf(Device type %s is not supported.\n, device_name);fprintf(stderr, Available device types:);while((type av_hwdevice_iterate_types(type)) ! AV_HWDEVICE_TYPE_NONE){fprintf(stderr, %s, av_hwdevice_get_type_name(type));}fprintf(stderr, \n); }通用过程 avformat_open_input avformat_find_stream_info av_find_best_stream获取硬件编码器 AVCodec *pCodec;for (i 0;; i) {const AVCodecHWConfig *config avcodec_get_hw_config(pCodec, i);if (!config) {fprintf(stderr, Decoder %s does not support device type %s.\n,pCodec-name, av_hwdevice_get_type_name(type));return;}if (config-methods AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX config-device_type type) {hw_pix_fmt config-pix_fmt;break;}}查找解码器 if (!(pCodecCtx avcodec_alloc_context3(pCodec)))return;复制参数 video pFormatCtx-streams[videoStream];if (avcodec_parameters_to_context(pCodecCtx, video-codecpar) 0)return;pCodecCtx-get_format get_hw_format;初始化硬件解码器与打开解码器 if (hw_decoder_init(pCodecCtx, type) 0)return; //打开解码器if (avcodec_open2(pCodecCtx, pCodec, NULL) 0) {printf(Could not open codec.\n);return;}读取视频包发送视频包到解码器解码将显存中的内容复制内存中 ret av_hwframe_transfer_data(swFrame, pFrame, 0);if(ret 0){qDebug() Error transferring the data to system memory;break;}完整的代码 AVFormatContext *pFormatCtx;AVCodecContext *pCodecCtx;AVCodec *pCodec;AVFrame *pFrame, *pFrameRGB, *swFrame, *tempFrame;uint8_t *out_buffer;AVPacket packet;AVStream *video NULL;static struct SwsContext *img_convert_ctx;int videoStream, i, numBytes;int ret, got_picture;avformat_network_init();//Allocate an AVFormatContext.pFormatCtx avformat_alloc_context();const char *device_name cuda; //cudaenum AVHWDeviceType type av_hwdevice_find_type_by_name(device_name);if(type AV_HWDEVICE_TYPE_NONE){printf(Device type %s is not supported.\n, device_name);fprintf(stderr, Available device types:);while((type av_hwdevice_iterate_types(type)) ! AV_HWDEVICE_TYPE_NONE)fprintf(stderr, %s, av_hwdevice_get_type_name(type));fprintf(stderr, \n);}AVDictionary *opt nullptr; // av_dict_set(opt,buffer_size,1024000,0); // av_dict_set(opt,max_delay,0,0);av_dict_set(opt,rtsp_transport,tcp,0);av_dict_set(opt,stimeout,5000000,0);if (avformat_open_input(pFormatCtx, mFileName.toUtf8().data(), NULL, NULL) ! 0) {printf(cant open the file. \n);return;}if (avformat_find_stream_info(pFormatCtx, NULL) 0) {printf(Couldt find stream infomation.\n);return;}ret av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, pCodec, 0);if (ret 0) {fprintf(stderr, Cannot find a video stream in the input file\n);return;}videoStream ret;for (i 0;; i) {const AVCodecHWConfig *config avcodec_get_hw_config(pCodec, i);if (!config) {fprintf(stderr, Decoder %s does not support device type %s.\n,pCodec-name, av_hwdevice_get_type_name(type));return;}if (config-methods AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX config-device_type type) {hw_pix_fmt config-pix_fmt;break;}}///查找解码器if (!(pCodecCtx avcodec_alloc_context3(pCodec)))return;video pFormatCtx-streams[videoStream];if (avcodec_parameters_to_context(pCodecCtx, video-codecpar) 0)return;pCodecCtx-get_format get_hw_format;if (hw_decoder_init(pCodecCtx, type) 0)return;///打开解码器if (avcodec_open2(pCodecCtx, pCodec, NULL) 0) {printf(Could not open codec.\n);return;}pFrame av_frame_alloc();pFrameRGB av_frame_alloc();tempFrame av_frame_alloc();swFrame av_frame_alloc();///这里我们改成了 将解码后的YUV数据转换成RGB32img_convert_ctx sws_getContext(pCodecCtx-width, pCodecCtx-height,AV_PIX_FMT_NV12, pCodecCtx-width, pCodecCtx-height,AV_PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL);numBytes avpicture_get_size(AV_PIX_FMT_RGB32, pCodecCtx-width,pCodecCtx-height);out_buffer (uint8_t *) av_malloc(numBytes * sizeof(uint8_t));avpicture_fill((AVPicture *) pFrameRGB, out_buffer, AV_PIX_FMT_RGB32,pCodecCtx-width, pCodecCtx-height);av_dump_format(pFormatCtx, 0, mFileName.toUtf8().data(), 0); //输出视频信息while (1){if (av_read_frame(pFormatCtx, packet) 0){break; //这里认为视频读取完了}if (packet.stream_index videoStream) {ret avcodec_send_packet(pCodecCtx, packet);if (ret 0) {printf(decode error.\n);return;}while (1) {ret avcodec_receive_frame(pCodecCtx, pFrame);if(ret AVERROR(EAGAIN) || ret AVERROR_EOF){break;}else if(ret 0){qDebug() Error while decoding;break;}ret av_hwframe_transfer_data(swFrame, pFrame, 0);if(ret 0){qDebug() Error transferring the data to system memory;break;}sws_scale(img_convert_ctx,(uint8_t const * const *) swFrame-data,swFrame-linesize, 0, pCodecCtx-height, pFrameRGB-data,pFrameRGB-linesize);static int index 0;qDebug() frame index;}}av_packet_unref(packet);msleep(30); //停一停 不然放的太快了}av_free(out_buffer);av_free(pFrameRGB);avcodec_close(pCodecCtx);avformat_close_input(pFormatCtx);hw_decoder_init static enum AVPixelFormat hw_pix_fmt; static AVBufferRef *hw_device_ctx NULL; static int hw_decoder_init(AVCodecContext *ctx, const enum AVHWDeviceType type) {int err 0;if ((err av_hwdevice_ctx_create(hw_device_ctx, type,NULL, NULL, 0)) 0) {fprintf(stderr, Failed to create specified HW device.\n);return err;}ctx-hw_device_ctx av_buffer_ref(hw_device_ctx);return err; }get_hw_format static enum AVPixelFormat get_hw_format(AVCodecContext *ctx,const enum AVPixelFormat *pix_fmts) {const enum AVPixelFormat *p;for (p pix_fmts; *p ! -1; p) {if (*p hw_pix_fmt)return *p;}fprintf(stderr, Failed to get HW surface format.\n);return AV_PIX_FMT_NONE; }
http://www.w-s-a.com/news/578415/

相关文章:

  • 做张家界旅游网站多少钱企业推广网络营销
  • 代做毕设网站推荐广东手机微信网站制作
  • 福州建设工程质量监督网站专业做公司宣传网站的
  • 百度云建站教程网站工程师是做什么的
  • 手机在线制作网站一级消防工程师考试试题及答案
  • 网站设计的需求网页制作教程和素材
  • 徐州网站建设 网站推广WordPress 文章编辑
  • 做什么网站比较受欢迎软件商店下载安装2023版本最新
  • 做ip资讯的网站怎么在wordpress中套用同行网页
  • 医院网站如何备案东莞优化公司收费
  • 罗村网站开发适合ps做图的素材网站有哪些
  • 网站建设中 油财宝企业网址怎么整
  • asp.net空网站php网站开发要学什么
  • 做可视化的网站微信网站模版下载
  • 包头移动的网站建设茂名建站价格
  • 网站文章内容一键排版功能铜山网站建设
  • cdr可不可做网站对网站建设起到计划和指导的作用
  • 合肥最好的网站建设网页设计心得体会2000字
  • 西安网站品牌建设门户网站类型
  • 网上做调查问卷的网站请人做网站域名和主机
  • 个人网站模板html5找公司网站建设
  • 找最新游戏做视频网站一个做网站的团队需要哪些人员
  • 威海市做网站的做网站很难吗
  • 广州房地产网站建设方案怎么免费申请网站
  • 免费生成网站软件下载影视公司名字取名
  • 网站公司提供程序免费的网页入口
  • jsp网站开发实例教学房产网站怎么做400电话
  • 网络营销方式及流程广州seo工作
  • 专业商城网站制作免费网页设计成品
  • 韩国优秀设计网站找做网站找那个平台做