linux下,使用ffmpeg解码h264,出错,如何解决?
linux下,使用ffmpeg解码h264,出错,如何解决?
日期:2014-05-16 浏览次数:20371 次
linux下,使用ffmpeg解码h264,出错,怎么解决???
#include
#include
#include
#include
#include
#include
#include
#include
#define INBUF_SIZE 4096
/*
* Video decoding example
*/
static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
char *filename)
{
FILE *f;
int i;
f=fopen(filename,"ab+");
// fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255);
for(i=0;i
fwrite(buf + i * wrap,1,xsize,f);
fclose(f);
}
static int decode_write_frame(const char *outfilename, AVCodecContext *avctx,
AVFrame *frame, int *frame_count, AVPacket *pkt, int last)
{
int len, got_frame;
char buf[1024];
printf("as;dkfjaskd\n");
len = avcodec_decode_video2(avctx, frame, &got_frame, pkt);
printf("the len is %d\n",len);
if (len
fprintf(stderr, "Error while decoding frame %d\n", *frame_count);
return len;
}
if (got_frame) {
printf("Saving %sframe %3d\n", last ? "last " : "", *frame_count);
fflush(stdout);
/* the picture is allocated by the decoder, no need to free it */
//snprintf(buf, sizeof(buf), outfilename, *frame_count);
pgm_save(frame->data[0], frame->linesize[0],
avctx->width, avctx->height, outfilename);
pgm_save(frame->data[1], frame->linesize[1],
avctx->width/2, avctx->height/2, outfilename);
pgm_save(frame->data[2], frame->linesize[2],
avctx->width/2, avctx->height/2, outfilename);
(*frame_count)++;
}
if (pkt->data) {
&nbs
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。