1

ビデオの追加に mp4 パーサーを使用しています。私の問題は、ビデオを追加できないことです。BufferUnderFlow Exception などのエラーが発生します。どこで間違いを犯したのか誰か教えてもらえますか?

これは私のコードです:

public class MainActivity extends Activity
{
    Button b1;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        b1 = (Button)findViewById(R.id.button1);
        b1.setOnClickListener(new OnClickListener()
        {

            @SuppressWarnings("resource")
            @Override
            public void onClick(View v)
            {
                try 
                {
                    String f1 = Environment.getExternalStorageDirectory()+ "/wish_by_video.mp4";
                    String f2 = Environment.getExternalStorageDirectory() + "/wish_by_video.mp4";
                    String f3 = Environment.getExternalStorageDirectory() + "/wish_by_video.mp4";

                    Movie[] inMovies = new Movie[]{
                            MovieCreator.build(new FileInputStream(f1).getChannel()),
                            MovieCreator.build(new FileInputStream(f2).getChannel()),
                            MovieCreator.build(new FileInputStream(f3).getChannel())
                         };

                    List<Track> videoTracks = new LinkedList<Track>();
                    List<Track> audioTracks = new LinkedList<Track>();

                    for (Movie m : inMovies) {
                        for (Track t : m.getTracks()) {
                            if (t.getHandler().equals("soun")) {
                                audioTracks.add(t);
                            }
                            if (t.getHandler().equals("vide")) {
                                videoTracks.add(t);
                            }
                        }
                    }

                    Movie result = new Movie();

                    if (audioTracks.size() > 0) {
                        result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));
                    }
                    if (videoTracks.size() > 0) {
                        result.addTrack(new AppendTrack(videoTracks.toArray(new Track[3])));
                    }

                    IsoFile out = new DefaultMp4Builder().build(result);


                    @SuppressWarnings("resource")
                    FileChannel fc = new RandomAccessFile(String.format(Environment.getExternalStorageDirectory()+"output.mp4"), "rw").getChannel();
                    fc.position(0);
                    out.getBox(fc);
                    fc.close();

                } 
                catch (FileNotFoundException e) 
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
        });


    }
}
4

0 に答える 0