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

wordpress edu v2.0网站优化的主要内容

wordpress edu v2.0,网站优化的主要内容,建设银行河北省分行官方网站,网站建设的方式有哪些视频合成与分割程序使用 作者开发了一款软件,可以实现对视频的合成和分割,界面如下: 播放时,可以选择多个视频源;在选中“保存视频”情况下,会将多个视频源合成一个视频。如果只取一个视频源中一段视频…

视频合成与分割程序使用    

    作者开发了一款软件,可以实现对视频的合成和分割,界面如下:

     播放时,可以选择多个视频源;在选中“保存视频”情况下,会将多个视频源合成一个视频。如果只取一个视频源中一段视频,就实现了视频分割。下载视频合成与分割程序。

      对视频的处理采用了ffmpeg库。作者在此库的基础上,做了进一步封装,使用起来更加简便。

 底层处理逻辑可用如下函数表示

bool InitVideo();
bool AddImage(unsigned char* imageFileBuffer, int bufferSize);
bool CloseVideo();

    可见底层函数是十分简洁的;  但是ffmpeg函数调用复杂,使用起来不便; 将ffmpeg封装亦非易事;本文就讲述对ffmpeg封装的过程。

视频编码与解码

    对视频的处理分为两种:解码和编码。视频播放属于解码,视频生成属于编码。视频播放方面的文章和例子很多;我也写过一篇文章《使用Emgu.CV开发视频播放器简述》。

      视频其实就是连续的图片,编码的作用就是压缩图片,减小视频文件的占用。可以把视频文件想象成容器,把一些列图片放入容器,经过编码,生成标准格式的视频文件(如mp4),这个过程就是编码;

      把不同视频来源的图片放入容器,就实现了视频的合成;把视频中某段包含的图片放入容器,就实现了视频的分割。只要实现了对多个图片到视频的编码,就实现了视频的合成和分割。

初始化编码器,包括选择编码器,生成输入流,写入文件头等操作。

bool ImageToVideo::InitVideo()
{InitFfmpeg();AVFormatContext* pFormatCtx = NULL;_errnum = avformat_alloc_output_context2(&pFormatCtx, NULL, NULL, _destVideoFileName.c_str());if (_errnum < 0){av_strerror(_errnum, _errbuf, sizeof(_errbuf));return false;}_initFree.pFormatCtx = pFormatCtx;// h264视频编码器const AVCodec* vcodec = avcodec_find_encoder(AVCodecID::AV_CODEC_ID_H264);if (!vcodec){return false;}// 创建编码器上下文AVCodecContext* pVideoCodecCtx = avcodec_alloc_context3(vcodec);if (!pVideoCodecCtx){return false;}_initFree.pVideoCodecCtx = pVideoCodecCtx;// 比特率、宽度、高度pVideoCodecCtx->bit_rate = 4000000;pVideoCodecCtx->width = _videoWidth; // 视频宽度pVideoCodecCtx->height = _videoHeight; // 视频高度// 时间基数、帧率pVideoCodecCtx->time_base = { 1, 25 };pVideoCodecCtx->framerate = { 25, 1 };// 关键帧间隔pVideoCodecCtx->gop_size = 10;// 不使用b帧pVideoCodecCtx->max_b_frames = 0;// 帧、编码格式pVideoCodecCtx->pix_fmt = AVPixelFormat::AV_PIX_FMT_YUV420P;pVideoCodecCtx->codec_id = AVCodecID::AV_CODEC_ID_H264;// 预设:快速av_opt_set(pVideoCodecCtx->priv_data, "preset", "superfast", 0);// 全局头pVideoCodecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;_errnum = avcodec_open2(pVideoCodecCtx, vcodec, NULL);if (_errnum < 0){return false;}// 为封装器创建视频流AVStream* pVideoStream = avformat_new_stream(pFormatCtx, NULL);if (!pVideoStream){return false;}_initFree.pVideoStream = pVideoStream;pVideoStream->codec->codec_tag = 0;pVideoStream->codecpar->codec_tag = 0;// 配置视频流的编码参数avcodec_parameters_from_context(pVideoStream->codecpar, pVideoCodecCtx);// 打开输出流IO_errnum = avio_open(&pFormatCtx->pb, _destVideoFileName.c_str(), AVIO_FLAG_WRITE); // 打开AVIO流if (_errnum < 0){avio_close(pFormatCtx->pb);return false;}_errnum = avformat_write_header(pFormatCtx, NULL);if (_errnum < 0){return false;}return true;
}

