title: How to merge audio and video files using ffmpeg in Android?
body: <p>I have an existing mp4 file and want to add an audio track to it using <code>ffmpeg</code> (the audio track is a wav file recorded from the device's microphone).</p>
  
  <p>I'm executing the following command but it's not generating any output. It seems that fmpeg simply hangs:</p>
  
  <pre><code>String[] command = new String[]{"-i", audioFilePath, "-i", videoFilePath, "-codec", "copy", "-shortest", outputFilePath};
  </code></pre>
  
  <p>The logs are:</p>
  
  <pre><code>Input #0, wav, from '/data/user/0/android.com.app/cache/30930595321169630261385.audio':
     Duration: 00:00:02.03, bitrate: 705 kb/s
       Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
   Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Android/data/android.com.app/cache/4632127da0955d4a461dfd622c78233e':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.41.100
     Duration: 00:00:02.04, start: 0.000000, bitrate: 728 kb/s
       Stream #1:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 500x280 [SAR 1:1 DAR 25:14], 724 kb/s, 16.67 fps, 16.67 tbr, 166667 tbn, 33.33 tbc (default)
       Metadata:
         handler_name    : VideoHandler
  </code></pre>
  
  <p>After this, there are no more log statements.</p>
  
  <p>Any ideas what could be causing this?</p>