ffmpeg在clion下的引入

1、在MAC先查看当前安装的ffmpeg的路径

如果没有安装,可以执行安装命令 brew install ffmpeg

确定ffmpeg的安装位置

brew info ffmpeg

在clion的新建项目的中修改CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
project(ffmpeg_base)   //内部是项目名称 

set(CMAKE_C_STANDARD 11)

# FFmpeg的安装目录,可以通过命令"brew info ffmpeg"获取
set(FFMPEG_DIR /usr/local/Cellar/ffmpeg/4.4)
# 头文件搜索路径
include_directories(${FFMPEG_DIR}/include/)
# 动态链接库或静态链接库的搜索路径
link_directories(${FFMPEG_DIR}/lib/)

add_executable(ffmpeg_base main.c)      
target_link_libraries(ffmpeg_base
        swscale swresample avcodec avutil avdevice avfilter avformat
        )   // 注意第一个参数是项目的名称

之后运行ffmpeg官方提供的获取元数据实例程序(metadata.c)来来测试ffmpeg是否配置成功

/**
 * @file
 * Shows how the metadata API can be used in application programs.
 * @example metadata.c
 */

#include <stdio.h>

#include <libavformat/avformat.h>
#include <libavutil/dict.h>

int main (int argc, char **argv) {
  AVFormatContext *fmt_ctx = NULL;
  AVDictionaryEntry *tag = NULL;
  int ret;

    if (argc != 2) {
        printf("usage: %s <input_file>\n"
               "example program to demonstrate the use of the libavformat metadata API.\n"
               "\n", argv[0]);
        return 1;
    }

  if ((ret = avformat_open_input(&fmt_ctx, argv[1], NULL, NULL)))
    return ret;

  if ((ret = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
    av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
    return ret;
  }

  while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
    printf("%s=%s\n", tag->key, tag->value);

  avformat_close_input(&fmt_ctx);
  return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值