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

wordpress 多语言 站点怎样免费制作网站

wordpress 多语言 站点,怎样免费制作网站,建筑企业资质怎么查,法律电商如何做网站推广营销前言 话不多说#xff0c;重走霄骅登神路 前一篇文章 [音视频学习笔记]六、自制音视频播放器Part1 -新版本ffmpeg#xff0c;Qt VS2022#xff0c;都什么年代了还在写传统播放器#xff1f; 本文相关代码仓库#xff1a; MediaPlay-FFmpeg - Public 转载雷神的两个流程…前言 话不多说重走霄骅登神路 前一篇文章 [音视频学习笔记]六、自制音视频播放器Part1 -新版本ffmpegQt VS2022都什么年代了还在写传统播放器 本文相关代码仓库 MediaPlay-FFmpeg - Public 转载雷神的两个流程图挺实用的不过现在接口有一些小修改可能有点不一样了 流程 首先定义了一些变量包括用于存储视频帧的缓冲区 buf标记是否为视频流的 isVideo以及一些用于处理视频的结构体和指针。 创建并初始化 AVFormatContext 结构体 ptr_formatCtx并打开视频文件以获取音视频流数据信息。 使用 avformat_find_stream_info 函数获取音视频流信息并通过循环找到视频流的索引 streamIndex。 检查是否成功找到视频流判断 ptr_formatCtx-streams[i]-codecpar-codec_type AVMEDIA_TYPE_VIDEO 如果没有找到则退出。 分配并初始化 AVCodecContext 结构体 ptr_avctx并根据流的参数找到AVCodecParameters将其放在ptr_formatCtx-streams[streamIndex]-codecpar。找到对应视频流的解码器avcodec_find_decoder并检查。 使用 avcodec_open2 函数打开解码器初始化ptr_avctx准备解码视频帧。 分配并初始化 AVPacket 结构体 ptr_avpkg以及视频帧的空间 ptr_avframe和 ptr_avframeRGB。 为图像数据存储空间 buf 分配内存并根据视频的宽高调整窗口大小。 初始化 SwsContext 结构体 ptr_swsCtx用于图像的缩放和格式转换。 进入循环不断读取视频数据帧并解码、处理、显示。 在循环中通过 av_read_frame 读取视频帧数据然后使用 avcodec_send_packet将数据发送给解码器进行解码使用avcodec_receive_frame解码视频数据并将解码后的图像数据经过格式转换后显示在界面上。 循环中还包含了处理视频播放状态的逻辑包括播放、暂停和结束播放等情况。 最后释放相关资源包括 SwsContext 结构体、图像帧内存和解码器等。 需要注意的点 播放延时 我们在播放的时候实际上是需要提供延时的但是又不能直接QThread::msleep(10)因为画面的渲染在主线程上进行而主线程是严格禁止msleep(10)的否则容易崩溃所以采用以下方式 //延时, 不能直接sleep延时UI主线程不能直接被阻塞不然会有问题的 void delay(int ms) {QTime stopTime;stopTime.start();//qDebug()start:QTime::currentTime().toString(HH:mm:ss.zzz);while(stopTime.elapsed() ms)//stopTime.elapsed()返回从start开始到现在的毫秒数{QCoreApplication::processEvents();}//qDebug()stop :QTime::currentTime().toString(HH:mm:ss.zzz); }播放速度 播放速度实际上就是通过影响上述的delay来实现的在播放的过程中通过对应的值影响延时从而修改播放速度。 项目效果 核心代码 #include ../include/MediaPlay_Core.hMediaPlay_Core::MediaPlay_Core() {}MediaPlay_Core::~MediaPlay_Core() {}void MediaPlay_Core::register_func(func_frame func) {this-callback func; }int MediaPlay_Core::playVideo(const char* videopath) {unsigned char* buf;bool blnVideo false;int ret, gotPicture;unsigned int streamIndex 0;const AVCodec* ptr_codec nullptr;AVPacket* ptr_avpkg nullptr;AVCodecContext* ptr_avctx nullptr;AVFrame* ptr_avframe, * ptr_avframeRGB nullptr;AVFormatContext* ptr_formatCtx nullptr;struct SwsContext* ptr_swsCtx nullptr;this-videoUrl QString::fromLocal8Bit(videopath);int width 0;int height 0;//创建AVFormatContextptr_formatCtx avformat_alloc_context();//初始化ptr_formatCtx if (avformat_open_input(ptr_formatCtx, videopath, nullptr, nullptr) ! 0) {qDebug() AVFormat open input Error;return -1;}//获取音频流数据信息if (avformat_find_stream_info(ptr_formatCtx, nullptr) 0) {avformat_close_input(ptr_formatCtx);qDebug() AVFormat find stream info Error;return -2;}//找到视频流的索引for (int i 0; i ptr_formatCtx-nb_streams; i) {if (ptr_formatCtx-streams[i]-codecpar-codec_type AVMEDIA_TYPE_VIDEO) {streamIndex i;blnVideo true;break;}}//没有找到视频流则直接退出if (!blnVideo) {avformat_close_input(ptr_formatCtx);qDebug() nv_streams error;return -3;}//获取视频流编码ptr_avctx avcodec_alloc_context3(nullptr);//查找编码器avcodec_parameters_to_context(ptr_avctx, ptr_formatCtx-streams[streamIndex]-codecpar);ptr_codec avcodec_find_decoder(ptr_avctx-codec_id);if (!ptr_codec) {avcodec_close(ptr_avctx);avformat_close_input(ptr_formatCtx);qDebug() Cant find decoder;return -4;}//初始化ptr_avctxif (avcodec_open2(ptr_avctx, ptr_codec, nullptr) 0) {avcodec_close(ptr_avctx);avformat_close_input(ptr_formatCtx);qDebug() avcodec_open2 err.;return -5;}//初始化ptr_avpkgptr_avpkg (AVPacket*)av_malloc(sizeof(AVPacket));//初始化数据帧空间ptr_avframe av_frame_alloc();ptr_avframeRGB av_frame_alloc();//创建图像数据存储buf//av_image_get_buffer_size一帧大小buf (unsigned char*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_RGB32, ptr_avctx-width, ptr_avctx-height, 1));av_image_fill_arrays(ptr_avframeRGB-data, ptr_avframeRGB-linesize, buf, AV_PIX_FMT_RGB32, ptr_avctx-width, ptr_avctx-height, 1);width ptr_avctx-width;height ptr_avctx-height;//初始化ptr_swsCtxptr_swsCtx sws_getContext(ptr_avctx-width, ptr_avctx-height, ptr_avctx-pix_fmt, ptr_avctx-width, ptr_avctx-height, AV_PIX_FMT_RGB32, SWS_BICUBIC, nullptr, nullptr, nullptr);//尝试循环读取视频数据while (true) {if (this-state_playVideo PlayState::Video_Playing) { // 正在播放if (av_read_frame(ptr_formatCtx, ptr_avpkg) 0) { //读取一帧未解码的数据//如果是视频数据if (ptr_avpkg-stream_index (int)streamIndex) {// 将数据发送给解码器进行解码ret avcodec_send_packet(ptr_avctx, ptr_avpkg);if (ret 0) {qDebug() 发送数据包到解码器时发生错误: ret;continue; // 处理错误情况并继续读取下一帧数据}//解码视频数据ret avcodec_receive_frame(ptr_avctx, ptr_avframe);if (ret AVERROR(EAGAIN) || ret AVERROR_EOF){av_packet_unref(ptr_avpkg); // 释放解码后的帧数据continue; // 没有可解码的帧数据或者已经解码完毕继续读取下一帧}if (ret 0) {qDebug() Decode error;continue;}// 处理解码后的图像帧sws_scale(ptr_swsCtx, (const unsigned char* const*)ptr_avframe-data, ptr_avframe-linesize, 0, ptr_avctx-height, ptr_avframeRGB-data, ptr_avframeRGB-linesize);if(this-callback ! nullptr)this-callback((uchar*)ptr_avframeRGB-data[0], width, height);av_frame_unref(ptr_avframe);}}else {break;}}else if (this-state_playVideo PlayState::Video_Finish)//播放结束{break;}else//暂停{delay(300);}}//释放资源sws_freeContext(ptr_swsCtx);av_frame_free(ptr_avframeRGB);av_frame_free(ptr_avframe);avcodec_close(ptr_avctx);avformat_close_input(ptr_formatCtx);this-state_playVideo PlayState::Video_Finish;qDebug() play finish!;return 0; }void MediaPlay_Core::VideoPlayControl(bool blnPlay) {if (blnPlay) {if (this-state_playVideo ! PlayState::Video_Playing) {this-state_playVideo PlayState::Video_Playing;playVideo(this-videoUrl.toLocal8Bit().data());}else {this-state_playVideo PlayState::Video_Playing;}}else {if (this-state_playVideo PlayState::Video_Playing) {this-state_playVideo PlayState::Video_Pause;}} }void MediaPlay_Core::VideoPlayEnd() {//停止播放视频this-state_playVideo PlayState::Video_Finish; }void MediaPlay_Core::delay(int msc) {QTime stopTime;stopTime.start();while (stopTime.elapsed() msc)//stopTime.elapsed()返回从start开始到现在的毫秒数{QCoreApplication::processEvents();} } .
http://www.pierceye.com/news/63704/

