2

ビデオを追加するためにこのライブラリを試しました-mp4parser ..同じモードのビデオを追加するのに問題なく動作します..しかし、別のモードのビデオを追加したい-タイムラプスと通常モードのビデオ..どのように進めればよいですか?すべてのビデオVidが同じモードの場合は正常に機能しますが、ビデオが異なるモードの場合は追加に失敗します。

public class MergedVideo extends AsyncTask<Void, Integer, String> {
    @Override
    protected void onPreExecute() {
    }
    ;
    @Override
    protected String doInBackground(Void... voids) {
        try {
            File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
                    Environment.DIRECTORY_PICTURES), "Vid");
            File f = new File(mediaStorageDir.getPath());
            File file[] = f.listFiles();
            String paths[] = new String[file.length];
            Movie[] inMovies = new Movie[file.length];
            for (int i = 0; i < file.length; i++) {
                paths[i] = file[i].getPath();
                inMovies[i] = MovieCreator.build(paths[i]);
            }
            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[videoTracks.size()])));
            }
            BasicContainer out = (BasicContainer) new DefaultMp4Builder()
                    .build(result);
            @SuppressWarnings("resource")
            FileChannel fc = new RandomAccessFile(String.format(Environment
                    .getExternalStorageDirectory() + "/mergedvideo.mp4"),
                    "rw").getChannel();
            out.writeContainer(fc);
            fc.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.e("Bhu", e.toString());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.e("Bhu", e.toString());
        }
        String mFileName = Environment.getExternalStorageDirectory()
                .getAbsolutePath();
        mFileName += "/mergedvideo.mp4";
        return mFileName;
    }
4

0 に答える 0