title: Convert Images to Video in Android
body: <p>I Successfully convert images to video in android by using ffmpeg, javacv
  now i want to add background music on video.
  Below code convert images to video but cannot find audio</p>
  
  <pre><code>public void imagevideo(ArrayList&lt;String&gt; links)
  {
  
      Log.d("Received",""+links);
  
          iplimage = new opencv_core.IplImage[links.size()];
         for (int j = 0; j &lt; links.size(); j++) 
         {
         System.out.println(" j " + "Inise Loop"+links.get(j).toString());
         iplimage[j]=cvLoadImage(links.get(j));
  
  
       }
  </code></pre>
  
  <p>here is get image array length
             Log.d("Length",""+iplimage.length);
          Frame framee;
             File videopath = new File(Environment.getExternalStorageDirectory().toString()+"/test");
             videopath.mkdirs();</p>
  
  <pre><code>    String audioFile = Environment.getExternalStorageDirectory().getAbsolutePath()+"/susic.mp3"; 
  
  
           try {
  
  
  
              FFmpegFrameGrabber audioFrames = FFmpegFrameGrabber.createDefault(audioFile);
              FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(Environment.getExternalStorageDirectory().toString()+"/test/video.mp4",400,400,audioFrames.getAudioChannels());
  
               Log.d("Enter in Try","FF");               
               Log.d("Start Recorder","");
               Log.d("Length","Sound Grab");
               audioFrames.start();
  
               recorder.setFrameRate(30);
               recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);
               recorder.setVideoBitrate(9000);
               recorder.setFormat("mp4");
               recorder.setAudioChannels(2);
               recorder.setSampleRate(44100);
               recorder.setVideoQuality(0); // maximum quality
               recorder.start();
  
               Frame frame=null;
  
               Log.d("Length",""+iplimage.length);
              for (int i=0;i&lt; iplimage.length;i++)
              {   
                  frame=audioFrames.grabFrame();
  
                     long t = 9000 * (System.currentTimeMillis());
                     if (t &gt; recorder.getTimestamp()) {
                         recorder.setTimestamp(t);
  
                         recorder.record(iplimage[i]);
                          recorder.record(frame); 
  
  
  
  
                 }
  
              }
               recorder.stop();
  
  
  
  
  }
  </code></pre>