0

First of all hello,

When I add another mp4 file at the end of an mp4 file, the video looks completely black screen but I can get the video sounds.

If I add a copy of a video to the end of it, I saw that there was no problem, but this is not a scenario I want.

I am getting the "text relocations" error when merging with the FFmpeg library. (This problem is fixed when I change this library version, but I have other problems. Therefore, mp4parser is an alternative I see.)

The piece of code that allows the videos to be merged is as follows. Thank you from now.

private void appendTwoVideos(String firstVideoPath, String secondVideoPath) {
    try {
        Movie[] inMovies = new Movie[2];

        inMovies[0] = MovieCreator.build(firstVideoPath);
        inMovies[1] = MovieCreator.build(secondVideoPath);

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

        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(DIRECTORY_PATH + "output.mp4", "rw").getChannel();
        out.writeContainer(fc);
        fc.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Darkhmar
  • 137
  • 1
  • 7
  • Both MP4 files must have the same attributes for proper concatenation. – llogan Jul 09 '20 at 18:21
  • Both videos are 640x360 and 0.2 megapixels. – Darkhmar Jul 09 '20 at 20:12
  • Please, i need help. – Darkhmar Jul 10 '20 at 06:09
  • Need to see details on each file. Show the complete output of: `ffmpeg -n -i input1.mp4 -i input2.mp4`. This command is only to get file info: its does not output a file. It will provide useful info about the inputs and your `ffmpeg` version. This info is required to provide an answer. Copy the **complete** log from that command. [Edit] your question and paste the complete log into your question. Ignore the `At least one output file must be specified error` in the log. – llogan Jul 10 '20 at 17:09

1 Answers1

0

This is probably because the videos you are trying to append or join are of different framerates. For example one might be a slowmotion video and other might be a fast froward/Time lapse video. During appending, audio works fine but android doesn't give functionality of appending videos of different framerate by using is libraries.So you see a black screen with audio.

I would recommend using FFmpeg library. Although its slow but gives you the desired result.

Raghav Sharma
  • 43
  • 1
  • 6