[Libav-user] FFMPEG avformat_write_header changing my stream time_base
cesar pachon
cesarpachon at gmail.com
Fri Apr 24 18:33:22 CEST 2015
I am muxing video using ffmpeg 2.1.3 with libavcodec 55.39.101 (forced to
that version because is the one available in google-chrome PNACL port
project). all my frames seems to have bad the time. they try to be rendered
all at once at the beggining of the video when playing it.
I am setting the stream time base to 1/25, but just after calling
avformat_write_header, it has the value of -18082736/1. in each frame, when
I print the stream time_base it says 1/12800, while the time_base of codec
is always ok (1/25).
console log before and after av_format_write_header:
before avformat_write_header stream time_base: 1/25
after avformat_write_header ret 0 stream time_base: -18082736/1
the code (abreviated to keep the post short, all calls in the original
version had error checking):
AVCodecContext *codecContext;
AVCodec * codec = avcodec_find_encoder(codec_id);
myOutputStream->stream = avformat_new_stream(outputFormatContext, *codec);
myOutputStream->stream->id = outputFormatContext->nb_streams-1;
codecContext = myOutputStream->stream->codec;
codecContext->codec_id = codec_id;
codecContext->bit_rate = 400000;
codecContext->width = width;
codecContext->height = height;
myOutputStream->stream->time_base = (AVRational){ 1, 25 };
codecContext->time_base = myOutputStream->stream->time_base;
codecContext->gop_size = 12;
codecContext->pix_fmt = AV_PIX_FMT_YUV420P;
AVDictionary *opt = NULL;
av_dict_copy(&opt, opt_arg, 0);
ret = avcodec_open2(codecContext, codec, &opt);
av_dict_free(&opt);
myOutputStream->frame = alloc_picture(codecContext->pix_fmt,
codecContext->width, codecContext->height);
myOutputStream->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P,
codecContext->width, codecContext->height);
//before: printing g_outputContext->stream time_base here
ret = avformat_write_header(g_outputContext, &opt);
//after: printing g_outputContext->stream time_base here
(note: I also posted this question in stackoverflow:
http://stackoverflow.com/questions/29850246/ffmpeg-avformat-write-header-changing-my-stream-time-base
)
Cesar Pachón
-------------------------------------------------------------
www.cesarpachon.com, just a digital hermit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150424/b3fdff1e/attachment.html>
More information about the Libav-user
mailing list