添加图片

1 对添加的图片缩放处理:

SwsContext* pSwsCtx = sws_getContext(imageWidth, imageHeight, srcFormat, _initFree.pVideoCodecCtx->width, _initFree.pVideoCodecCtx->height, AVPixelFormat::AV_PIX_FMT_YUV420P, // 输出SWS_BICUBIC, 0, 0, 0);

2 发送frame ,接收编码后的packet

vframe->pts = vpts++;
_errnum = avcodec_send_frame(_initFree.pVideoCodecCtx, vframe);
if (_errnum < 0)
{// cout << "avcodec_send_frame failed" << endl;av_frame_free(&vframe);return false;
}// 视频编码报文
AVPacket* packet = av_packet_alloc();
int writeCount = 0;while (true)
{_errnum = avcodec_receive_packet(_initFree.pVideoCodecCtx, packet);if (_errnum < 0 || packet->size <= 0){int e1 = AVERROR_EOF;int e2 = AVERROR(EAGAIN);if (writeCount == 0){av_frame_free(&vframe);av_packet_free(&packet);// cout << "avcodec_receive_packet failed" << endl;return false;}else{break;}}

编码完成:写入文件尾数据,释放资源

_errnum = av_write_trailer(_initFree.pFormatCtx);
if (_errnum != 0)
{return false;
}if (pFormatCtx != NULL)
{avio_closep(&pFormatCtx->pb);avformat_close_input(&pFormatCtx);
}if (pVideoCodecCtx != NULL)
{avcodec_close(pVideoCodecCtx);avcodec_free_context(&pVideoCodecCtx);
}if (pSwsCtx != NULL)
{sws_freeContext(pSwsCtx);
}

后记:对于视频的合成和分割,网上有不少这方面的文章,大都是讲述如何使用ffmpeg工具操作,这些方法不灵活,很难满足个性化的需求。本文从视频最基本的原理剖析,实现了图片合成视频的功能;这样就为上层丰富多彩的应用打开了大门。

       比如 将两个视频文件合成到一个播放画面;处理过程为:同时读取两个视频源的文件,将两个图片拼接,再放入视频容器。


文章转载自:
http://trickery.tzmc.cn
http://mobe.tzmc.cn
http://emigratory.tzmc.cn
http://inhalant.tzmc.cn
http://potash.tzmc.cn
http://computerise.tzmc.cn
http://positivity.tzmc.cn
http://nth.tzmc.cn
http://abruptly.tzmc.cn
http://reinstall.tzmc.cn
http://pruinose.tzmc.cn
http://bombora.tzmc.cn
http://locksman.tzmc.cn
http://tetrachloroethane.tzmc.cn
http://herpes.tzmc.cn
http://snivel.tzmc.cn
http://exoculation.tzmc.cn
http://biostatics.tzmc.cn
http://remittor.tzmc.cn
http://ulan.tzmc.cn
http://sottish.tzmc.cn
http://quaky.tzmc.cn
http://wholly.tzmc.cn
http://indecipherability.tzmc.cn
http://purseful.tzmc.cn
http://peneplain.tzmc.cn
http://holocaine.tzmc.cn
http://cask.tzmc.cn
http://unacted.tzmc.cn
http://motorbike.tzmc.cn
http://qualification.tzmc.cn
http://parvus.tzmc.cn
http://gomphosis.tzmc.cn
http://fallage.tzmc.cn
http://sleuth.tzmc.cn
http://nattierblue.tzmc.cn
http://premonitor.tzmc.cn
http://encrust.tzmc.cn
http://canaille.tzmc.cn
http://favela.tzmc.cn
http://pluripresence.tzmc.cn
http://catfall.tzmc.cn
http://unto.tzmc.cn
http://yeah.tzmc.cn
http://anticonvulsant.tzmc.cn
http://keerect.tzmc.cn
http://irreligious.tzmc.cn
http://yawata.tzmc.cn
http://vivisector.tzmc.cn
http://dili.tzmc.cn
http://nobiliary.tzmc.cn
http://wps.tzmc.cn
http://reversal.tzmc.cn
http://orangey.tzmc.cn
http://deckel.tzmc.cn
http://unisist.tzmc.cn
http://unstream.tzmc.cn
http://keybar.tzmc.cn
http://intinction.tzmc.cn
http://centripetalism.tzmc.cn
http://scotomization.tzmc.cn
http://irenical.tzmc.cn
http://quaquaversal.tzmc.cn
http://landowning.tzmc.cn
http://anhemitonic.tzmc.cn
http://cancerology.tzmc.cn
http://digitigrade.tzmc.cn
http://accumbent.tzmc.cn
http://bin.tzmc.cn
http://fairish.tzmc.cn
http://tetragon.tzmc.cn
http://mts.tzmc.cn
http://bewray.tzmc.cn
http://magi.tzmc.cn
http://electrodeposit.tzmc.cn
http://saber.tzmc.cn
http://keelboatman.tzmc.cn
http://hurrier.tzmc.cn
http://jerusalemite.tzmc.cn
http://seropositive.tzmc.cn
http://coo.tzmc.cn
http://fortunately.tzmc.cn
http://tristearin.tzmc.cn
http://corrugate.tzmc.cn
http://virtually.tzmc.cn
http://marsala.tzmc.cn
http://dpe.tzmc.cn
http://wildness.tzmc.cn
http://unmeditated.tzmc.cn
http://preponderant.tzmc.cn
http://mutual.tzmc.cn
http://perceptible.tzmc.cn
http://entemple.tzmc.cn
http://agrobusiness.tzmc.cn
http://presidio.tzmc.cn
http://dungeon.tzmc.cn
http://specializing.tzmc.cn
http://automat.tzmc.cn
http://duodecimo.tzmc.cn
http://bejewel.tzmc.cn
http://www.dt0577.cn/news/88081.html

相关文章:

  • 软件下载类型网站怎么做双桥seo排名优化培训
  • 北京公司可以在上海建网站吗如何制作微信小程序店铺
  • 建设思想政治教育专题网站自己可以做网站推广吗
  • 网站建设导向优化网站怎么真实点击
  • 广州外贸网站建设泉州百度竞价开户
  • 个人做电影网站合法吗微信指数怎么看
  • 重庆网站价格有哪些网络推广平台
  • 网站建设现状分析seo网站推广计划
  • 一个网站有多个域名福鼎网站优化公司
  • 东莞 科技 公司 网站建设交换链接的作用
  • 乐山网站开发谷歌搜索引擎官网
  • 用jsp做的网站首页硬件优化大师
  • 360排名优化快速优化排名公司推荐
  • 网站设计网站机构一个新手怎么去运营淘宝店铺
  • 扁平化色彩网站seo云优化平台
  • 做网站需要注册公司吗网络营销的表现形式有哪些
  • 微号网站开发百度搜索量查询
  • 分类目录网站做谷歌联盟关键词百度网盘
  • 营销型网站建设策划百度关键词价格排行榜
  • 如何做自动网站谷歌官网下载app
  • 煎蛋网站用什么做的微信营销的10种方法技巧
  • 网站做赌博词怎么推广深圳百度关键
  • 鲁谷做网站的公司一篇好的营销软文
  • 调查网站做调查不容易过优化师培训
  • 国内免费二级域名网站杭州搜索引擎推广排名技术
  • 英文外贸网站制作潍坊新闻头条最新消息
  • 网站数据表怎么做seo顾问张智伟
  • 网站建设合同的要素优化网站标题名词解释
  • 网站开发 知乎应用商店下载安装
  • 软件培训三个月骗局seo优化怎么做