zoukankan      html  css  js  c++  java
  • C++配置ffmpeg

    C++配置ffmpeg

    可以从这个地址下载ffmpeg开发库https://www.gyan.dev/ffmpeg/builds/

    下载完成后的配置情况与配置SDL是类似的。参考https://www.cnblogs.com/zzr-stdio/p/14514043.html

    注意:从这里下载的ffmpeg是64位版本的

    打开视频文件示例:

    #include <iostream>
    extern "C" {
    #include<libavcodec/avcodec.h>
    #include<libavformat/avformat.h>
    #include<libavutil/avutil.h>
    #include<libavutil/opt.h>
    }
    
    #pragma comment(lib, "avcodec.lib")
    #pragma comment(lib, "avformat.lib")
    #pragma comment(lib, "avutil.lib")
    using namespace std;
    int main()
    {
        AVFormatContext* pFormat = nullptr;
        string path(R"(11.mp4)");
        int ret = avformat_open_input(&pFormat, path.c_str(), nullptr, nullptr);//打开视频文件
        if (ret)
        {
            cout << "avformat_open_input failed" << endl;
            return -1;
        }
        ret = avformat_find_stream_info(pFormat, nullptr);//查询视频流信息
        if (ret)
        {
            cout << "avformat_open_input failed" << endl;
            return -1;
        }
        av_dump_format(pFormat, 0, nullptr, 0);//在控制台中打印该视频文件的信息。
        getchar();
    }
    

    打开直播流示例:

    #include <iostream>
    extern "C" {
    #include<libavcodec/avcodec.h>
    #include<libavformat/avformat.h>
    #include<libavutil/avutil.h>
    #include<libavutil/opt.h>
    }
    
    #pragma comment(lib, "avcodec.lib")
    #pragma comment(lib, "avformat.lib")
    #pragma comment(lib, "avutil.lib")
    using namespace std;
    int main()
    {
        AVFormatContext* pFormat = nullptr;
        string path(R"(http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8)");
        AVDictionary* opt = nullptr;
        av_dict_set(&opt, "rtsp_transport", "tcp", 0);
        av_dict_set(&opt, "rtsp_delay", "550", 0);
        int ret = avformat_open_input(&pFormat, path.c_str(), nullptr, &opt);//打开网络直播地址
        if (ret)
        {
            cout << "avformat_open_input failed" << endl;
            return -1;
        }
        ret = avformat_find_stream_info(pFormat, nullptr);//查询视频流信息
        if (ret)
        {
            cout << "avformat_open_input failed" << endl;
            return -1;
        }
        av_dump_format(pFormat, 0, nullptr, 0);//在控制台中打印该视频文件的信息。
        getchar();
    }
    
  • 相关阅读:
    go语言基础之安装go开发环境和beego
    mysql之事件的开启和调用
    系统和应用监控指标
    常用的17个运维监控系统(必备知识)
    Kafka Java API操作topic
    Linux安装mysql8.0
    mybatis+Oracle 批量插入数据,有数据做更新操作
    ORACLE数据库导出表,字段名,长度,类型,字段注释,表注释语句
    ORACLE 按时间创建分区表
    oracle创建表空间和用户
  • 原文地址:https://www.cnblogs.com/zzr-stdio/p/14526982.html
Copyright © 2011-2022 走看看