相关文章:

  • 洛阳建站洛阳市网站建设wordpress茶叶主题
  • 网站导航栏按钮企业网站建设渠道
  • 西安市建设局网站邯郸做网站代理
  • 个人网站推荐免费电气网站设计
  • 一起做网店官方网站公司网站的定义
  • 青海城乡建设部网站首页八零云自助建站免费建站平台
  • 网站建设兼职平台邢台市住建局
  • 网站项目实施方案腾讯云服务器搭建WordPress
  • 简述网站设计基本流程动态站 网站地图怎么做
  • 完整网站建设案例教程网页设计企业宣传网站
  • 阿里巴巴网站做销售方案重庆响应式网站建设
  • 网站注销申请表离职模板网
  • 河南做网站推广哪个好建设pc 移动网站
  • 专做排名的网站电商网站 外包
  • 我的世界是谁做的视频网站导购网站一站式建站
  • 免费的写作网站物联网的含义是什么意思
  • 有了网站模板 还要怎样做网页设计在哪里接单
  • 建设网站需要什么基础知识莆田网站开发公司电话
  • 怎么把asp网站改成php太原关键词排名推广
  • 域名解析站长工具建筑工程网价是什么意思
  • 阿里云建站售前咨询2023年ppt模板免费
  • 文昌湖城乡建设局网站织梦高端大气网站模板
  • 网站免费空间哪个好更改wordpress语言设置
  • 建站小软件山西网站制作工具
  • 上海网站原型设计wordpress 点赞 ajax
  • 手机个人简历模板下载网站模板wordpress 3.3.1漏洞
  • mvc网站开发视频企业网站模板官网
  • 网站互联网接入商网站制作和如何推广
  • 乐山做美食推荐的网站做数码相的网站
  • 菏泽外贸网站建设公司东莞做网站哪个公司好