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

FFMPEG 工具方法

av_strerror
int av_strerror	(	int 	errnum,
char * 	errbuf,
size_t 	errbuf_size
)
ffmpeg获取与设置mp4文件旋转方向方法

设置与获取都是对AVStream的dict操作.
设置

for (i = 0; i < ifmt_ctx_v->nb_streams; i++) {  //Create output AVStream according to input AVStream  if(ifmt_ctx_v->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO){  AVStream *in_stream = ifmt_ctx_v->streams[i];  AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);  videoindex_v=i;  if (!out_stream) {  printf( "Failed allocating output stream\n");  ret = AVERROR_UNKNOWN;  goto end;  }  videoindex_out=out_stream->index;  //Copy the settings of AVCodecContext  ret = av_dict_set(&out_stream->metadata,"rotate","90",0); //设置旋转角度  if(ret>=0)  {  printf("=========yes=====set rotate success!===\n");  }  if (avcodec_copy_context(out_stream->codec, in_stream->codec) < 0) {  printf( "Failed to copy context from input to output stream codec context\n");  goto end;  }  out_stream->codec->codec_tag = 0;  if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)  out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;  break;  }  }  

读取

for (i = 0; i < ifmt_ctx_v->nb_streams; i++) {  //Create output AVStream according to input AVStream  if(ifmt_ctx_v->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO){  AVStream *in_stream = ifmt_ctx_v->streams[i];  AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);  videoindex_v=i;  if (!out_stream) {  printf( "Failed allocating output stream\n");  ret = AVERROR_UNKNOWN;  goto end;  }  videoindex_out=out_stream->index;  //Copy the settings of AVCodecContext  ret = av_dict_set(&out_stream->metadata,"rotate","90",0); //设置旋转角度  if(ret>=0)  {  printf("=========yes=====set rotate success!===\n");  }  if (avcodec_copy_context(out_stream->codec, in_stream->codec) < 0) {  printf( "Failed to copy context from input to output stream codec context\n");  goto end;  }  out_stream->codec->codec_tag = 0;  if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)  out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;  break;  }  }  double g_rotate_theta = get_rotation(decoder->is_video);//is_video是video的AVStreamint rotate = 0;if (fabs(g_rotate_theta - 90) < 1.0){rotate = 90;}else if(fabs(g_rotate_theta - 180) < 1.0||fabs(g_rotate_theta + 180) < 1.0){rotate = 180;}else if(fabs(g_rotate_theta - 270) < 1.0||fabs(g_rotate_theta + 90) < 1.0){rotate = 270;}LOGI("get rotate is : %d" , rotate);metadata->rotate = rotate;
http://www.lryc.cn/news/419931.html

相关文章:

  • Qt QML 使用QPainterPath绘制弧形曲线和弧形文本
  • VMware虚拟机和Docker的备份与恢复
  • 新加坡服务器延迟大吗?如何进行优化
  • uniapp——列表图片加载太多且空间占用太大的处理方法(降低清晰度)
  • spring+SSM+Mybatis面试题(上)(30道)
  • odoo17 翻译一个小bug
  • sqli-labs-php7-master第5-10关
  • 全方位教程:接入视频美颜SDK与直播美颜插件的完整步骤
  • Apache Curator 分布式锁的介绍,以及案例
  • 自动化测试 — selenium + Java
  • 【SpringBoot系列】接口参数的默认值与必要性
  • 茶余饭后(五)
  • 【网络编程详解】
  • C# winform三层架构 实现增删改查( 显示数据,查询数据 显示,查询篇)
  • Apache Kylin 系列入门教程
  • 如何识别并防御漏洞扫描类攻击
  • 冷思考:低代码的AI Agent构建平台能创造价值吗?
  • Spring Boot如何自定义注解?
  • gin框架传入的gin.context参数是池化的
  • AWS注册是否必须使用美元银行卡
  • Spring IOC 注入的3种方式
  • 无人机影像基于机器学习的遥感反演及其结果可视化,定量遥感反演结果出图,相关性分析,指标筛选,特征选择
  • Eclipse插件之Java Dependency Viewer(显示类和包的关系图)
  • H5小游戏出海,如何流量变现?
  • 轻空间六大专利优势:引领气膜建筑新时代
  • LeetCode-day37-2940. 找到 Alice 和 Bob 可以相遇的建筑
  • unity 判断平台
  • PyCharm找不到Python了咋办
  • BRC-100 协议
  • 茶余饭后(六)