title: FFMPEG avformat_write_header changing my stream time_base
body: <p>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. </p>
  
  <p>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).   </p>
  
  <p>console log before and after av_format_write_header: </p>
  
  <pre><code>before avformat_write_header stream time_base: 1/25
  after avformat_write_header ret 0 stream time_base: -18082736/1
  </code></pre>
  
  <p>the code (abreviated to keep the post short, all calls in the original version had error checking):</p>
  
  <pre><code>AVCodecContext *codecContext;
  AVCodec * codec = avcodec_find_encoder(codec_id);  
  myOutputStream-&gt;stream = avformat_new_stream(outputFormatContext, *codec);
  myOutputStream-&gt;stream-&gt;id = outputFormatContext-&gt;nb_streams-1;
  codecContext = myOutputStream-&gt;stream-&gt;codec;
  codecContext-&gt;codec_id = codec_id;
  codecContext-&gt;bit_rate = 400000;
  codecContext-&gt;width    = width;
  codecContext-&gt;height   = height;
  myOutputStream-&gt;stream-&gt;time_base = (AVRational){ 1, 25 };
  codecContext-&gt;time_base       = myOutputStream-&gt;stream-&gt;time_base;
  codecContext-&gt;gop_size      = 12; 
  codecContext-&gt;pix_fmt       = AV_PIX_FMT_YUV420P;
  AVDictionary *opt = NULL;
  av_dict_copy(&amp;opt, opt_arg, 0);
  ret = avcodec_open2(codecContext, codec, &amp;opt);
  av_dict_free(&amp;opt);
  myOutputStream-&gt;frame = alloc_picture(codecContext-&gt;pix_fmt, codecContext-&gt;width, codecContext-&gt;height);
    myOutputStream-&gt;tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, codecContext-&gt;width, codecContext-&gt;height);
  
  //before: printing g_outputContext-&gt;stream time_base here
  ret = avformat_write_header(g_outputContext, &amp;opt);
  //after: printing g_outputContext-&gt;stream time_base here
  </code></pre>
  
  <p>If I run ffmpeg -i on the final video, I got this (why duration is zero?): </p>
  
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test4.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2mp41
      encoder         : Lavf55.19.104
    Duration: 00:00:00.05, start: 0.000000, bitrate: 99549 kb/s
      Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 800x600 [SAR 1:1 DAR 4:3], 463106 kb/s, 12800 fps, 12800 tbr, 12800 tbn, 25 tbc (default)
      Metadata:
        handler_name    : VideoHandler
  </code></pre>