代码片段---使用ffmpeg从h264文件中提取出一帧一帧数据

本文介绍如何利用ffmpeg工具从.h264文件中逐帧提取包含0x00 00 00 01头部的完整视频帧数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

d盘有一个test.264文件,我们需要从这个h264文件中提取出一帧一帧的数据,所以直接采用ffmpeg来做。

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#ifdef __cplusplus
extern "C" {
#endif
#include <libswscale/swscale.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>
#include <libavutil/time.h>
#include <libavutil/avutil.h>
#include <libavutil/imgutils.h>
#include <libavutil/hwcontext.h>
#include <libavutil/error.h>
#ifdef __cplusplus
}
#endif

int main(int argc, char *argv[])
{
	AVFormatContext *input_ctx = NULL;
	AVCodecContext *decoder_ctx = NULL;
	AVCodec *decoder = NULL;
	enum AVHWDeviceType type;
	const char *dec_name = "h264_qsv";

	const char *in_file = "d://test.264";
	int video_stream = 0, ret;
	AVPacket packet;

		/* open the input file */
	if (avformat_open_input(&input_ctx, in_file
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值