title: FFmpeg library: modified muxing sample for FLTP input and FLTP audio, loses audio
body: <p>Based on muxing sample that comes with FFmpeg docs, I have modified it, from input format as S16 to FLTP (planar stereo), and outputting to webm format (stereo).</p>
  
  <p>Since input is now FLTP, I am filling two arrays, then encoding again to FLTP. There are no obvious errors given on screen, but the resulting webm video does not play any audio (just the video content). This is just proof of concept in understanding things; here is an added (crude) function to fill up input FLTP stereo buffer:</p>
  
  <pre><code>static void get_audio_frame_for_planar_stereo(int16_t **samples, int frame_size, int nb_channels)
  {
      int j, i, v[2];
      int16_t *q1 = (int16_t *) samples[0];
      int16_t *q2 = (int16_t *) samples[1];
  
      for (j = 0; j &lt; frame_size; j++)
      {
          v[0] = (int)(sin(t) * 10000);
          v[1] = (int)(tan(t) * 10000);
          *q1++ = v[0];
          *q2++ = v[1];
          t     += tincr;
          tincr += tincr2;
      }
  }
  </code></pre>
  
  <p>Which I am calling from inside write_audio_frame() function.</p>
  
  <p>Note also, wherever code reffered AV_SAMPLE_FMT_S16 as input, I have changed to AV_SAMPLE_FMT_FLTP.</p>
  
  <p>Whole workable source is here:</p>
  
  <p><a href="https://gist.github.com/anonymous/05d1d7662e9feafc45a6" rel="nofollow">https://gist.github.com/anonymous/05d1d7662e9feafc45a6</a></p>
  
  <p>When run with ffprobe.exe, with these instructions:</p>
  
  <pre><code>ffprobe -show_packets output.webm &gt;output.txt
  </code></pre>
  
  <p>I see nothing out of ordinary, all pts/dts values appear to be in place:</p>
  
  <p><a href="https://gist.github.com/anonymous/3ed0d6308700ab991704" rel="nofollow">https://gist.github.com/anonymous/3ed0d6308700ab991704</a></p>
  
  <p>Could someone highlight cause of this mis-interpretation?</p>
  
  <p>Thanks for your time...</p>
  
  <p>p.s. I am using Zeranoe FFmpeg Windows builds (32 bit), built on Jan  9 2014 22:04:35 with gcc 4.8.2.(GCC)</p>
  
  <p><strong>Edit:</strong> Based on your guidance elsewhere, I tried the following:</p>
  
  <pre><code>    /* set options */
      //av_opt_set_int       (swr_ctx, "in_channel_count",   c-&gt;channels,       0);
      //av_opt_set_int       (swr_ctx, "in_sample_rate",     c-&gt;sample_rate,    0);
      //av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt",      AV_SAMPLE_FMT_FLTP, 0);
      //av_opt_set_int       (swr_ctx, "out_channel_count",  c-&gt;channels,       0);
      //av_opt_set_int       (swr_ctx, "out_sample_rate",    c-&gt;sample_rate,    0);
      //av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt",     c-&gt;sample_fmt,     0);
  
      av_opt_set_int(swr_ctx, "in_channel_layout",    AV_CH_LAYOUT_STEREO, 0);
      av_opt_set_int(swr_ctx, "in_sample_rate",       c-&gt;sample_rate, 0);
      av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
  
      av_opt_set_int(swr_ctx, "out_channel_layout",    AV_CH_LAYOUT_STEREO, 0);
      av_opt_set_int(swr_ctx, "out_sample_rate",       c-&gt;sample_rate, 0);
      av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
  </code></pre>
  
  <p>And the revised function:</p>
  
  <pre><code>static void get_audio_frame_for_planar_stereo(uint8_t **samples, int frame_size, int nb_channels)
  {
      int j, i;
      float v[2];
      float *q1 = (float *) samples[0];
      float *q2 = (float *) samples[1];
  
      for (j = 0; j &lt; frame_size; j++) 
      {
          v[0] = (tan(t) * 1);
          v[1] = (sin(t) * 1);
          *q1++ = v[0];
          *q2++ = v[1];
          t     += tincr;
          tincr += tincr2;
      }
  }
  </code></pre>
  
  <p>Now it appears to be working properly. I tried changing function parameters from uint8_t** to float**, as well as src_samples_data from uint8_t** to float**, but did not make any difference, in a view.</p>
  
  <p>Updated code: <a href="https://gist.github.com/anonymous/35371b2c106961029c3d" rel="nofollow">https://gist.github.com/anonymous/35371b2c106961029c3d</a></p>
  
  <p>Thanks for highlighting the place(s) that result in this behavior!</p>