0

我正在使用此代码将音频与视频合并到一个文件中。

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();
    }

当我运行此代码时,try FileNotFoundException 后的 1 行被触发。

我无法解决这个问题,请帮助我

4

0 回答 0