ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

windows10-msys2-msvc编译ffmpeg4.4.2

2022-08-24 20:30:48  阅读:347  来源: 互联网

标签:comment msys2 ffmpeg lib -- pacman windows10 pragma msvc


  1. 下载msys2

在msys2安装目录下创建文件
msys2_ffmpeg.bat

call "D:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"

set MSYS2_PATH_TYPE=inherit
msys2_shell.cmd

测试

echo $LIB
  1. 准备环境

双击运行 msys2_ffmpeg.bat

pacman -S diffutils make pkg-config yasm nasm

说明

pacman -S nasm #汇编工具,安装
pacman -S yasm #汇编工具,安装
pacman -S make #项目编译工具,必须安装 
pacman -S diffutils #比较工具,ffmpeg configure 生成makefile时会用到,若不安装会警告,最好是安装 
pacman -S pkg-config #库配置工具,编译支持x264和x265用到 
pacman -S base-devel # 安装基本开发组件
pacman -S binutils #包含ld等命令
pacman -S automake
  1. 下载ffmpeg
wget https://ffmpeg.org/releases/ffmpeg-4.4.2.tar.xz
手动解压
  1. 编译
./configure \
    --prefix=../ffmepg-4.4-win64-msvc \
    --enable-static \
    --enable-gpl \
    --enable-version3 \
    --enable-nonfree \
    --enable-shared \
    --disable-doc \
    --disable-pthreads \
    --enable-w32threads \
    --enable-ffmpeg \
    --toolchain=msvc \
    --arch=x86_64

make -j8
make install
  1. 使用
#include <stdio.h>

extern "C" {
  #include "libavcodec/avcodec.h"
  #include "libavformat/avformat.h"
  #include "libavfilter/buffersink.h"
  #include "libavfilter/buffersrc.h"
  #include "libavutil/opt.h"
  #include "libavfilter/avfilter.h"
}

#pragma comment(lib, "libavcodec.a")
#pragma comment(lib, "libavdevice.a")
#pragma comment(lib, "libavfilter.a")
#pragma comment(lib, "libavformat.a")
#pragma comment(lib, "libavutil.a")
#pragma comment(lib, "libswresample.a")
#pragma comment(lib, "libswscale.a")
#pragma comment(lib, "libpostproc.a")

#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "Mfuuid.lib")
#pragma comment(lib, "Strmiids.lib")
#pragma comment(lib, "Mfplat.lib")
#pragma comment(lib, "Bcrypt.lib")
#pragma comment(lib, "Secur32.lib")


int main()
{
    char filepath[] = "input.mkv";

    AVFormatContext* pFormatCtx = avformat_alloc_context();

    av_log_set_level(AV_LOG_DEBUG);
    if (avformat_open_input(&pFormatCtx, filepath, NULL, NULL) != 0) {
        printf("Couldn't open input stream.\n");
        return -1;
    }
    else {
        printf("open success");
    }

    avformat_close_input(&pFormatCtx);

    return 0;
}


参考:
window10_ffmpeg-msys2-msvc编译 - 弦外之音

Windows MSVC2019 MSYS2编译ffmpeg_xuexixhp的技术博客_51CTO博客

标签:comment,msys2,ffmpeg,lib,--,pacman,windows10,pragma,msvc
来源: https://www.cnblogs.com/baigoogledu/p/16621451.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有