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

网页游戏如何制作百度自然排名优化

网页游戏如何制作,百度自然排名优化,公司网站建设华为,公众号 导入wordpress操作系统:ubuntu 注意事项: 1.ts文件顺序必须正确,也就是下一帧的dst和pst要比上一帧的大,否则会报错 2.codecpar->codec_tag要设置为0,否则报错Tag [27][0][0][0] incompatible with output codec id ‘27’ (avc1…

操作系统:ubuntu
注意事项:
1.ts文件顺序必须正确,也就是下一帧的dst和pst要比上一帧的大,否则会报错
2.codecpar->codec_tag要设置为0,否则报错Tag [27][0][0][0] incompatible with output codec id ‘27’ (avc1)
3.设置output的max_streams数目,默认是1000,超过此数目就会报错


#include <iostream>
#include <dirent.h>
#include <vector>extern "C" {
#include "include/libavformat/avformat.h"
#include "include/libavcodec/avcodec.h"
}//#pragma comment(lib,"avformat.lib")
//#pragma comment(lib,"avcodec.lib")using namespace std;int ts2Mp4(const string,const string,int);int main(int argc, char* argv[])
{//const string ts_filename = argv[1];//const string output_filename = "../1.mp4";//argv[2];ts2Mp4(argv[1],argv[2],atoi(argv[3]));return 0;
}int ts2Mp4(const string ts_path,const string mp4_path,int ts_count){/*vector<string> ts_list;DIR *pDir;struct dirent* ptr;if(!(pDir = opendir(ts_path.c_str()))){printf("cannot open ts dir\n");return -1;}while((ptr = readdir(pDir))!=0) {if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name,"..")!=0){ts_list.push_back(ptr->d_name);}}closedir(pDir);*/// create output context AVFormatContext* output_ctx = NULL;if (avformat_alloc_output_context2(&output_ctx, NULL, NULL, mp4_path.c_str()) < 0) {fprintf(stderr, "Failed to create output context\n");return -1;}//set the max streams number,default is 1000output_ctx->max_streams=3000;int video_stream_idx = -1;vector<AVFormatContext*> input_ctx_list;for(int i=0;i<ts_count;i++){// open input file char ts[256];sprintf(ts,"%s%s%d%s",ts_path.c_str(),"/",i,".ts");//string ts=tmp;printf("%s\n",ts);if(strcmp(".ts",strstr(ts,".ts"))!=0) continue;AVFormatContext* input_ctx = NULL;if (avformat_open_input(&input_ctx, ts, NULL, NULL) != 0) {fprintf(stderr, "Failed to open input file '%s'\n", ts);return -1;}if (avformat_find_stream_info(input_ctx, NULL) < 0) {fprintf(stderr, "Failed to retrieve input stream information\n");return -1;}input_ctx_list.push_back(input_ctx);// add streams for (int i = 0; i < input_ctx->nb_streams; i++) {AVStream* in_stream = input_ctx->streams[i];AVCodecParameters* in_codecpar = in_stream->codecpar;if (in_codecpar->codec_type == AVMEDIA_TYPE_VIDEO || in_codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {AVStream* out_stream = avformat_new_stream(output_ctx, NULL);if (!out_stream) {fprintf(stderr, "Failed to allocate output stream\n");return -1;}if (avcodec_parameters_copy(out_stream->codecpar, in_codecpar) < 0) {fprintf(stderr, "Failed to copy codec parameters\n");return -1;}out_stream->codecpar->codec_tag = 0;if (in_codecpar->codec_type == AVMEDIA_TYPE_VIDEO)video_stream_idx = out_stream->index;}}}// open output file if (!(output_ctx->oformat->flags & AVFMT_NOFILE)) {if (avio_open(&output_ctx->pb, mp4_path.c_str(), AVIO_FLAG_WRITE) < 0) {fprintf(stderr, "Could not open output file '%s'\n", mp4_path.c_str());return -1;}}// write header if (avformat_write_header(output_ctx, NULL) < 0) {fprintf(stderr, "Error occurred when opening output file\n");return -1;}int pkt_cnt = 0;// copy packets //int stream_index = 0;for(int i=0;i<input_ctx_list.size();i++){AVFormatContext* input_ctx=input_ctx_list[i];AVPacket packet;int ret = 0;while (av_read_frame(input_ctx, &packet) >= 0) {//printf("%d,%d\n",video_stream_idx,packet.stream_index);AVStream* in_stream = input_ctx->streams[packet.stream_index];AVStream* out_stream = output_ctx->streams[packet.stream_index];// copy packetpacket.pts = av_rescale_q_rnd(packet.pts, in_stream->time_base, out_stream->time_base,(AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));packet.dts = av_rescale_q_rnd(packet.dts, in_stream->time_base, out_stream->time_base,(AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));packet.duration = av_rescale_q(packet.duration, in_stream->time_base, out_stream->time_base);//printf("%ld,%ld,%ld\n",packet.pts,packet.dts,packet.duration);packet.pos = -1;if (packet.stream_index == video_stream_idx) {//printf("Send video %8d\n", pkt_cnt);pkt_cnt++;}ret = av_interleaved_write_frame(output_ctx, &packet);if (ret < 0) {fprintf(stderr, "Error muxing packet\n");break;}av_packet_unref(&packet);}// close input avformat_close_input(&input_ctx);}// write trailer if (av_write_trailer(output_ctx) < 0) {fprintf(stderr, "Error occurred when writing trailer\n");return -1;}// close output if (output_ctx && !(output_ctx->oformat->flags & AVFMT_NOFILE))avio_closep(&output_ctx->pb);avformat_free_context(output_ctx);printf("convert success!\n"); return 0;
}
http://www.wangmingla.cn/news/48193.html

相关文章:

  • 新手学建设网站书籍内容营销成功案例
  • 深圳设计网站有哪些搜索引擎营销的英文缩写是
  • ui是做网站的吗免费的推广网站
  • php商务网站开发代码seo免费资源大全
  • 青岛同拓网站建设有限公司公司网站怎么建立
  • 怎样利用网站做引流互联网营销怎么赚钱
  • 传奇世界网页版平台通州优化公司
  • 怎么做阿里巴巴国际网站首页全网整合营销公司
  • 广东最新疫情今天新增伟哥seo博客
  • wap网站制作教程免费网站做seo
  • 宜昌今日头条新闻长沙网站优化对策
  • 买下云服务器怎么做网站苏州网站维护
  • wordpress更改首页模板aso安卓优化
  • wordpress的FTP帐号长春seo结算
  • 中国电信 网站备案东莞seo建站推广费用
  • 零下一度网站建设推广网络推广平台
  • wordpress 多站点 插件宁德市住房和城乡建设局
  • 怎么做类似淘宝一样的网站创建网站的基本流程
  • 银河星宇 网站建设百度关键词优化多少钱
  • 网站前端是什么网站建设费用明细表
  • 西地那非片怎么服用最佳优化大师专业版
  • 需要做网站的企业资源军事新闻最新消息今天
  • 怎么建立自己的网站平台多少钱推广方案的内容有哪些
  • 二手房发布网站怎么做浙江疫情最新情况
  • 在阿里云做视频网站需要什么专业培训机构
  • 娄底网站建设优化企业外链发布平台大全
  • 形象设计师培训网课seo主管招聘
  • 怎么才能百度做网站腾讯会议多少钱一个月
  • 商丘做网站公司百度快照和广告的区别
  • 网站后台文章编辑不了500强企业seo服务商