2013-03-12 3 views
0

테스트로서 나는 1 프레임의 프레임 속도를 갖는 비디오를 만들고 싶습니다. 이처럼 vlc를 만들면 여전히 25fps로 재생됩니다. 아무도 아이디어가 있니?vlc는 잘못된 프레임 속도로 libavcodec로 생성 된 비디오를 지불합니다.

AVFormatContext* formatContext; 
avformat_alloc_output_context2(&formatContext, NULL, NULL, "test.h264"); 
AVOutputFormat* outputFormat = formatContext->oformat; 

AVStream* videoStream = av_new_stream(formatContext, 0); 
AVCodecContext* ctx = videoStream->codec; 

ctx->codec_type = AVMEDIA_TYPE_VIDEO; 
ctx->codec_id = CODEC_ID_H264;  

ctx->bit_rate = 500*1000; 
ctx->bit_rate_tolerance = 0; 
ctx->width = w; 
ctx->height = h; 
ctx->pix_fmt = AV_PIX_FMT_YUV420P; 
ctx->time_base.den = 1;//25; 
ctx->time_base.num = 1; 
+0

이 파일의 프레임 속도를 보여 -i는 FFmpeg 무엇을해야합니까? 어때? – rogerdpack

답변

1

이 오래된 질문이다 그러나 나는

AVStream 컨테이너에 따라 먹서에 의해 설정된다 명시 적 time_base을 가지고 같은 문제로 다른 사람을 도움이되기를 바랍니다. AVStream.time_base 코멘트에 명시된 바와 같이 : 힌트로 AVCodecContext.time_base의 사용자가 제공 한 값을 사용할 수 있습니다

먹서 .

당신은 올바른 값에 RAW FRAME 점을 설정 av_rescale_q()를 사용해야합니다 :

/* AVFrame* */ raw_frame->pts = av_rescale_q(my_pts, ctx->time_base, videoStream->time_base); 
. 
. 
. 
/* AVPacket pkt; */ 
avcodec_encode_video2(ctx, pkt, &got_packet); 
. 
. 
. 
av_write_frame(formatContext, &pkt);