title: ffmpeg - operation not permitted error while conversion
body: <p>I am developing an android app. My requirement is that to implement an rtsp streaming server on android. It has to live stream video and audio captured using <code>MediaRecorder</code>. Another requirement is that I have to use live555 as the streaming server. What I get from <code>MediaRecorder</code> is in MP4 or 3GP format. live555 cannot able to stream both. But it can stream audio if I recorded it only in 'RAW_AMR' format. Since live555 support 'mpg' format for streaming, I decided to put someone in middle who can convert 'mp4' or '3gp' to 'mpg', and I chose ffmpeg.</p>
  
  <p>I have ported live555 and ffmpeg to android. ffmpeg is able to convert the file recorded by <code>MediaRecorder</code> once it is finished. But the problem is that ffmpeg cannot be able to do it concurrently. That is, ffmpeg is not able to convert the file while recording. It shows an <code>Operation not permitted</code> error. I tried the same on my linux machine, using VLC to record instead of <code>MediaRecorder</code> on android. The result is same. ffmpeg is able to convert once the recording is finished, and not able to do the same while recording.</p>
  
  <p>Here is the ffmpeg command I issued on my linux box:</p>
  
  <pre><code>ffmpeg -v 9 -loglevel 99 -i test.mp4 test.mpg
  </code></pre>
  
  <p>Where <code>test.mp4</code> is the file to which VLC is recording in <code>mp4</code> format. and <code>test.mpg</code> is my destination file. The following is the output by ffmpeg on terminal.</p>
  
  <pre><code>ffmpeg version 0.8.9, Copyright (c) 2000-2011 the FFmpeg developers
    built on Feb  1 2012 18:29:27 with gcc 4.6.2 20111027 (Red Hat 4.6.2-1)
    configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --enable-bzlib --enable-libcelt --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
    libavutil    51.  9. 1 / 51.  9. 1
    libavcodec   53.  8. 0 / 53.  8. 0
    libavformat  53.  5. 0 / 53.  5. 0
    libavdevice  53.  1. 1 / 53.  1. 1
    libavfilter   2. 23. 0 /  2. 23. 0
    libswscale    2.  0. 0 /  2.  0. 0
    libpostproc  51.  2. 0 / 51.  2. 0
  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] ISO: File Type Major Brand: isom
  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] moov atom not found
  test.mp4: Operation not permitted
  </code></pre>
  
  <p>Would anyone please tell me what is causing the problem? Or is the scenario above is possible by ffmpeg. That is, is ffmpeg is able to do the conversion at the same time as that of recording? If it is not possible by ffmpeg, would you please suggest any alternative solutions?</p>
  
  <p>NOTE: I am putting a <code>C</code> tag because if it possible by some tweaking in C on ffmpeg, I am ready to do that(I want the solution that badly). But please provide some pointers to the right direction. </p>