vistual studio 2017中导入pthread.h的配置方法

1.下载pthread.h的相关库文件

下载路径 https://www.mirrorservice.org/sites/sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip

加压后得到两种系统版本的三个文件夹

pthreads.2 : 包含了pthread的源文件

Pre-built2 :包含了pthreads for win32的头文件和已编译号的库文件

QueueUserAPcEx :里面是一个alert的driver,编译需要DDK.

2.将库文件拷贝到vistual studio 的库文件路径中

先从vs中找到库文件的存储路径:

打开iostream的源文件点击打开所在的文件夹即可.

得到以下路径

 

拷贝文件主要用到第二个文件:Pre-built2

 将Pre-built2中include文件夹下的文件拷贝到....\MSVC\14.16.27023\include文件夹下

 将Pre-built2中lib文件夹下的文件拷贝到....\MSVC\14.16.27023\lib文件夹下(注意按照操作系统的位数拷贝,一一对应)

 将Pre-built2中dll文件夹下的x86文件夹下的文件拷贝到C:\Windows\SysWOW64文件夹下

3.配置pthread.h文件

打开pthread.h文件,添加"#define HAVE_STRUCT_TIMESPEC"

(此操作解决timespec重定义问题)

如图所示位置

4.使用pthread.h的操作

若出现在无法解析的外部符号,须在下方加上"#pragma comment(lib, "pthreadVC2.lib")"

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Visual Studio 使用 FFmpeg 将内存的 H.264 数据保存为 TS 文件,您需要将 FFmpeg 库添加到您的项目,并使用 C++ 代码编写文件保存功能。以下是一个简单的示例程序,它将内存的 H.264 数据保存为 MPEG-TS 文件: ```cpp extern "C" { #include <libavformat/avformat.h> #include <libavutil/opt.h> } int save_as_ts(unsigned char* h264_data, int h264_size, const char* output_file) { AVFormatContext* output_format_ctx = NULL; AVOutputFormat* output_format = NULL; AVStream* video_stream = NULL; AVPacket pkt; int ret; av_register_all(); // Register MPEG-TS output format output_format = av_guess_format("mpegts", NULL, NULL); if (!output_format) { return AVERROR_MUXER_NOT_FOUND; } // Create output format context if ((ret = avformat_alloc_output_context2(&output_format_ctx, output_format, NULL, output_file)) < 0) { return ret; } // Add video stream to output format context video_stream = avformat_new_stream(output_format_ctx, NULL); if (!video_stream) { return AVERROR_UNKNOWN; } // Set video codec parameters video_stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; video_stream->codecpar->codec_id = output_format->video_codec; video_stream->codecpar->width = 1280; // replace with your video width video_stream->codecpar->height = 720; // replace with your video height video_stream->codecpar->format = AV_PIX_FMT_YUV420P; // replace with your video pixel format // Open output file for writing if ((ret = avio_open(&output_format_ctx->pb, output_file, AVIO_FLAG_WRITE)) < 0) { return ret; } // Write stream headers if ((ret = avformat_write_header(output_format_ctx, NULL)) < 0) { return ret; } // Write H.264 packets to output file av_init_packet(&pkt); pkt.data = h264_data; pkt.size = h264_size; pkt.pts = AV_NOPTS_VALUE; pkt.dts = AV_NOPTS_VALUE; pkt.duration = 1; pkt.stream_index = video_stream->index; if ((ret = av_interleaved_write_frame(output_format_ctx, &pkt)) < 0) { return ret; } // Write stream trailer av_write_trailer(output_format_ctx); // Close output file avio_close(output_format_ctx->pb); avformat_free_context(output_format_ctx); return 0; } ``` 此代码使用 FFmpeg 库的 AVFormatContext 结构体创建 MPEG-TS 文件,并使用 avformat_new_stream() 函数创建视频流。然后,使用 avio_open() 函数打开输出文件,使用 avformat_write_header() 函数写入文件头,并使用 av_interleaved_write_frame() 函数将 H.264 包写入文件。最后,使用 av_write_trailer() 函数写入文件尾,并使用 avio_close() 函数关闭输出文件。 您可以在 Visual Studio 创建一个 C++ 项目,并将 FFmpeg 库和头文件添加到项目。然后,您可以将此代码添加到您的项目,并调用 save_as_ts() 函数来保存内存的 H.264 数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值