Android ffmpeg yuv原始数据写入yuv文件

1.首先要给yuv数据分配缓存空间
u_int8_t *video_dst_data[4];
int video_dst_linesize[4];
int video_dst_bufsize;
video_dst_bufsize=av_image_alloc(video_dst_data,video_dst_linesize,dec_ctx->width,dec_ctx->height,pixelFormat,1);
2.
// 循环读取一帧视频
while (av_read_frame(fmt_ctx, &avPacket) >= 0) {
//判断是否为视频流
if (avPacket.stream_index == videoStream->index) {
LOGE(“AVStream is VideoStream”);
got_frame = 0;
//对该帧进行解码
ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, &avPacket);
if (ret < 0) {
LOGE(“Error decoding video\n ret=%d”, ret);
break;
}
if (got_frame) {
//把解码后视频帧添加到filter graph
if (av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF) <
0) {
LOGE(“Error while feeding the filter_graph\n”);
break;
}
//把滤波后的视频帧从filter graph取出来

你可能感兴趣的:(ffmpeg,ffmpeg,yuv)