mp4合并不显示视频

时间:2019-10-26 06:08:03

标签: java android-studio

他是开发应用程序的新手 正在尝试创建YouTube下载器... 从itag提取适用于360p和720p,但对于480p和1080,我们需要从仪表板视频下载并合并音频和视频..因此,我正在使用mp4合并...但在输出中,仅获得音频而不显示视频

    private void mergeMp4(String inFilePathAudio, String inFilePathVideo) {
        String path = inFilePathVideo.substring(0, inFilePathVideo.lastIndexOf("/"));
        try {
            Movie video = MovieCreator.build(inFilePathVideo);
            Movie audio = MovieCreator.build(inFilePathAudio);
            video.addTrack(audio.getTracks().get(0));
            Container out = new DefaultMp4Builder().build(video);
            long currentMillis = System.currentTimeMillis();
            FileOutputStream fos = new FileOutputStream(new File(path + TEMP_FILE_NAME + currentMillis + ".mp4"));
            out.writeContainer(fos.getChannel());
            fos.close();
            File inAudioFile = new File(inFilePathAudio);
            inAudioFile.delete();
            File inVideoFile = new File(inFilePathVideo);
            if (inVideoFile.delete()) {
                File tempOutFile = new File(path + TEMP_FILE_NAME + currentMillis + ".mp4");
                tempOutFile.renameTo(inVideoFile);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

告诉我如何解决

0 个答案:

没有答案