title: Call ffmpeg in c++ with system() function fails
body: <p>I write a c++ program which needs to convert some(say:10) mp4 videos to flv videos.
  I use ffmpeg in my program for each video like this:  </p>
  
  <pre><code>system("ffmpeg -i video -filter:v yadif -ar 44100 -sameq -y -f flv temp.flv")
  </code></pre>
  
  <p>however,it turns out:<strong>only first video will be converted successfully,the others will fail.</strong><br>
  it means:<br>
  when i change the input order of which video to convert and re-execution the program,it behave the same:only the first video(will be different each time as i changed the input video order) will be converted successfully.  </p>
  
  <p><strong>The error message like:</strong>  </p>
  
  <p>[h264 @ 0xaee0740] concealing 45 DC, 45 AC, 45 MV errors<br>
  [h264 @ 0xaee0ce0] AVC: nal size 305665<br>
      Last message repeated 1 times<br>
  [h264 @ 0xaee0ce0] no frame!<br>
  [h264 @ 0xaee1280] AVC: nal size 572993<br>
      Last message repeated 1 times<br>
  [h264 @ 0xaee1280] no frame!<br>
  [aac @ 0xad9ccc0] channel element 0.13 is not allocated<br>
  Error while decoding stream #0:1<br>
  [aac @ 0xad9ccc0] channel element 0.13 is not allocated<br>
  Error while decoding stream #0:1<br>
  [aac @ 0xad9ccc0] channel element 0.13 is not allocated<br>
  Error while decoding stream #0:1<br>
  ......<br>
  The most strange thing is :<strong>when i run ffmpeg command in bash shell,all video will be converted successfully</strong> .</p>
  
  <p>After google it,I have try these(certainly failed):</p>
  
  <ol>
  <li>remove -sameq option,the result is same;</li>
  <li><p>write ffmpeg commod in a shell script ConvertToFlv.sh like:</p>
  
  <pre><code>/usr/local/bin/ffmpeg -i "$dir/$1" -filter:v yadif -ar 44100 -sameq -y -f flv "$dir/temp.fiv"
  </code></pre>
  
  <p>then call this script in program like</p>
  
  <pre><code>system("ConvertToFlv.sh"+video)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>system("sh ConvertToFlv.sh"+video)
  </code></pre>
  
  <p>The result is same.</p></li>
  </ol>
  
  <p>The ffmpeg configure is:</p>
  
  <pre><code>  ffmpeg version 0.9.1.git Copyright (c) 2000-2012 the FFmpeg developers
    built on Dec 17 2012 16:17:30 with gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
    configuration: --enable-gpl --enable-postproc --enable-nonfree --enable-postproc --enable-swscale --enable-avfilter --enable-pthreads --enable-libxvid --enable-libx264 --enable-libmp3lame --enable-libfaac --disable-ffserver --disable-ffplay
    libavutil      51. 41.100 / 51. 41.100
    libavcodec     54.  4.100 / 54.  4.100
    libavformat    54.  1.100 / 54.  1.100
    libavdevice    53.  4.100 / 53.  4.100
    libavfilter     2. 62.101 /  2. 62.101
    libswscale      2.  1.100 /  2.  1.100
    libswresample   0.  7.100 /  0.  7.100
    libpostproc    52.  0.100 / 52.  0.100
  </code></pre>
  
  <p>and my machine envirment is:</p>
  
  <pre><code>Linux master 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
  </code></pre>
  
  <p>I'm irritable now,I hope someone can give me some advice,really appreciate it.</p>