小编DDo*_*nko的帖子

C++ FFmpeg 创建 mp4 文件

我正在尝试使用 FFmpeg 和 C++ 创建 mp4 视频文件,但结果我收到损坏的文件(Windows 播放器显示“无法播放 ... 0xc00d36c4”)。如果我创建 .h264 文件,它可以用 'ffplay' 播放并通过 CL 成功转换为 mp4。

我的代码:

int main() {
    char *filename = "tmp.mp4";
    AVOutputFormat *fmt;
    AVFormatContext *fctx;
    AVCodecContext *cctx;
    AVStream *st;

    av_register_all();
    avcodec_register_all();

    //auto detect the output format from the name
    fmt = av_guess_format(NULL, filename, NULL);
    if (!fmt) {
        cout << "Error av_guess_format()" << endl; system("pause"); exit(1);
    }

    if (avformat_alloc_output_context2(&fctx, fmt, NULL, filename) < 0) {
        cout << "Error avformat_alloc_output_context2()" << endl; system("pause"); exit(1);
    }


    //stream creation + …
Run Code Online (Sandbox Code Playgroud)

c++ video ffmpeg libavcodec libavformat

10
推荐指数
2
解决办法
2万
查看次数

将字节数组从 Unity C# 传递到 C++ 插件

我正在尝试将原始纹理数据从Texture2D(字节数组)传递到非托管C++ 代码。在 C# 代码中,数组长度约为 1.5kk,但在 C++ 中,“sizeof”始终返回 8。

本机方法的 C# 声明:

[DllImport("LibName", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ProcessData(byte[] data);
Run Code Online (Sandbox Code Playgroud)

C++:

extern "C" {
    __declspec(dllexport) void ProcessData(uint8_t *data) {
        //sizeof(data) is always 8
    }
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?有没有一种方法可以在 C++ 代码中传递数组而不需要额外的内存分配?

c# c++ unity-game-engine

3
推荐指数
1
解决办法
2920
查看次数

Spring Boot Hikari 配置

我正在为 Spring Boot 应用程序配置 HikariCP,数据库是 Postgresql。

文件说:“我们使用推荐的dataSourceClassName替代jdbcUrl,但无论哪种是可以接受的。”

但是,下一行说:“注意:Spring Boot自动配置用户,需要使用jdbcUrl-based配置。”

如果我们使用jdbcUrl-based 配置并指定dataSourceClassNamethenjdbcUrl将被忽略,如果我们不指定数据源 - HikariDataSource将被创建。所以他们推荐HikariDataSource用于 Spring Boot 应用程序。

如果我们使用dataSourceClassName- 它将使用给定的属性创建(在我的情况下是PGSimpleDataSource使用它的祖先BaseDataSource)。

这两种配置都适合我。

所以,我的问题是:

  1. HikariDataSourcePGSimpleDataSource(或任何其他推荐的)之间有什么区别?
  2. 为什么建议在 Spring Boot 中使用jdbcUrl基于配置(因此HikariDataSource)?

java spring spring-boot hikaricp

2
推荐指数
1
解决办法
4443
查看次数