0

I am using this code to merge an audio with a video into a single file .

String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();

    String video = "android.resource://" + getPackageName() + "/" + R.raw.yakoob;
    String audio = "android.resource://" + getPackageName() + "/" + R.raw.ermia;

    try
    {
        H264TrackImpl mp4 = new H264TrackImpl(new FileDataSourceImpl(video));
        AACTrackImpl mp3 = new AACTrackImpl(new FileDataSourceImpl(audio));
        ////
        Movie movie = new Movie();
        movie.addTrack(mp4);
        movie.addTrack(mp3);
        Container con = new DefaultMp4Builder().build(movie);

        @SuppressWarnings("resource")
        FileChannel fc = new FileOutputStream(new File(baseDir+"/ramin.mp4")).getChannel();
        con.writeContainer(fc);
        fc.close();

    } catch (FileNotFoundException e) 
    {
        Toast toast = Toast.makeText(this, "File: not found!", Toast.LENGTH_LONG);  
        toast.show();
    } catch (IOException e)
    {
        e.printStackTrace();
    }

When i run this code, 1 line after try FileNotFoundException is triggered.

I can't solve this problem, please help me

LBes
  • 3,366
  • 1
  • 32
  • 66

0 Answers0