• FFmpeg使用c语言sdk实现打印视频的信息


    主要使用函数

    ffmpeg中的所有编解码库,网络协议注册到程序里面来:av_register_all()

    打开一个多媒体文件:avformat_open_input()

    关闭一个多媒体文件:avformat_close_input()

    打印meta信息:av_dump_format()

    实例

    vim meta_info.c

    #include <libavutil/log.h>
    #include <libavformat/avformat.h>
    
    int main(int argc, char *argv[])
    {
      int ret;
      // 文件上下文
      AVFormatContext *fmt_ctx = NUll;
      
      // 初始化logo
      av_log_set_level(AV_LOG_INFO);
      
      // 全局注册ffmpeg的函数
      av_register_all();
      
      // 打开多媒体文件
      ret = avformat_open_input(&fmt_ctx, "./test.mp4", NULL, NULL);
      if (ret < 0){
        av_log(NULL, AV_LOG_ERROR, "找不到文件:%s", av_err2str(ret));
        
        return -1;
      }
      
      // 第一个产生是文件上下文, 第二个参数默认0就可以 , 最后一个代表是输入流还是输出流
      av_dump_format(fmt_ctx, 0, "./test.mp4", 0);
      
      avformat_close_input(&fmt_ctx);
      
      
      return 0;
    }
    

    clang -g -o meta_info meta_info.c pkg-config --libs libavformat libavutil

  • 相关阅读:
    dom4j 创建XML文件
    Convert.ToInt32()与int.Parse()的区别
    委托
    工厂模式
    策略模式
    大型网站架构演化
    字符串反转(面试)
    switch(面试)
    带宽计算
    新语法
  • 原文地址:https://www.cnblogs.com/fandx/p/12123337.html
Copyright © 2020-2023  润新知